From fec755359fcad69aac763a6231e5fe82c5e8d33c Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 27 Feb 2024 13:57:55 +0000 Subject: [PATCH 1/3] Use Testbench configuration feature --- testbench.yaml | 5 ++++ .../create_password_reset_tokens_table.php | 22 ---------------- .../migrations/create_users_table.php | 26 ------------------- tests/src/TestCase.php | 9 +++---- 4 files changed, 8 insertions(+), 54 deletions(-) create mode 100644 testbench.yaml delete mode 100644 tests/database/migrations/create_password_reset_tokens_table.php delete mode 100644 tests/database/migrations/create_users_table.php diff --git a/testbench.yaml b/testbench.yaml new file mode 100644 index 00000000000..c2aa11f93bb --- /dev/null +++ b/testbench.yaml @@ -0,0 +1,5 @@ +migrations: + - tests/database/migrations + +workbench: + install: true diff --git a/tests/database/migrations/create_password_reset_tokens_table.php b/tests/database/migrations/create_password_reset_tokens_table.php deleted file mode 100644 index bce2f339eea..00000000000 --- a/tests/database/migrations/create_password_reset_tokens_table.php +++ /dev/null @@ -1,22 +0,0 @@ -string('email')->index(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - } - - public function down(): void - { - Schema::dropIfExists('password_reset_tokens'); - } -}; diff --git a/tests/database/migrations/create_users_table.php b/tests/database/migrations/create_users_table.php deleted file mode 100644 index 2bf418036fa..00000000000 --- a/tests/database/migrations/create_users_table.php +++ /dev/null @@ -1,26 +0,0 @@ -id(); - $table->string('name'); - $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); - $table->string('password'); - $table->rememberToken(); - $table->timestamps(); - }); - } - - public function down(): void - { - Schema::dropIfExists('users'); - } -}; diff --git a/tests/src/TestCase.php b/tests/src/TestCase.php index 05f6e167eeb..4fbbf1d7656 100644 --- a/tests/src/TestCase.php +++ b/tests/src/TestCase.php @@ -17,12 +17,14 @@ use Filament\Widgets\WidgetsServiceProvider; use Illuminate\Foundation\Testing\LazilyRefreshDatabase; use Livewire\LivewireServiceProvider; +use Orchestra\Testbench\Concerns\WithWorkbench; use Orchestra\Testbench\TestCase as BaseTestCase; use RyanChandler\BladeCaptureDirective\BladeCaptureDirectiveServiceProvider; abstract class TestCase extends BaseTestCase { use LazilyRefreshDatabase; + use WithWorkbench; protected function getPackageProviders($app): array { @@ -49,12 +51,7 @@ protected function getPackageProviders($app): array ]; } - protected function defineDatabaseMigrations(): void - { - $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); - } - - protected function getEnvironmentSetUp($app): void + protected function defineEnvironment($app): void { $app['config']->set('auth.passwords.users.table', 'password_reset_tokens'); $app['config']->set('auth.providers.users.model', User::class); From aa844606adefe782cd466293b1654974261ad6aa Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 27 Feb 2024 22:02:36 +0800 Subject: [PATCH 2/3] wip --- .gitattributes | 1 + composer.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index ec3577d888a..1eddc24b69c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,4 +3,5 @@ /.github export-ignore /.gitignore export-ignore /phpunit.xml.dist export-ignore +/testbench.yaml export-ignore /tests export-ignore diff --git a/composer.json b/composer.json index 789923a75e0..4787fd5745d 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "league/flysystem-aws-s3-v3": "^3.0", "nunomaduro/termwind": "^1.0|^2.0", "openspout/openspout": "^4.23", - "orchestra/testbench": "^8.0|^9.0", + "orchestra/testbench": "^8.20|^9.0", "pestphp/pest": "^2.0", "pestphp/pest-plugin-laravel": "^2.0", "phpstan/extension-installer": "^1.1", From 493d560d3a8b9817b08e142ad891bfb988ea5ab5 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 27 Feb 2024 22:45:51 +0800 Subject: [PATCH 3/3] wip --- tests/src/TestCase.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/src/TestCase.php b/tests/src/TestCase.php index 4fbbf1d7656..8cefc56327c 100644 --- a/tests/src/TestCase.php +++ b/tests/src/TestCase.php @@ -53,7 +53,6 @@ protected function getPackageProviders($app): array protected function defineEnvironment($app): void { - $app['config']->set('auth.passwords.users.table', 'password_reset_tokens'); $app['config']->set('auth.providers.users.model', User::class); $app['config']->set('view.paths', [ ...$app['config']->get('view.paths'),