From 6f160a1d108075f2aed3834ef079a362dfef94eb Mon Sep 17 00:00:00 2001 From: yaozm Date: Tue, 10 Oct 2023 17:47:14 +0800 Subject: [PATCH] feat(tests): Install and enable login captcha extension - Install and enable login captcha extension - Add publish and install commands - Initialize the login captcha service provider --- tests/Facades/CaptchaBuilderTest.php | 1 - tests/Fixtures/.gitkeep | 0 tests/Fixtures/database.sqlite | Bin 131072 -> 0 bytes tests/TestCase.php | 47 +++++++++++++++------------ 4 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 tests/Fixtures/.gitkeep delete mode 100644 tests/Fixtures/database.sqlite 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 cfab258e0f26de55ea1d2959fba97be7a3d5bb70..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 131072 zcmeI5&u<$?mdCp#O6^|~lOHa(@@0Xfbb11ttuV2%UKWifxiVlQ)CV1dCR*S+n|Z7+)%U=hq^fPGa>va6dd z$}}7xBEFPb?5=wCs_OGzRaaM)$WK0AcYK@eR_hhZXG_XUimEDq%b22!exxW0y(^dK z&=qCmOL|Yy(Rrzzlf&Oh$NTQTPLRNfQ{O7-?X))W=ZSC5e0Rn>edpA-soChy$nQpe zr~Y0&eYn2wHKsW~rRi6$s4d;McFML@syMD$ua<4IV!Msl<+-(dcD0aYh1HwuS!Tpy z4K{6vlupTDj_ccdcAdFZpSg{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;KmY_l00ck)1V8`;KmY`eD*=4|-*L4Z$_)Y_00JNY0w4eaAOHd&00JNY z0?$qW&;QTP3X&iI0w4eaAOHd&00JNY0w4eaAaGm>@csYl0=uF)ra z-M*9i$=&sh&3pGh&VN$a`t-90+dnmCj4zxL*SK(Pe#Y3hoxOchd39;V5T8PI!>GA? zB(z&~DOh|xoUu!vBV^ae#*a&MyiUh!bX=rEmyTE3 z=P%RySvp>7A8C5;gq^4Jb9C^u7wEtX1V8`;KmY_l00ck)1V8`;KmY_l;DstartMockery(); + $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'); - } }