From 824ac3e2dab2b2b0335cebfd19a23b29e54ecd70 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 3 Mar 2025 23:16:23 +0800 Subject: [PATCH 1/7] [11.x] Test Improvements Signed-off-by: Mior Muhammad Zaki --- composer.json | 2 +- tests/Integration/Concurrency/ConcurrencyTest.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index cf2c2589ce8f..117a554293bf 100644 --- a/composer.json +++ b/composer.json @@ -111,7 +111,7 @@ "league/flysystem-read-only": "^3.25.1", "league/flysystem-sftp-v3": "^3.25.1", "mockery/mockery": "^1.6.10", - "orchestra/testbench-core": "^9.9.4", + "orchestra/testbench-core": "9.x-dev", "pda/pheanstalk": "^5.0.6", "php-http/discovery": "^1.15", "phpstan/phpstan": "^2.0", diff --git a/tests/Integration/Concurrency/ConcurrencyTest.php b/tests/Integration/Concurrency/ConcurrencyTest.php index a745a8d27bc7..092dba3d0a08 100644 --- a/tests/Integration/Concurrency/ConcurrencyTest.php +++ b/tests/Integration/Concurrency/ConcurrencyTest.php @@ -7,14 +7,18 @@ use Illuminate\Foundation\Application; use Illuminate\Process\Factory as ProcessFactory; use Illuminate\Support\Facades\Concurrency; +use Orchestra\Testbench\Attributes\UsesVendor; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; #[RequiresOperatingSystem('Linux|DAR')] +#[UsesVendor] class ConcurrencyTest extends TestCase { protected function setUp(): void { + parent::setUp(); + $this->defineCacheRoutes(<< Date: Mon, 3 Mar 2025 23:32:49 +0800 Subject: [PATCH 2/7] Test Improvements Signed-off-by: Mior Muhammad Zaki --- composer.json | 2 +- tests/Integration/Cache/DynamoDbStoreTest.php | 2 +- tests/Integration/Cookie/CookieTest.php | 2 +- ...ctionWithAfterCommitUsingDatabaseTransactionsTest.php | 2 +- .../DatabaseEmulatePreparesMariaDbConnectionTest.php | 4 ++-- .../MySql/DatabaseEmulatePreparesMySqlConnectionTest.php | 4 ++-- .../Database/Postgres/PostgresSchemaBuilderTest.php | 4 ++-- tests/Integration/Mail/SendingMarkdownMailTest.php | 2 +- tests/Integration/Mail/SendingQueuedMailTest.php | 2 +- tests/Integration/Queue/JobEncryptionTest.php | 4 ++-- tests/Integration/Queue/ModelSerializationTest.php | 2 +- tests/Integration/Queue/QueueConnectionTest.php | 9 +++------ tests/Integration/View/BladeAnonymousComponentTest.php | 2 +- tests/Integration/View/BladeTest.php | 2 +- tests/Integration/View/RenderableViewExceptionTest.php | 2 +- 15 files changed, 21 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 117a554293bf..7bf2d4615eee 100644 --- a/composer.json +++ b/composer.json @@ -111,7 +111,7 @@ "league/flysystem-read-only": "^3.25.1", "league/flysystem-sftp-v3": "^3.25.1", "mockery/mockery": "^1.6.10", - "orchestra/testbench-core": "9.x-dev", + "orchestra/testbench-core": "9.11.x-dev", "pda/pheanstalk": "^5.0.6", "php-http/discovery": "^1.15", "phpstan/phpstan": "^2.0", diff --git a/tests/Integration/Cache/DynamoDbStoreTest.php b/tests/Integration/Cache/DynamoDbStoreTest.php index b465cc61ea0e..7abe70d27864 100644 --- a/tests/Integration/Cache/DynamoDbStoreTest.php +++ b/tests/Integration/Cache/DynamoDbStoreTest.php @@ -65,7 +65,7 @@ public function testLocksCanBeAcquired() * @param \Illuminate\Foundation\Application $app * @return void */ - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { if (! env('DYNAMODB_CACHE_TABLE')) { $this->markTestSkipped('DynamoDB not configured.'); diff --git a/tests/Integration/Cookie/CookieTest.php b/tests/Integration/Cookie/CookieTest.php index bc5252630376..ed5223022a91 100644 --- a/tests/Integration/Cookie/CookieTest.php +++ b/tests/Integration/Cookie/CookieTest.php @@ -42,7 +42,7 @@ public function test_cookie_is_sent_back_with_proper_expire_time_with_respect_to $this->assertEquals(Carbon::now()->getTimestamp() + 60, $response->headers->getCookies()[1]->getExpiresTime()); } - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $app->instance( ExceptionHandler::class, diff --git a/tests/Integration/Database/EloquentTransactionWithAfterCommitUsingDatabaseTransactionsTest.php b/tests/Integration/Database/EloquentTransactionWithAfterCommitUsingDatabaseTransactionsTest.php index 25a8b27a72cc..620df3d0b9c7 100644 --- a/tests/Integration/Database/EloquentTransactionWithAfterCommitUsingDatabaseTransactionsTest.php +++ b/tests/Integration/Database/EloquentTransactionWithAfterCommitUsingDatabaseTransactionsTest.php @@ -32,7 +32,7 @@ protected function setUp(): void } } - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $connection = $app->make('config')->get('database.default'); diff --git a/tests/Integration/Database/MariaDb/DatabaseEmulatePreparesMariaDbConnectionTest.php b/tests/Integration/Database/MariaDb/DatabaseEmulatePreparesMariaDbConnectionTest.php index 8c155518dcb5..451fd3a1bd69 100755 --- a/tests/Integration/Database/MariaDb/DatabaseEmulatePreparesMariaDbConnectionTest.php +++ b/tests/Integration/Database/MariaDb/DatabaseEmulatePreparesMariaDbConnectionTest.php @@ -10,9 +10,9 @@ #[RequiresPhpExtension('pdo_mysql')] class DatabaseEmulatePreparesMariaDbConnectionTest extends DatabaseMariaDbConnectionTest { - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { - parent::getEnvironmentSetUp($app); + parent::defineEnvironment($app); $app['config']->set('database.connections.mariadb.options', [ PDO::ATTR_EMULATE_PREPARES => true, diff --git a/tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php b/tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php index 62592a40486f..a67d747945e7 100755 --- a/tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php +++ b/tests/Integration/Database/MySql/DatabaseEmulatePreparesMySqlConnectionTest.php @@ -10,9 +10,9 @@ #[RequiresPhpExtension('pdo_mysql')] class DatabaseEmulatePreparesMySqlConnectionTest extends DatabaseMySqlConnectionTest { - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { - parent::getEnvironmentSetUp($app); + parent::defineEnvironment($app); $app['config']->set('database.connections.mysql.options', [ PDO::ATTR_EMULATE_PREPARES => true, diff --git a/tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php b/tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php index 4f64c21fbc80..bfcf439d74ac 100644 --- a/tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php +++ b/tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php @@ -13,9 +13,9 @@ #[RequiresPhpExtension('pdo_pgsql')] class PostgresSchemaBuilderTest extends PostgresTestCase { - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { - parent::getEnvironmentSetUp($app); + parent::defineEnvironment($app); $app['config']->set('database.connections.pgsql.search_path', 'public,private'); } diff --git a/tests/Integration/Mail/SendingMarkdownMailTest.php b/tests/Integration/Mail/SendingMarkdownMailTest.php index 591b7264f60a..43ecd156646d 100644 --- a/tests/Integration/Mail/SendingMarkdownMailTest.php +++ b/tests/Integration/Mail/SendingMarkdownMailTest.php @@ -12,7 +12,7 @@ class SendingMarkdownMailTest extends TestCase { - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $app['config']->set('mail.driver', 'array'); diff --git a/tests/Integration/Mail/SendingQueuedMailTest.php b/tests/Integration/Mail/SendingQueuedMailTest.php index 6f982043ce65..e20a44659cbb 100644 --- a/tests/Integration/Mail/SendingQueuedMailTest.php +++ b/tests/Integration/Mail/SendingQueuedMailTest.php @@ -11,7 +11,7 @@ class SendingQueuedMailTest extends TestCase { - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $app['config']->set('mail.driver', 'array'); diff --git a/tests/Integration/Queue/JobEncryptionTest.php b/tests/Integration/Queue/JobEncryptionTest.php index 704c08001074..85701d51871f 100644 --- a/tests/Integration/Queue/JobEncryptionTest.php +++ b/tests/Integration/Queue/JobEncryptionTest.php @@ -21,9 +21,9 @@ class JobEncryptionTest extends DatabaseTestCase { use DatabaseMigrations; - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { - parent::getEnvironmentSetUp($app); + parent::defineEnvironment($app); $app['config']->set('app.key', Str::random(32)); $app['config']->set('queue.default', 'database'); diff --git a/tests/Integration/Queue/ModelSerializationTest.php b/tests/Integration/Queue/ModelSerializationTest.php index 359bbff8fa84..bd3b401c6576 100644 --- a/tests/Integration/Queue/ModelSerializationTest.php +++ b/tests/Integration/Queue/ModelSerializationTest.php @@ -18,7 +18,7 @@ class ModelSerializationTest extends TestCase { use RefreshDatabase; - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $app['config']->set('database.connections.custom', [ 'driver' => 'sqlite', diff --git a/tests/Integration/Queue/QueueConnectionTest.php b/tests/Integration/Queue/QueueConnectionTest.php index 1ae5f1ef9083..7ad7722499a4 100644 --- a/tests/Integration/Queue/QueueConnectionTest.php +++ b/tests/Integration/Queue/QueueConnectionTest.php @@ -8,17 +8,14 @@ use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Support\Facades\Bus; use Mockery as m; +use Orchestra\Testbench\Attributes\WithConfig; use Orchestra\Testbench\TestCase; use Throwable; +#[WithConfig('queue.default', 'sqs')] +#[WithConfig('queue.connections.sqs.after_commit', true)] class QueueConnectionTest extends TestCase { - protected function getEnvironmentSetUp($app) - { - $app['config']->set('queue.default', 'sqs'); - $app['config']->set('queue.connections.sqs.after_commit', true); - } - protected function tearDown(): void { QueueConnectionTestJob::$ran = false; diff --git a/tests/Integration/View/BladeAnonymousComponentTest.php b/tests/Integration/View/BladeAnonymousComponentTest.php index eb29765dae03..0281de48d80f 100644 --- a/tests/Integration/View/BladeAnonymousComponentTest.php +++ b/tests/Integration/View/BladeAnonymousComponentTest.php @@ -41,7 +41,7 @@ public function test_anonymous_components_with_custom_paths_cant_be_rendered_as_ $view = View::make('panel')->render(); } - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $app['config']->set('view.paths', [__DIR__.'/anonymous-components-templates']); } diff --git a/tests/Integration/View/BladeTest.php b/tests/Integration/View/BladeTest.php index 7a08d43fd0b3..6495175337c4 100644 --- a/tests/Integration/View/BladeTest.php +++ b/tests/Integration/View/BladeTest.php @@ -210,7 +210,7 @@ public function testViewCacheCommandHandlesConfiguredBladeExtensions() $this->artisan('view:clear'); } - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $app['config']->set('view.paths', [__DIR__.'/templates']); } diff --git a/tests/Integration/View/RenderableViewExceptionTest.php b/tests/Integration/View/RenderableViewExceptionTest.php index 93c91cb31387..f5ed176e26f4 100644 --- a/tests/Integration/View/RenderableViewExceptionTest.php +++ b/tests/Integration/View/RenderableViewExceptionTest.php @@ -21,7 +21,7 @@ public function testRenderMethodOfExceptionThrownInViewGetsHandled() $response->assertSee('This is a renderable exception.'); } - protected function getEnvironmentSetUp($app) + protected function defineEnvironment($app) { $app['config']->set('view.paths', [__DIR__.'/templates']); } From 2744aa7c8595bcb86f33e82e80667048a83e4756 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Mon, 3 Mar 2025 23:35:14 +0800 Subject: [PATCH 3/7] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Concurrency/ConcurrencyTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Integration/Concurrency/ConcurrencyTest.php b/tests/Integration/Concurrency/ConcurrencyTest.php index 092dba3d0a08..d6907f9433e5 100644 --- a/tests/Integration/Concurrency/ConcurrencyTest.php +++ b/tests/Integration/Concurrency/ConcurrencyTest.php @@ -17,8 +17,6 @@ class ConcurrencyTest extends TestCase { protected function setUp(): void { - parent::setUp(); - $this->defineCacheRoutes(<< Date: Mon, 3 Mar 2025 23:52:49 +0800 Subject: [PATCH 4/7] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7bf2d4615eee..282d9ff0aa8d 100644 --- a/composer.json +++ b/composer.json @@ -111,7 +111,7 @@ "league/flysystem-read-only": "^3.25.1", "league/flysystem-sftp-v3": "^3.25.1", "mockery/mockery": "^1.6.10", - "orchestra/testbench-core": "9.11.x-dev", + "orchestra/testbench-core": "^9.11.2", "pda/pheanstalk": "^5.0.6", "php-http/discovery": "^1.15", "phpstan/phpstan": "^2.0", From 0796783c9f0d2ddcf982a223a2abd68283eec7f6 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 4 Mar 2025 07:37:42 +0800 Subject: [PATCH 5/7] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Concurrency/ConcurrencyTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Integration/Concurrency/ConcurrencyTest.php b/tests/Integration/Concurrency/ConcurrencyTest.php index d6907f9433e5..a745a8d27bc7 100644 --- a/tests/Integration/Concurrency/ConcurrencyTest.php +++ b/tests/Integration/Concurrency/ConcurrencyTest.php @@ -7,12 +7,10 @@ use Illuminate\Foundation\Application; use Illuminate\Process\Factory as ProcessFactory; use Illuminate\Support\Facades\Concurrency; -use Orchestra\Testbench\Attributes\UsesVendor; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; #[RequiresOperatingSystem('Linux|DAR')] -#[UsesVendor] class ConcurrencyTest extends TestCase { protected function setUp(): void From 8c302a772b20fdffc60bc3e5b4b7675ecb74f454 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 4 Mar 2025 07:46:18 +0800 Subject: [PATCH 6/7] wip Signed-off-by: Mior Muhammad Zaki --- tests/Database/DatabaseEloquentCollectionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Database/DatabaseEloquentCollectionTest.php b/tests/Database/DatabaseEloquentCollectionTest.php index 2669921059f5..4448492791f4 100755 --- a/tests/Database/DatabaseEloquentCollectionTest.php +++ b/tests/Database/DatabaseEloquentCollectionTest.php @@ -701,7 +701,7 @@ public function testLoadExistsShouldCastBool() $user = EloquentTestUserModel::with('articles')->first(); $user->articles->loadExists('comments'); $commentsExists = $user->articles->pluck('comments_exists')->toArray(); - $this->assertContainsOnly('bool', $commentsExists); + $this->assertContainsOnlyBool($commentsExists); } public function testWithNonScalarKey() From 782d6a2a17636d890b98b167f3eae178b8ede329 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Tue, 4 Mar 2025 07:49:19 +0800 Subject: [PATCH 7/7] wip Signed-off-by: Mior Muhammad Zaki --- tests/Database/DatabaseEloquentCollectionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Database/DatabaseEloquentCollectionTest.php b/tests/Database/DatabaseEloquentCollectionTest.php index 4448492791f4..2669921059f5 100755 --- a/tests/Database/DatabaseEloquentCollectionTest.php +++ b/tests/Database/DatabaseEloquentCollectionTest.php @@ -701,7 +701,7 @@ public function testLoadExistsShouldCastBool() $user = EloquentTestUserModel::with('articles')->first(); $user->articles->loadExists('comments'); $commentsExists = $user->articles->pluck('comments_exists')->toArray(); - $this->assertContainsOnlyBool($commentsExists); + $this->assertContainsOnly('bool', $commentsExists); } public function testWithNonScalarKey()