From 826b98279888589fc3c6d0a6849b17a37687f19d Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 11:11:39 +0800 Subject: [PATCH 01/16] Test Improvements Remove warnings and deprecations from tests. Signed-off-by: Mior Muhammad Zaki --- tests/Database/DatabaseEloquentModelTest.php | 9 +++++++-- tests/Database/DatabaseMariaDbProcessorTest.php | 6 +++--- tests/Database/DatabaseMySqlProcessorTest.php | 6 +++--- tests/Database/DatabasePostgresProcessorTest.php | 8 ++++---- tests/Database/DatabasePostgresSchemaGrammarTest.php | 8 +++++++- tests/Database/DatabaseSQLiteProcessorTest.php | 6 +++--- tests/Database/DatabaseSchemaBlueprintTest.php | 8 ++++---- tests/Validation/ValidationRuleParserTest.php | 2 +- 8 files changed, 32 insertions(+), 21 deletions(-) diff --git a/tests/Database/DatabaseEloquentModelTest.php b/tests/Database/DatabaseEloquentModelTest.php index 7c5e22bd7c3e..079f68f16747 100755 --- a/tests/Database/DatabaseEloquentModelTest.php +++ b/tests/Database/DatabaseEloquentModelTest.php @@ -3609,6 +3609,11 @@ class EloquentModelWithPrimitiveCasts extends Model 'address' => Address::class, ]; + public $attributes = [ + 'address_line_one' => null, + 'address_line_two' => null, + ]; + public static function makePrimitiveCastsArray(): array { $toReturn = []; @@ -3660,8 +3665,8 @@ public function get(Model $model, string $key, mixed $value, array $attributes): public function set(Model $model, string $key, mixed $value, array $attributes): array { return [ - 'address_line_one' => $value->lineOne, - 'address_line_two' => $value->lineTwo, + 'address_line_one' => $value->lineOne ?? null, + 'address_line_two' => $value->lineTwo ?? null, ]; } }; diff --git a/tests/Database/DatabaseMariaDbProcessorTest.php b/tests/Database/DatabaseMariaDbProcessorTest.php index 97c0cc90f479..f5e44c6851a8 100644 --- a/tests/Database/DatabaseMariaDbProcessorTest.php +++ b/tests/Database/DatabaseMariaDbProcessorTest.php @@ -11,9 +11,9 @@ public function testProcessColumns() { $processor = new MariaDbProcessor; $listing = [ - ['name' => 'id', 'type_name' => 'bigint', 'type' => 'bigint', 'collation' => 'collate', 'nullable' => 'YES', 'default' => '', 'extra' => 'auto_increment', 'comment' => 'bar'], - ['name' => 'name', 'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'NO', 'default' => 'foo', 'extra' => '', 'comment' => ''], - ['name' => 'email', 'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'YES', 'default' => 'NULL', 'extra' => 'on update CURRENT_TIMESTAMP', 'comment' => 'NULL'], + ['name' => 'id', 'type_name' => 'bigint', 'type' => 'bigint', 'collation' => 'collate', 'nullable' => 'YES', 'default' => '', 'extra' => 'auto_increment', 'comment' => 'bar', 'expression' => null], + ['name' => 'name', 'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'NO', 'default' => 'foo', 'extra' => '', 'comment' => '', 'expression' => null], + ['name' => 'email', 'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'YES', 'default' => 'NULL', 'extra' => 'on update CURRENT_TIMESTAMP', 'comment' => 'NULL', 'expression' => null], ]; $expected = [ ['name' => 'id', 'type_name' => 'bigint', 'type' => 'bigint', 'collation' => 'collate', 'nullable' => true, 'default' => '', 'auto_increment' => true, 'comment' => 'bar', 'generation' => null], diff --git a/tests/Database/DatabaseMySqlProcessorTest.php b/tests/Database/DatabaseMySqlProcessorTest.php index 9919ff975b34..433379444c6e 100644 --- a/tests/Database/DatabaseMySqlProcessorTest.php +++ b/tests/Database/DatabaseMySqlProcessorTest.php @@ -11,9 +11,9 @@ public function testProcessColumns() { $processor = new MySqlProcessor; $listing = [ - ['name' => 'id', 'type_name' => 'bigint', 'type' => 'bigint', 'collation' => 'collate', 'nullable' => 'YES', 'default' => '', 'extra' => 'auto_increment', 'comment' => 'bar'], - ['name' => 'name', 'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'NO', 'default' => 'foo', 'extra' => '', 'comment' => ''], - ['name' => 'email', 'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'YES', 'default' => 'NULL', 'extra' => 'on update CURRENT_TIMESTAMP', 'comment' => 'NULL'], + ['name' => 'id', 'type_name' => 'bigint', 'type' => 'bigint', 'collation' => 'collate', 'nullable' => 'YES', 'default' => '', 'extra' => 'auto_increment', 'comment' => 'bar', 'expression' => null], + ['name' => 'name', 'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'NO', 'default' => 'foo', 'extra' => '', 'comment' => '', 'expression' => null], + ['name' => 'email', 'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'YES', 'default' => 'NULL', 'extra' => 'on update CURRENT_TIMESTAMP', 'comment' => 'NULL', 'expression' => null], ]; $expected = [ ['name' => 'id', 'type_name' => 'bigint', 'type' => 'bigint', 'collation' => 'collate', 'nullable' => true, 'default' => '', 'auto_increment' => true, 'comment' => 'bar', 'generation' => null], diff --git a/tests/Database/DatabasePostgresProcessorTest.php b/tests/Database/DatabasePostgresProcessorTest.php index 6fca3d3496ed..5b645a6d68b4 100644 --- a/tests/Database/DatabasePostgresProcessorTest.php +++ b/tests/Database/DatabasePostgresProcessorTest.php @@ -12,10 +12,10 @@ public function testProcessColumns() $processor = new PostgresProcessor; $listing = [ - ['name' => 'id', 'type_name' => 'int4', 'type' => 'integer', 'collation' => '', 'nullable' => true, 'default' => "nextval('employee_id_seq'::regclass)", 'comment' => ''], - ['name' => 'name', 'type_name' => 'varchar', 'type' => 'character varying(100)', 'collation' => 'collate', 'nullable' => false, 'default' => '', 'comment' => 'foo'], - ['name' => 'balance', 'type_name' => 'numeric', 'type' => 'numeric(8,2)', 'collation' => '', 'nullable' => true, 'default' => '4', 'comment' => 'NULL'], - ['name' => 'birth_date', 'type_name' => 'timestamp', 'type' => 'timestamp(6) without time zone', 'collation' => '', 'nullable' => false, 'default' => '', 'comment' => ''], + ['name' => 'id', 'type_name' => 'int4', 'type' => 'integer', 'collation' => '', 'nullable' => true, 'default' => "nextval('employee_id_seq'::regclass)", 'comment' => '', 'generated' => false], + ['name' => 'name', 'type_name' => 'varchar', 'type' => 'character varying(100)', 'collation' => 'collate', 'nullable' => false, 'default' => '', 'comment' => 'foo', 'generated' => false], + ['name' => 'balance', 'type_name' => 'numeric', 'type' => 'numeric(8,2)', 'collation' => '', 'nullable' => true, 'default' => '4', 'comment' => 'NULL', 'generated' => false], + ['name' => 'birth_date', 'type_name' => 'timestamp', 'type' => 'timestamp(6) without time zone', 'collation' => '', 'nullable' => false, 'default' => '', 'comment' => '', 'generated' => false], ]; $expected = [ ['name' => 'id', 'type_name' => 'int4', 'type' => 'integer', 'collation' => '', 'nullable' => true, 'default' => "nextval('employee_id_seq'::regclass)", 'auto_increment' => true, 'comment' => '', 'generation' => null], diff --git a/tests/Database/DatabasePostgresSchemaGrammarTest.php b/tests/Database/DatabasePostgresSchemaGrammarTest.php index c95601e92223..e74ed9ab91a8 100755 --- a/tests/Database/DatabasePostgresSchemaGrammarTest.php +++ b/tests/Database/DatabasePostgresSchemaGrammarTest.php @@ -1216,7 +1216,13 @@ public function testDropAllTypesEscapesTableNames() public function testCompileColumns() { - $statement = $this->getGrammar()->compileColumns('public', 'table'); + $connection = $this->getConnection(); + $grammar = $this->getGrammar(); + + $connection->shouldReceive('getServerVersion')->once()->andReturn('12.0.0'); + $grammar->setConnection($connection); + + $statement = $grammar->compileColumns('public', 'table'); $this->assertStringContainsString("where c.relname = 'table' and n.nspname = 'public'", $statement); } diff --git a/tests/Database/DatabaseSQLiteProcessorTest.php b/tests/Database/DatabaseSQLiteProcessorTest.php index 7511686d40bd..4775d556458f 100644 --- a/tests/Database/DatabaseSQLiteProcessorTest.php +++ b/tests/Database/DatabaseSQLiteProcessorTest.php @@ -12,9 +12,9 @@ public function testProcessColumns() $processor = new SQLiteProcessor; $listing = [ - ['name' => 'id', 'type' => 'INTEGER', 'nullable' => '0', 'default' => '', 'primary' => '1'], - ['name' => 'name', 'type' => 'varchar', 'nullable' => '1', 'default' => 'foo', 'primary' => '0'], - ['name' => 'is_active', 'type' => 'tinyint(1)', 'nullable' => '0', 'default' => '1', 'primary' => '0'], + ['name' => 'id', 'type' => 'INTEGER', 'nullable' => '0', 'default' => '', 'primary' => '1', 'extra' => 1], + ['name' => 'name', 'type' => 'varchar', 'nullable' => '1', 'default' => 'foo', 'primary' => '0', 'extra' => 1], + ['name' => 'is_active', 'type' => 'tinyint(1)', 'nullable' => '0', 'default' => '1', 'primary' => '0', 'extra' => 1], ]; $expected = [ ['name' => 'id', 'type_name' => 'integer', 'type' => 'integer', 'collation' => null, 'nullable' => false, 'default' => '', 'auto_increment' => true, 'comment' => null, 'generation' => null], diff --git a/tests/Database/DatabaseSchemaBlueprintTest.php b/tests/Database/DatabaseSchemaBlueprintTest.php index b7cc72970ac2..eb80ee6b2a56 100755 --- a/tests/Database/DatabaseSchemaBlueprintTest.php +++ b/tests/Database/DatabaseSchemaBlueprintTest.php @@ -197,8 +197,8 @@ public function testNativeRenameColumnOnMysql57() $connection->shouldReceive('isMaria')->andReturn(false); $connection->shouldReceive('getServerVersion')->andReturn('5.7'); $connection->shouldReceive('getSchemaBuilder->getColumns')->andReturn([ - ['name' => 'name', 'type' => 'varchar(255)', 'type_name' => 'varchar', 'nullable' => true, 'collation' => 'utf8mb4_unicode_ci', 'default' => 'foo', 'comment' => null, 'auto_increment' => false], - ['name' => 'id', 'type' => 'bigint unsigned', 'type_name' => 'bigint', 'nullable' => false, 'collation' => null, 'default' => null, 'comment' => 'lorem ipsum', 'auto_increment' => true], + ['name' => 'name', 'type' => 'varchar(255)', 'type_name' => 'varchar', 'nullable' => true, 'collation' => 'utf8mb4_unicode_ci', 'default' => 'foo', 'comment' => null, 'auto_increment' => false, 'generation' => null], + ['name' => 'id', 'type' => 'bigint unsigned', 'type_name' => 'bigint', 'nullable' => false, 'collation' => null, 'default' => null, 'comment' => 'lorem ipsum', 'auto_increment' => true, 'generation' => null], ['name' => 'generated', 'type' => 'int', 'type_name' => 'int', 'nullable' => false, 'collation' => null, 'default' => null, 'comment' => null, 'auto_increment' => false, 'generation' => ['type' => 'stored', 'expression' => 'expression']], ]); @@ -222,8 +222,8 @@ public function testNativeRenameColumnOnLegacyMariaDB() $connection->shouldReceive('isMaria')->andReturn(true); $connection->shouldReceive('getServerVersion')->andReturn('10.1.35'); $connection->shouldReceive('getSchemaBuilder->getColumns')->andReturn([ - ['name' => 'name', 'type' => 'varchar(255)', 'type_name' => 'varchar', 'nullable' => true, 'collation' => 'utf8mb4_unicode_ci', 'default' => 'foo', 'comment' => null, 'auto_increment' => false], - ['name' => 'id', 'type' => 'bigint unsigned', 'type_name' => 'bigint', 'nullable' => false, 'collation' => null, 'default' => null, 'comment' => 'lorem ipsum', 'auto_increment' => true], + ['name' => 'name', 'type' => 'varchar(255)', 'type_name' => 'varchar', 'nullable' => true, 'collation' => 'utf8mb4_unicode_ci', 'default' => 'foo', 'comment' => null, 'auto_increment' => false, 'generation' => null], + ['name' => 'id', 'type' => 'bigint unsigned', 'type_name' => 'bigint', 'nullable' => false, 'collation' => null, 'default' => null, 'comment' => 'lorem ipsum', 'auto_increment' => true, 'generation' => null], ['name' => 'generated', 'type' => 'int', 'type_name' => 'int', 'nullable' => false, 'collation' => null, 'default' => null, 'comment' => null, 'auto_increment' => false, 'generation' => ['type' => 'stored', 'expression' => 'expression']], ['name' => 'foo', 'type' => 'int', 'type_name' => 'int', 'nullable' => true, 'collation' => null, 'default' => 'NULL', 'comment' => null, 'auto_increment' => false, 'generation' => null], ]); diff --git a/tests/Validation/ValidationRuleParserTest.php b/tests/Validation/ValidationRuleParserTest.php index c054acc6ecbf..ea04f00705f8 100644 --- a/tests/Validation/ValidationRuleParserTest.php +++ b/tests/Validation/ValidationRuleParserTest.php @@ -206,7 +206,7 @@ public function testExplodeGeneratesNestedRulesForNonNestedData() ])); $results = $parser->explode([ - 'name' => Rule::forEach(function ($value, $attribute, $data = null, $context) { + 'name' => Rule::forEach(function ($value, $attribute, $data, $context) { $this->assertSame('Taylor Otwell', $value); $this->assertSame('name', $attribute); $this->assertEquals(['name' => 'Taylor Otwell', 'email' => 'taylor@laravel.com'], $data); From b031b60e4f07467d3750ab89089546754298ded1 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 11:23:55 +0800 Subject: [PATCH 02/16] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Queue/RateLimitedWithRedisTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Integration/Queue/RateLimitedWithRedisTest.php b/tests/Integration/Queue/RateLimitedWithRedisTest.php index ebd497ce6368..afae79326868 100644 --- a/tests/Integration/Queue/RateLimitedWithRedisTest.php +++ b/tests/Integration/Queue/RateLimitedWithRedisTest.php @@ -15,6 +15,7 @@ use Illuminate\Support\Str; use Mockery as m; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\WithoutErrorHandler; class RateLimitedWithRedisTest extends TestCase { @@ -34,6 +35,7 @@ protected function tearDown(): void parent::tearDown(); } + #[WithoutErrorHandler] public function testUnlimitedJobsAreExecuted() { $rateLimiter = $this->app->make(RateLimiter::class); From 82970b014154a07ad8654d46f603ef993e78e84e Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 11:31:10 +0800 Subject: [PATCH 03/16] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Queue/RateLimitedWithRedisTest.php | 4 ++-- tests/Integration/Queue/RedisQueueTest.php | 1 + tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/Integration/Queue/RateLimitedWithRedisTest.php b/tests/Integration/Queue/RateLimitedWithRedisTest.php index afae79326868..1306c7d232c4 100644 --- a/tests/Integration/Queue/RateLimitedWithRedisTest.php +++ b/tests/Integration/Queue/RateLimitedWithRedisTest.php @@ -15,8 +15,9 @@ use Illuminate\Support\Str; use Mockery as m; use Orchestra\Testbench\TestCase; -use PHPUnit\Framework\Attributes\WithoutErrorHandler; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; +#[RequiresPhpExtension('redis')] class RateLimitedWithRedisTest extends TestCase { use InteractsWithRedis; @@ -35,7 +36,6 @@ protected function tearDown(): void parent::tearDown(); } - #[WithoutErrorHandler] public function testUnlimitedJobsAreExecuted() { $rateLimiter = $this->app->make(RateLimiter::class); diff --git a/tests/Integration/Queue/RedisQueueTest.php b/tests/Integration/Queue/RedisQueueTest.php index 59818790f1f9..f7120110568d 100644 --- a/tests/Integration/Queue/RedisQueueTest.php +++ b/tests/Integration/Queue/RedisQueueTest.php @@ -16,6 +16,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresPhpExtension; +#[RequiresPhpExtension('redis')] class RedisQueueTest extends TestCase { use InteractsWithRedis, InteractsWithTime; diff --git a/tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php b/tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php index 4a11502ae293..59cc8f77b412 100644 --- a/tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php +++ b/tests/Integration/Queue/ThrottlesExceptionsWithRedisTest.php @@ -15,8 +15,10 @@ use Illuminate\Support\Str; use Mockery as m; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; use RuntimeException; +#[RequiresPhpExtension('redis')] class ThrottlesExceptionsWithRedisTest extends TestCase { use InteractsWithRedis; From e26f4c55c27926a47b502cbda32132682741b6bc Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 12:09:01 +0800 Subject: [PATCH 04/16] Update queues.yml --- .github/workflows/queues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/queues.yml b/.github/workflows/queues.yml index 7d3687525f7d..e7f5edb19fe3 100644 --- a/.github/workflows/queues.yml +++ b/.github/workflows/queues.yml @@ -24,7 +24,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :redis, :php-psr tools: composer:v2 coverage: none From 5f97b5e37a459fd2dbb9a5d97fc8660efc7c97e9 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 12:11:05 +0800 Subject: [PATCH 05/16] Update queues.yml --- .github/workflows/queues.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/queues.yml b/.github/workflows/queues.yml index e7f5edb19fe3..9b13deac643d 100644 --- a/.github/workflows/queues.yml +++ b/.github/workflows/queues.yml @@ -59,7 +59,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :redis, :php-psr tools: composer:v2 coverage: none @@ -141,7 +141,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :redis, :php-psr tools: composer:v2 coverage: none From 8daacb1b440a148bce42e6d7e544cafa55a87cc0 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:08:19 +0800 Subject: [PATCH 06/16] wip Signed-off-by: Mior Muhammad Zaki --- .github/workflows/queues.yml | 6 +++--- .../Integration/Queue/RateLimitedWithRedisTest.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/queues.yml b/.github/workflows/queues.yml index 9b13deac643d..7d3687525f7d 100644 --- a/.github/workflows/queues.yml +++ b/.github/workflows/queues.yml @@ -24,7 +24,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :redis, :php-psr + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr tools: composer:v2 coverage: none @@ -59,7 +59,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :redis, :php-psr + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr tools: composer:v2 coverage: none @@ -141,7 +141,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: 8.2 - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :redis, :php-psr + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr tools: composer:v2 coverage: none diff --git a/tests/Integration/Queue/RateLimitedWithRedisTest.php b/tests/Integration/Queue/RateLimitedWithRedisTest.php index 1306c7d232c4..a844af8b1bde 100644 --- a/tests/Integration/Queue/RateLimitedWithRedisTest.php +++ b/tests/Integration/Queue/RateLimitedWithRedisTest.php @@ -14,6 +14,7 @@ use Illuminate\Queue\Middleware\RateLimitedWithRedis; use Illuminate\Support\Str; use Mockery as m; +use Orchestra\Testbench\Foundation\Application as Testbench; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresPhpExtension; @@ -36,6 +37,19 @@ protected function tearDown(): void parent::tearDown(); } + /** + * This method is called when a test method did not execute successfully. + * + * @throws Throwable + */ + protected function onNotSuccessfulTest(Throwable $t): never + { + Testbench::flushState($this); + + throw $t; + } + + public function testUnlimitedJobsAreExecuted() { $rateLimiter = $this->app->make(RateLimiter::class); From fba1f628b54ce30dd11292de7ecd0183cd219bdf Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 10 May 2024 08:08:46 +0000 Subject: [PATCH 07/16] Apply fixes from StyleCI --- tests/Integration/Queue/RateLimitedWithRedisTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Integration/Queue/RateLimitedWithRedisTest.php b/tests/Integration/Queue/RateLimitedWithRedisTest.php index a844af8b1bde..c5d30e8f2f52 100644 --- a/tests/Integration/Queue/RateLimitedWithRedisTest.php +++ b/tests/Integration/Queue/RateLimitedWithRedisTest.php @@ -49,7 +49,6 @@ protected function onNotSuccessfulTest(Throwable $t): never throw $t; } - public function testUnlimitedJobsAreExecuted() { $rateLimiter = $this->app->make(RateLimiter::class); From ddb2d2b7b5a26003338d006f000141f320e84203 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:09:51 +0800 Subject: [PATCH 08/16] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Queue/RateLimitedWithRedisTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Integration/Queue/RateLimitedWithRedisTest.php b/tests/Integration/Queue/RateLimitedWithRedisTest.php index c5d30e8f2f52..f7aa49341418 100644 --- a/tests/Integration/Queue/RateLimitedWithRedisTest.php +++ b/tests/Integration/Queue/RateLimitedWithRedisTest.php @@ -42,7 +42,7 @@ protected function tearDown(): void * * @throws Throwable */ - protected function onNotSuccessfulTest(Throwable $t): never + protected function onNotSuccessfulTest(\Throwable $t): never { Testbench::flushState($this); From 198503d3382afb108be3c58c0a48c1942095b54a Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:19:49 +0800 Subject: [PATCH 09/16] wip Signed-off-by: Mior Muhammad Zaki --- .../Foundation/Testing/Concerns/InteractsWithRedis.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index f6263d29cd93..bebf4fea1364 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -83,6 +83,7 @@ public function tearDownRedis() foreach (static::redisDriverProvider() as $driver) { if (isset($this->redis[$driver[0]])) { $this->redis[$driver[0]]->connection()->disconnect(); + unset($this->redis[$driver[0]]); } } } From 40eddb7aeedce09acdecdca1c165d69162642cea Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:23:33 +0800 Subject: [PATCH 10/16] wip Signed-off-by: Mior Muhammad Zaki --- .../Foundation/Testing/Concerns/InteractsWithRedis.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index bebf4fea1364..e363c93e5888 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -60,7 +60,8 @@ public function setUpRedis() try { $this->redis['phpredis']->connection()->flushdb(); - } catch (Exception) { + } catch (Exception $e) { + var_dump($e); if ($host === '127.0.0.1' && $port === 6379 && Env::get('REDIS_HOST') === null) { static::$connectionFailedOnceWithDefaultsSkip = true; From 555e976e7d3dd0b8ad672c4cfbfa0bef64ebec5e Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:45:32 +0800 Subject: [PATCH 11/16] wip Signed-off-by: Mior Muhammad Zaki --- .../Testing/Concerns/InteractsWithRedis.php | 4 ++-- .../Integration/Queue/RateLimitedWithRedisTest.php | 13 ------------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index e363c93e5888..a32b9d1491e2 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -34,7 +34,7 @@ public function setUpRedis() $this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__); } - if (static::$connectionFailedOnceWithDefaultsSkip) { + if (static::$connectionFailedOnceWithDefaultsSkip === true) { $this->markTestSkipped('Trying default host/port failed, please set environment variable REDIS_HOST & REDIS_PORT to enable '.__CLASS__); } @@ -61,7 +61,7 @@ public function setUpRedis() try { $this->redis['phpredis']->connection()->flushdb(); } catch (Exception $e) { - var_dump($e); + var_dump($e, $host, $port); if ($host === '127.0.0.1' && $port === 6379 && Env::get('REDIS_HOST') === null) { static::$connectionFailedOnceWithDefaultsSkip = true; diff --git a/tests/Integration/Queue/RateLimitedWithRedisTest.php b/tests/Integration/Queue/RateLimitedWithRedisTest.php index f7aa49341418..cb8588f7f4b9 100644 --- a/tests/Integration/Queue/RateLimitedWithRedisTest.php +++ b/tests/Integration/Queue/RateLimitedWithRedisTest.php @@ -18,7 +18,6 @@ use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresPhpExtension; -#[RequiresPhpExtension('redis')] class RateLimitedWithRedisTest extends TestCase { use InteractsWithRedis; @@ -37,18 +36,6 @@ protected function tearDown(): void parent::tearDown(); } - /** - * This method is called when a test method did not execute successfully. - * - * @throws Throwable - */ - protected function onNotSuccessfulTest(\Throwable $t): never - { - Testbench::flushState($this); - - throw $t; - } - public function testUnlimitedJobsAreExecuted() { $rateLimiter = $this->app->make(RateLimiter::class); From 3b7e8cf050d58e395cbbc4a9c67f51963dacf9f5 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 10 May 2024 08:45:46 +0000 Subject: [PATCH 12/16] Apply fixes from StyleCI --- tests/Integration/Queue/RateLimitedWithRedisTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Integration/Queue/RateLimitedWithRedisTest.php b/tests/Integration/Queue/RateLimitedWithRedisTest.php index cb8588f7f4b9..ebd497ce6368 100644 --- a/tests/Integration/Queue/RateLimitedWithRedisTest.php +++ b/tests/Integration/Queue/RateLimitedWithRedisTest.php @@ -14,9 +14,7 @@ use Illuminate\Queue\Middleware\RateLimitedWithRedis; use Illuminate\Support\Str; use Mockery as m; -use Orchestra\Testbench\Foundation\Application as Testbench; use Orchestra\Testbench\TestCase; -use PHPUnit\Framework\Attributes\RequiresPhpExtension; class RateLimitedWithRedisTest extends TestCase { From 6a2b517abaf4974715aa6e79ead145bebfc76785 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:48:16 +0800 Subject: [PATCH 13/16] wip Signed-off-by: Mior Muhammad Zaki --- .../Foundation/Testing/Concerns/InteractsWithRedis.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index a32b9d1491e2..a8b3ebb3b81a 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -60,8 +60,7 @@ public function setUpRedis() try { $this->redis['phpredis']->connection()->flushdb(); - } catch (Exception $e) { - var_dump($e, $host, $port); + } catch (Exception) { if ($host === '127.0.0.1' && $port === 6379 && Env::get('REDIS_HOST') === null) { static::$connectionFailedOnceWithDefaultsSkip = true; From 3c3dff3e2cac6126ea7fd0da19ca6a72bedf6dbc Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:48:25 +0800 Subject: [PATCH 14/16] wip Signed-off-by: Mior Muhammad Zaki --- .../Foundation/Testing/Concerns/InteractsWithRedis.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index a8b3ebb3b81a..06e32e986d23 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -83,7 +83,6 @@ public function tearDownRedis() foreach (static::redisDriverProvider() as $driver) { if (isset($this->redis[$driver[0]])) { $this->redis[$driver[0]]->connection()->disconnect(); - unset($this->redis[$driver[0]]); } } } From 4f13d0af6cd6d6349dc511df02c2c61fdcad9f12 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:51:27 +0800 Subject: [PATCH 15/16] wip Signed-off-by: Mior Muhammad Zaki --- tests/Integration/Queue/RateLimitedWithRedisTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Integration/Queue/RateLimitedWithRedisTest.php b/tests/Integration/Queue/RateLimitedWithRedisTest.php index ebd497ce6368..1306c7d232c4 100644 --- a/tests/Integration/Queue/RateLimitedWithRedisTest.php +++ b/tests/Integration/Queue/RateLimitedWithRedisTest.php @@ -15,7 +15,9 @@ use Illuminate\Support\Str; use Mockery as m; use Orchestra\Testbench\TestCase; +use PHPUnit\Framework\Attributes\RequiresPhpExtension; +#[RequiresPhpExtension('redis')] class RateLimitedWithRedisTest extends TestCase { use InteractsWithRedis; From 091e8d8fe3f8a7c1e2633b8ce383c5a58ad238a3 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Fri, 10 May 2024 16:52:03 +0800 Subject: [PATCH 16/16] wip Signed-off-by: Mior Muhammad Zaki --- .../Foundation/Testing/Concerns/InteractsWithRedis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index 06e32e986d23..f6263d29cd93 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -34,7 +34,7 @@ public function setUpRedis() $this->markTestSkipped('The redis extension is not installed. Please install the extension to enable '.__CLASS__); } - if (static::$connectionFailedOnceWithDefaultsSkip === true) { + if (static::$connectionFailedOnceWithDefaultsSkip) { $this->markTestSkipped('Trying default host/port failed, please set environment variable REDIS_HOST & REDIS_PORT to enable '.__CLASS__); }