diff --git a/tests/Facades/CaptchaBuilderTest.php b/tests/Facades/CaptchaBuilderTest.php index 78e03af..138e29f 100644 --- a/tests/Facades/CaptchaBuilderTest.php +++ b/tests/Facades/CaptchaBuilderTest.php @@ -15,6 +15,5 @@ use Guanguans\DcatLoginCaptcha\Facades\CaptchaBuilder; it('can get captcha content', function (): void { - $this->markTestSkipped('This test is skipped.'); expect(CaptchaBuilder::get())->toBeString(); })->group(__DIR__, __FILE__); diff --git a/tests/Fixtures/.gitkeep b/tests/Fixtures/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Fixtures/database.sqlite b/tests/Fixtures/database.sqlite deleted file mode 100644 index cfab258..0000000 Binary files a/tests/Fixtures/database.sqlite and /dev/null differ diff --git a/tests/TestCase.php b/tests/TestCase.php index 6623b93..aa1917c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -48,6 +48,7 @@ protected function setUp(): void { parent::setUp(); $this->startMockery(); + $this->install(); } protected function tearDown(): void @@ -56,6 +57,26 @@ protected function tearDown(): void parent::tearDown(); } + /** + * @noinspection ForgottenDebugOutputInspection + * @noinspection DebugFunctionUsageInspection + */ + protected function install(): void + { + try { + // $this->fixDatabaseMigrations(); + // $this->loadMigrationsFrom(__DIR__.'/../vendor/dcat/laravel-admin/database/migrations'); + Artisan::call('admin:publish', ['--force' => false]); + Artisan::call('admin:install'); + // Artisan::call('admin:ext-install', ['name' => 'guanguans.dcat-login-captcha', ['--path' => __DIR__.'/../']]); + // Artisan::call('admin:ext-enable', ['name' => 'guanguans.dcat-login-captcha']); + $loginCaptchaServiceProvider = app(LoginCaptchaServiceProvider::class); + $loginCaptchaServiceProvider->init(); + } catch (\Throwable $throwable) { + dump($throwable->getMessage()); + } + } + protected function getPackageProviders($app): array { return [ @@ -77,24 +98,16 @@ protected function defineEnvironment($app): void }); } - protected function defineDatabaseMigrations(): void + protected function defineRoutes($router): void { - // $this->fixDatabaseMigrations(); - Artisan::call('admin:publish', [ - // '--force' => true - ]); - Artisan::call('admin:install'); - // Artisan::call('admin:ext-install', ['name' => 'guanguans.dcat-login-captcha', ['--path' => __DIR__.'/../']]); - // Artisan::call('admin:ext-enable', ['name' => 'guanguans.dcat-login-captcha']); - // $this->loadMigrationsFrom(__DIR__.'/../vendor/dcat/laravel-admin/database/migrations'); - $loginCaptchaServiceProvider = app(LoginCaptchaServiceProvider::class); - $loginCaptchaServiceProvider->init(); + Route::get('foo/bar', static function (): void { + })->name('dcat.admin.foo.bar'); } protected function fixDatabaseMigrations(): void { - $traverser = new NodeTraverser(); - $traverser->addVisitor(new class() extends NodeVisitorAbstract { + $nodeTraverser = new NodeTraverser(); + $nodeTraverser->addVisitor(new class() extends NodeVisitorAbstract { public function enterNode(Node $node): void { if ($node instanceof \PhpParser\Node\Expr\Closure) { @@ -119,13 +132,7 @@ public function enterNode(Node $node): void $migratedFile = __DIR__.'/../vendor/dcat/laravel-admin/database/migrations/2020_11_01_083237_update_admin_menu_table.php'; $stmts = (new ParserFactory())->create(1)->parse(File::get($migratedFile)); - $traverser->traverse($stmts); + $nodeTraverser->traverse($stmts); File::put($migratedFile, (new Standard())->prettyPrintFile($stmts)); } - - protected function defineRoutes($router): void - { - Route::get('foo/bar', static function (): void { - })->name('dcat.admin.foo.bar'); - } }