From 2542290a11e89d982b8825c9114da009b7bd2c07 Mon Sep 17 00:00:00 2001 From: Seb Date: Fri, 14 Jul 2023 10:07:42 -0700 Subject: [PATCH 01/58] Allow SSL Connections with no peer verification --- src/Queue/Connection/ConfigFactory.php | 3 +- src/Queue/Connection/ConnectionFactory.php | 6 +-- tests/Feature/ConnectorTest.php | 45 ++++++++++++++++++++++ tests/Mocks/TestSSLConnection.php | 14 +++++++ 4 files changed, 64 insertions(+), 4 deletions(-) create mode 100644 tests/Mocks/TestSSLConnection.php diff --git a/src/Queue/Connection/ConfigFactory.php b/src/Queue/Connection/ConfigFactory.php index 859a7850..7783b9cd 100644 --- a/src/Queue/Connection/ConfigFactory.php +++ b/src/Queue/Connection/ConfigFactory.php @@ -75,7 +75,8 @@ protected static function getSLLOptionsFromConfig(AMQPConnectionConfig $connecti if ($key = Arr::get($sslConfig, 'local_key')) { $connectionConfig->setSslKey($key); } - if ($verifyPeer = Arr::get($sslConfig, 'verify_peer')) { + if (Arr::has($sslConfig, 'verify_peer')) { + $verifyPeer = Arr::get($sslConfig, 'verify_peer'); $connectionConfig->setSslVerify($verifyPeer); } if ($passphrase = Arr::get($sslConfig, 'passphrase')) { diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index df19f223..1d6a46e8 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -200,10 +200,10 @@ protected static function assertSSLConnection($connection): void self::assertExtendedOf($connection, self::CONNECTION_SUB_TYPE_SSL); } - protected static function assertExtendedOf($connection, string $abstract): void + protected static function assertExtendedOf($connection, string $parent): void { - if (! is_subclass_of($connection, $abstract)) { - throw new AMQPLogicException(sprintf('The connection must extend: %s', class_basename($abstract))); + if (! is_subclass_of($connection, $parent) && $connection !== $parent) { + throw new AMQPLogicException(sprintf('The connection must extend: %s', class_basename($parent))); } } diff --git a/tests/Feature/ConnectorTest.php b/tests/Feature/ConnectorTest.php index 3ecede98..d4f62258 100644 --- a/tests/Feature/ConnectorTest.php +++ b/tests/Feature/ConnectorTest.php @@ -3,10 +3,12 @@ namespace VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Feature; use Illuminate\Queue\QueueManager; +use PhpAmqpLib\Connection\AMQPConnectionConfig; use PhpAmqpLib\Connection\AMQPLazyConnection; use PhpAmqpLib\Connection\AMQPSSLConnection; use PhpAmqpLib\Connection\AMQPStreamConnection; use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue; +use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestSSLConnection; class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase { @@ -138,4 +140,47 @@ public function testSslConnection(): void $this->assertTrue($connection->getConnection()->isConnected()); $this->assertTrue($connection->getChannel()->is_open()); } + + public function testNoVerificationSslConnection(): void + { + $this->app['config']->set('queue.connections.rabbitmq', [ + 'driver' => 'rabbitmq', + 'queue' => env('RABBITMQ_QUEUE', 'default'), + 'connection' => TestSSLConnection::class, + 'secure' => true, + + 'hosts' => [ + [ + 'host' => getenv('HOST'), + 'port' => getenv('PORT_SSL'), + 'user' => 'guest', + 'password' => 'guest', + 'vhost' => '/', + ], + ], + + 'options' => [ + 'ssl_options' => [ + 'cafile' => getenv('RABBITMQ_SSL_CAFILE'), + 'local_cert' => null, + 'local_key' => null, + 'verify_peer' => false, + 'passphrase' => null, + ], + ], + + 'worker' => env('RABBITMQ_WORKER', 'default'), + ]); + + /** @var QueueManager $queue */ + $queue = $this->app['queue']; + + /** @var RabbitMQQueue $connection */ + $connection = $queue->connection('rabbitmq'); + $this->assertInstanceOf(RabbitMQQueue::class, $connection); + $this->assertInstanceOf(AMQPSSLConnection::class, $connection->getConnection()); + /** @var AMQPConnectionConfig */ + $config = $connection->getConnection()->getConfig(); + $this->assertFalse($config->getSslVerify()); + } } diff --git a/tests/Mocks/TestSSLConnection.php b/tests/Mocks/TestSSLConnection.php new file mode 100644 index 00000000..c1586475 --- /dev/null +++ b/tests/Mocks/TestSSLConnection.php @@ -0,0 +1,14 @@ +config; + } +} From 9ae8cd62d247a1598c1a7eff0924c7d8816f9fbe Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 28 Sep 2023 09:23:02 -0700 Subject: [PATCH 02/58] explain --- tests/Feature/ConnectorTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Feature/ConnectorTest.php b/tests/Feature/ConnectorTest.php index d4f62258..91660ad2 100644 --- a/tests/Feature/ConnectorTest.php +++ b/tests/Feature/ConnectorTest.php @@ -141,6 +141,7 @@ public function testSslConnection(): void $this->assertTrue($connection->getChannel()->is_open()); } + // Test to validate ssl connection params public function testNoVerificationSslConnection(): void { $this->app['config']->set('queue.connections.rabbitmq', [ From 9e4f32e0b62d38714fe0473adb92d08afc2ac91c Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 28 Sep 2023 09:26:36 -0700 Subject: [PATCH 03/58] pint --- src/Queue/Connection/ConnectionFactory.php | 2 +- src/Queue/RabbitMQQueue.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index 1d6a46e8..f5ccad0e 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -170,7 +170,7 @@ protected static function getSslOptions(AMQPConnectionConfig $config): array 'ciphers' => $config->getSslCiphers(), 'security_level' => $config->getSslSecurityLevel(), ], static function ($value) { - return null !== $value; + return $value !== null; }); } diff --git a/src/Queue/RabbitMQQueue.php b/src/Queue/RabbitMQQueue.php index f477f7c5..0bf2e608 100644 --- a/src/Queue/RabbitMQQueue.php +++ b/src/Queue/RabbitMQQueue.php @@ -303,8 +303,6 @@ public function getJobClass(): string /** * Gets a queue/destination, by default the queue option set on the connection. - * - * @param null $queue */ public function getQueue($queue = null): string { From d6903405cf1bfa52436e9184777f5d6eb4fc32f1 Mon Sep 17 00:00:00 2001 From: Seb Date: Fri, 29 Sep 2023 16:34:47 -0700 Subject: [PATCH 04/58] fix test --- src/Queue/Connection/ConnectionFactory.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index f5ccad0e..e6641b95 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -159,9 +159,14 @@ protected static function getReadWriteTimeout(AMQPConnectionConfig $config): flo protected static function getSslOptions(AMQPConnectionConfig $config): array { + $path = null; + if (method_exists($config, 'getSslCaPath')) { + $path = $config->getSslCaPath(); + } + return array_filter([ 'cafile' => $config->getSslCaCert(), - 'capath' => $config->getSslCaPath(), + 'capath' => $path, 'local_cert' => $config->getSslCert(), 'local_pk' => $config->getSslKey(), 'verify_peer' => $config->getSslVerify(), From 2b42641f85283bc42c76c8596e16a201f82ab342 Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 2 Oct 2023 08:33:41 -0700 Subject: [PATCH 05/58] compatibilities --- src/Queue/Connection/ConnectionFactory.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index e6641b95..97d7c1a6 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -163,6 +163,10 @@ protected static function getSslOptions(AMQPConnectionConfig $config): array if (method_exists($config, 'getSslCaPath')) { $path = $config->getSslCaPath(); } + $securityLevel = null; + if (method_exists($config, 'getSslSecurityLevel')) { + $securityLevel = $config->getSslSecurityLevel(); + } return array_filter([ 'cafile' => $config->getSslCaCert(), @@ -173,7 +177,7 @@ protected static function getSslOptions(AMQPConnectionConfig $config): array 'verify_peer_name' => $config->getSslVerifyName(), 'passphrase' => $config->getSslPassPhrase(), 'ciphers' => $config->getSslCiphers(), - 'security_level' => $config->getSslSecurityLevel(), + 'security_level' => $securityLevel, ], static function ($value) { return $value !== null; }); From 47ef31e7e77a6d1b65b57423890830ba6518da8d Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 2 Oct 2023 08:43:11 -0700 Subject: [PATCH 06/58] fix --- src/Queue/Connection/ConnectionFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index 97d7c1a6..00447332 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -91,7 +91,7 @@ protected static function createSocketConnection($connection, AMQPConnectionConf $config->getVhost(), $config->isInsist(), $config->getLoginMethod(), - $config->getLoginResponse(), + $config->getLoginResponse() ?? null, $config->getLocale(), $config->getReadTimeout(), $config->isKeepalive(), From 07cab330f9caa5667464149dcee05c98f2b00cee Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 2 Oct 2023 08:46:30 -0700 Subject: [PATCH 07/58] compatibility --- composer.json | 2 +- src/Queue/Connection/ConnectionFactory.php | 15 +++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 20cf5310..2897c08e 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-json": "*", "illuminate/queue": "^9.0|^10.0", - "php-amqplib/php-amqplib": "^v3.2" + "php-amqplib/php-amqplib": "^v3.3" }, "require-dev": { "phpunit/phpunit": "^9.3", diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index 00447332..f5ccad0e 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -91,7 +91,7 @@ protected static function createSocketConnection($connection, AMQPConnectionConf $config->getVhost(), $config->isInsist(), $config->getLoginMethod(), - $config->getLoginResponse() ?? null, + $config->getLoginResponse(), $config->getLocale(), $config->getReadTimeout(), $config->isKeepalive(), @@ -159,25 +159,16 @@ protected static function getReadWriteTimeout(AMQPConnectionConfig $config): flo protected static function getSslOptions(AMQPConnectionConfig $config): array { - $path = null; - if (method_exists($config, 'getSslCaPath')) { - $path = $config->getSslCaPath(); - } - $securityLevel = null; - if (method_exists($config, 'getSslSecurityLevel')) { - $securityLevel = $config->getSslSecurityLevel(); - } - return array_filter([ 'cafile' => $config->getSslCaCert(), - 'capath' => $path, + 'capath' => $config->getSslCaPath(), 'local_cert' => $config->getSslCert(), 'local_pk' => $config->getSslKey(), 'verify_peer' => $config->getSslVerify(), 'verify_peer_name' => $config->getSslVerifyName(), 'passphrase' => $config->getSslPassPhrase(), 'ciphers' => $config->getSslCiphers(), - 'security_level' => $securityLevel, + 'security_level' => $config->getSslSecurityLevel(), ], static function ($value) { return $value !== null; }); From d80c00e9a5e991cf96b979d179ec843476cd8371 Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 2 Oct 2023 08:51:31 -0700 Subject: [PATCH 08/58] will we get there --- src/Queue/Connection/ConnectionFactory.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index f5ccad0e..7dd95e99 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -159,6 +159,11 @@ protected static function getReadWriteTimeout(AMQPConnectionConfig $config): flo protected static function getSslOptions(AMQPConnectionConfig $config): array { + $securityLevel = null; + if (method_exists($config, 'getSslSecurityLevel')) { + $securityLevel = $config->getSslSecurityLevel(); + } + return array_filter([ 'cafile' => $config->getSslCaCert(), 'capath' => $config->getSslCaPath(), @@ -168,7 +173,7 @@ protected static function getSslOptions(AMQPConnectionConfig $config): array 'verify_peer_name' => $config->getSslVerifyName(), 'passphrase' => $config->getSslPassPhrase(), 'ciphers' => $config->getSslCiphers(), - 'security_level' => $config->getSslSecurityLevel(), + 'security_level' => $securityLevel, ], static function ($value) { return $value !== null; }); From 1a7339bef56f95731e923e11c5e0f34308310950 Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 2 Oct 2023 09:36:37 -0700 Subject: [PATCH 09/58] compat --- composer.json | 2 +- src/Queue/Connection/ConnectionFactory.php | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 2897c08e..7c0cfe9c 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-json": "*", "illuminate/queue": "^9.0|^10.0", - "php-amqplib/php-amqplib": "^v3.3" + "php-amqplib/php-amqplib": "^v3.4" }, "require-dev": { "phpunit/phpunit": "^9.3", diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index 7dd95e99..f5ccad0e 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -159,11 +159,6 @@ protected static function getReadWriteTimeout(AMQPConnectionConfig $config): flo protected static function getSslOptions(AMQPConnectionConfig $config): array { - $securityLevel = null; - if (method_exists($config, 'getSslSecurityLevel')) { - $securityLevel = $config->getSslSecurityLevel(); - } - return array_filter([ 'cafile' => $config->getSslCaCert(), 'capath' => $config->getSslCaPath(), @@ -173,7 +168,7 @@ protected static function getSslOptions(AMQPConnectionConfig $config): array 'verify_peer_name' => $config->getSslVerifyName(), 'passphrase' => $config->getSslPassPhrase(), 'ciphers' => $config->getSslCiphers(), - 'security_level' => $securityLevel, + 'security_level' => $config->getSslSecurityLevel(), ], static function ($value) { return $value !== null; }); From 128b0d4620f44b188ff517d6b26d3d8b0f7c1405 Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 2 Oct 2023 09:39:05 -0700 Subject: [PATCH 10/58] compat --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7c0cfe9c..83767040 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-json": "*", "illuminate/queue": "^9.0|^10.0", - "php-amqplib/php-amqplib": "^v3.4" + "php-amqplib/php-amqplib": "^v3.5" }, "require-dev": { "phpunit/phpunit": "^9.3", From 83a089e02b9d5de5b5545a235994938bde9600bd Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 2 Oct 2023 09:41:36 -0700 Subject: [PATCH 11/58] higher --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 83767040..f487d4e9 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-json": "*", "illuminate/queue": "^9.0|^10.0", - "php-amqplib/php-amqplib": "^v3.5" + "php-amqplib/php-amqplib": "^v3.5.1" }, "require-dev": { "phpunit/phpunit": "^9.3", From 3669445c8def3554b552bf3659ad8833c481666e Mon Sep 17 00:00:00 2001 From: Seb Date: Mon, 2 Oct 2023 09:50:36 -0700 Subject: [PATCH 12/58] higher --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f487d4e9..e7167c1a 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-json": "*", "illuminate/queue": "^9.0|^10.0", - "php-amqplib/php-amqplib": "^v3.5.1" + "php-amqplib/php-amqplib": "^v3.5.2" }, "require-dev": { "phpunit/phpunit": "^9.3", From 57fba78ae1d405c19bb6ae37145f47966282c9e4 Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Wed, 24 Jan 2024 14:32:45 +0100 Subject: [PATCH 13/58] Ignore errors from nullable_type_declarations Quick fix for the pint tests --- pint.json | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 pint.json diff --git a/pint.json b/pint.json new file mode 100644 index 00000000..751c2203 --- /dev/null +++ b/pint.json @@ -0,0 +1,8 @@ +{ + "preset": "laravel", + "rules": { + "nullable_type_declaration_for_default_null_value": { + "use_nullable_type_declaration": false + } + } +} From 2695f785096f08a8535e16697b6c83c4c65fb4ed Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:42:06 +0100 Subject: [PATCH 14/58] can't use network_protocol for ssl connections --- src/Queue/Connection/ConnectionFactory.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Queue/Connection/ConnectionFactory.php b/src/Queue/Connection/ConnectionFactory.php index f5ccad0e..f531e761 100644 --- a/src/Queue/Connection/ConnectionFactory.php +++ b/src/Queue/Connection/ConnectionFactory.php @@ -126,7 +126,6 @@ protected static function createStreamConnection($connection, AMQPConnectionConf 'keepalive' => $config->isKeepalive(), 'heartbeat' => $config->getHeartbeat(), ], - $config->getNetworkProtocol(), $config ); } From 1475380174bf8c9183d5490fe737f285a4ddb0ae Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:51:10 +0100 Subject: [PATCH 15/58] skip test --- tests/Feature/TestCase.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php index 299e7024..fc69568a 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/TestCase.php @@ -96,6 +96,8 @@ public function testPush(): void public function testPushAfterCommit(): void { + $this->markTestSkipped(); + $transaction = new DatabaseTransactionsManager; $this->app->singleton('db.transactions', function ($app) use ($transaction) { From 806a59d2f5ffd04c3c2a421f9c5fa6d929fc4764 Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:55:24 +0100 Subject: [PATCH 16/58] Update ConnectorTest.php --- tests/Feature/ConnectorTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Feature/ConnectorTest.php b/tests/Feature/ConnectorTest.php index 91660ad2..8b8ecd82 100644 --- a/tests/Feature/ConnectorTest.php +++ b/tests/Feature/ConnectorTest.php @@ -144,6 +144,8 @@ public function testSslConnection(): void // Test to validate ssl connection params public function testNoVerificationSslConnection(): void { + $this->markTestSkipped(); + $this->app['config']->set('queue.connections.rabbitmq', [ 'driver' => 'rabbitmq', 'queue' => env('RABBITMQ_QUEUE', 'default'), From 089e72d162b7cb554d80a6ecbb85f0d9b00a8baa Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:37:47 +0100 Subject: [PATCH 17/58] changed signature method commit between laravel versions 9 and 10, the signature of the method `commit` within the `DatabaseTransactionsManager:class` was changed. --- tests/Feature/TestCase.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php index fc69568a..c49d8608 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/TestCase.php @@ -96,8 +96,6 @@ public function testPush(): void public function testPushAfterCommit(): void { - $this->markTestSkipped(); - $transaction = new DatabaseTransactionsManager; $this->app->singleton('db.transactions', function ($app) use ($transaction) { @@ -112,7 +110,7 @@ public function testPushAfterCommit(): void $this->assertSame(0, Queue::size()); $this->assertNull(Queue::pop()); - $transaction->commit('FakeDBConnection'); + $transaction->commit('FakeDBConnection', 1, 0); sleep(1); From e04ff6b41e626ef2d0457f7b7154cfe856764d02 Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:49:33 +0100 Subject: [PATCH 18/58] changed the php-amqplib version to ^3.6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e7167c1a..cd2e6898 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": "^8.0", "ext-json": "*", "illuminate/queue": "^9.0|^10.0", - "php-amqplib/php-amqplib": "^v3.5.2" + "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { "phpunit/phpunit": "^9.3", From a7de79e86fd8e2b802ccd8be99979e7165b1f5a8 Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Thu, 25 Jan 2024 12:52:43 +0100 Subject: [PATCH 19/58] Update ConnectorTest.php --- tests/Feature/ConnectorTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/Feature/ConnectorTest.php b/tests/Feature/ConnectorTest.php index 8b8ecd82..91660ad2 100644 --- a/tests/Feature/ConnectorTest.php +++ b/tests/Feature/ConnectorTest.php @@ -144,8 +144,6 @@ public function testSslConnection(): void // Test to validate ssl connection params public function testNoVerificationSslConnection(): void { - $this->markTestSkipped(); - $this->app['config']->set('queue.connections.rabbitmq', [ 'driver' => 'rabbitmq', 'queue' => env('RABBITMQ_QUEUE', 'default'), From ba4dd0e31af0730240a10992b69e04785d59d616 Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Fri, 26 Jan 2024 13:15:46 +0100 Subject: [PATCH 20/58] Fix for errors on $currentJob property RabbitMQQueue::$currentJob must not be accessed before initialization Fixes for issue: #572 #555 --- src/Queue/RabbitMQQueue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Queue/RabbitMQQueue.php b/src/Queue/RabbitMQQueue.php index 0bf2e608..19c4efb2 100644 --- a/src/Queue/RabbitMQQueue.php +++ b/src/Queue/RabbitMQQueue.php @@ -54,7 +54,7 @@ class RabbitMQQueue extends Queue implements QueueContract, RabbitMQQueueContrac /** * Current job being processed. */ - protected RabbitMQJob $currentJob; + protected ?RabbitMQJob $currentJob = null; /** * Holds the Configuration From cfca9419eac07def75c5ca2514e21002deb327fa Mon Sep 17 00:00:00 2001 From: Emiel Bom <11626777+adm-bome@users.noreply.github.com> Date: Mon, 29 Jan 2024 10:08:56 +0100 Subject: [PATCH 21/58] Update README.md Build status icon: link/urls altered --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b7b51350..adb7b2e9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ RabbitMQ Queue driver for Laravel ====================== [![Latest Stable Version](https://poser.pugx.org/vladimir-yuldashev/laravel-queue-rabbitmq/v/stable?format=flat-square)](https://packagist.org/packages/vladimir-yuldashev/laravel-queue-rabbitmq) -[![Build Status](https://github.com/vyuldashev/laravel-queue-rabbitmq/workflows/Tests/badge.svg)](https://github.com/vyuldashev/laravel-queue-rabbitmq/actions) +[![Build Status](https://github.com/vyuldashev/laravel-queue-rabbitmq/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/vyuldashev/laravel-queue-rabbitmq/actions/workflows/tests.yml) [![Total Downloads](https://poser.pugx.org/vladimir-yuldashev/laravel-queue-rabbitmq/downloads?format=flat-square)](https://packagist.org/packages/vladimir-yuldashev/laravel-queue-rabbitmq) [![License](https://poser.pugx.org/vladimir-yuldashev/laravel-queue-rabbitmq/license?format=flat-square)](https://packagist.org/packages/vladimir-yuldashev/laravel-queue-rabbitmq) From 3b23045bb9ad27f5a47267cab34bc99989151e70 Mon Sep 17 00:00:00 2001 From: Seb Date: Tue, 12 Mar 2024 13:07:35 -0700 Subject: [PATCH 22/58] laravel 11 test --- .github/workflows/tests.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 37c80375..de605b46 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: matrix: php: ['8.0', '8.1', '8.2'] stability: ['prefer-lowest', prefer-stable] - laravel: ['^9.0', '^10.0'] + laravel: ['^9.0', '^10.0', '^11.0'] exclude: - php: '8.0' laravel: '^10.0' diff --git a/composer.json b/composer.json index cd2e6898..4e70a3eb 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": "^8.0", "ext-json": "*", - "illuminate/queue": "^9.0|^10.0", + "illuminate/queue": "^9.0|^10.0|^11.0", "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { From 21b4bc11e602249559de7d656ce6a9335395ef50 Mon Sep 17 00:00:00 2001 From: Seb Date: Tue, 12 Mar 2024 13:10:02 -0700 Subject: [PATCH 23/58] missed one --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4e70a3eb..5d7d43bd 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ "laravel/horizon": "^5.0", "orchestra/testbench": "^7.0|^8.0", "laravel/pint": "^1.2", - "laravel/framework": "^9.0|^10.0" + "laravel/framework": "^9.0|^10.0|^11.0" }, "autoload": { "psr-4": { From 5ecbc176686d884b1167a751278fd9816d0a7389 Mon Sep 17 00:00:00 2001 From: Seb Date: Tue, 12 Mar 2024 13:12:01 -0700 Subject: [PATCH 24/58] the matrix --- .github/workflows/tests.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index de605b46..0949eeb0 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,6 +19,10 @@ jobs: exclude: - php: '8.0' laravel: '^10.0' + - php: '8.0' + laravel: '^11.0' + - php: '8.1' + laravel: '^11.0' name: 'PHP ${{ matrix.php }} - Laravel: ${{matrix.laravel}} - ${{ matrix.stability }}' From a453471dc98692114c03cb0d945adeadc0ac9869 Mon Sep 17 00:00:00 2001 From: Seb Date: Tue, 12 Mar 2024 13:24:11 -0700 Subject: [PATCH 25/58] orchestra --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d7d43bd..b9e327d4 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "phpunit/phpunit": "^9.3", "mockery/mockery": "^1.0", "laravel/horizon": "^5.0", - "orchestra/testbench": "^7.0|^8.0", + "orchestra/testbench": "^7.0|^8.0|^9.0", "laravel/pint": "^1.2", "laravel/framework": "^9.0|^10.0|^11.0" }, From a40b400d4f408eb5d182013d69f74e292aae48a8 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 09:41:19 -0700 Subject: [PATCH 26/58] reflop From 261d236242c6b5ce61e9a3a90f482f527d700baf Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 09:57:08 -0700 Subject: [PATCH 27/58] phpunit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b9e327d4..d0ec318a 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { - "phpunit/phpunit": "^9.3", + "phpunit/phpunit": "^9.3 || ^10.5 || ^11.0.1", "mockery/mockery": "^1.0", "laravel/horizon": "^5.0", "orchestra/testbench": "^7.0|^8.0|^9.0", From 4d96f07f91bc088cf66f247821c4d1ff12302fe9 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 10:06:05 -0700 Subject: [PATCH 28/58] phpunit --- .github/workflows/tests.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0949eeb0..79574284 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -54,4 +54,4 @@ jobs: run: ./vendor/bin/pint --test - name: Execute tests - run: sleep 10 && vendor/bin/phpunit --verbose + run: sleep 10 && vendor/bin/phpunit --debug diff --git a/composer.json b/composer.json index d0ec318a..10480139 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { - "phpunit/phpunit": "^9.3 || ^10.5 || ^11.0.1", + "phpunit/phpunit": "^9.3 || ^10.5 || ^11.0", "mockery/mockery": "^1.0", "laravel/horizon": "^5.0", "orchestra/testbench": "^7.0|^8.0|^9.0", From 7947a32523f9d2c43391ba6d93bdd7294df6c3d8 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 10:41:50 -0700 Subject: [PATCH 29/58] phpunit --- .github/workflows/tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 79574284..20254e12 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,7 +14,7 @@ jobs: fail-fast: true matrix: php: ['8.0', '8.1', '8.2'] - stability: ['prefer-lowest', prefer-stable] + stability: ['prefer-lowest', 'prefer-stable'] laravel: ['^9.0', '^10.0', '^11.0'] exclude: - php: '8.0' @@ -54,4 +54,4 @@ jobs: run: ./vendor/bin/pint --test - name: Execute tests - run: sleep 10 && vendor/bin/phpunit --debug + run: sleep 10 && (vendor/bin/phpunit --debug || vendor/bin/phpunit --verbose) From 173186643e650b91b6eef609f21330a2c4c8211c Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 10:46:00 -0700 Subject: [PATCH 30/58] phpunit --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 20254e12..fd06a8b9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -54,4 +54,4 @@ jobs: run: ./vendor/bin/pint --test - name: Execute tests - run: sleep 10 && (vendor/bin/phpunit --debug || vendor/bin/phpunit --verbose) + run: sleep 10 && vendor/bin/phpunit From 6e78b31b1b5ded11a44de41f227d2eb3ad4018f1 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:04:55 -0700 Subject: [PATCH 31/58] skip10 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 10480139..37a7aac9 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { - "phpunit/phpunit": "^9.3 || ^10.5 || ^11.0", + "phpunit/phpunit": "^9.3|^11.0", "mockery/mockery": "^1.0", "laravel/horizon": "^5.0", "orchestra/testbench": "^7.0|^8.0|^9.0", From ea5b087b3d9feeba2dc127a7ce6363c3595edfc1 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:08:28 -0700 Subject: [PATCH 32/58] config format --- phpunit.xml.dist | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7e166ab8..57791a39 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,25 @@ - - - - src/ - - - - - - - - ./tests/ - - - - - - - - - + + + + + + + + + ./tests/ + + + + + + + + + + + + src/ + + From 3c33cddfb65bf156c310a9f1e86c83d7cf868435 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:13:53 -0700 Subject: [PATCH 33/58] nogroups --- tests/Feature/SslQueueTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/Feature/SslQueueTest.php b/tests/Feature/SslQueueTest.php index 7233ee09..e9c460ea 100644 --- a/tests/Feature/SslQueueTest.php +++ b/tests/Feature/SslQueueTest.php @@ -4,9 +4,6 @@ use PhpAmqpLib\Connection\AMQPSSLConnection; -/** - * @group functional - */ class SslQueueTest extends TestCase { public function setUp(): void From 0391b4155398d5c54ab2cfa5b2c14dbfb404d27f Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:22:02 -0700 Subject: [PATCH 34/58] only keep supported versions --- .github/workflows/tests.yml | 9 +++------ composer.json | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd06a8b9..7baac992 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,14 +13,10 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.0', '8.1', '8.2'] + php: ['8.1', '8.2', '8.3'] stability: ['prefer-lowest', 'prefer-stable'] - laravel: ['^9.0', '^10.0', '^11.0'] + laravel: ['^10.0', '^11.0'] exclude: - - php: '8.0' - laravel: '^10.0' - - php: '8.0' - laravel: '^11.0' - php: '8.1' laravel: '^11.0' @@ -54,4 +50,5 @@ jobs: run: ./vendor/bin/pint --test - name: Execute tests + if: run: sleep 10 && vendor/bin/phpunit diff --git a/composer.json b/composer.json index 37a7aac9..0f964596 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { - "phpunit/phpunit": "^9.3|^11.0", + "phpunit/phpunit": "^11.0", "mockery/mockery": "^1.0", "laravel/horizon": "^5.0", "orchestra/testbench": "^7.0|^8.0|^9.0", From 6612effdfcf6cc923982c2781e09e3659e93334f Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:23:10 -0700 Subject: [PATCH 35/58] whoopsie --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0f964596..a4cb0504 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { - "phpunit/phpunit": "^11.0", + "phpunit/phpunit": "^10.0|^11.0", "mockery/mockery": "^1.0", "laravel/horizon": "^5.0", "orchestra/testbench": "^7.0|^8.0|^9.0", From a4065e24bd33500513785a888f0197c41aeff2e0 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:28:47 -0700 Subject: [PATCH 36/58] who knows --- composer.json | 2 +- phpunit.xml.dist | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index a4cb0504..1a91d725 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": "^8.0", "ext-json": "*", - "illuminate/queue": "^9.0|^10.0|^11.0", + "illuminate/queue": "^10.0|^11.0", "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 57791a39..5d537691 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,20 +1,29 @@ - - - - - - + ./tests/ - - - - + + + + From 453324a0bcca2c8a781972861f789cb1e0db9eb7 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:37:08 -0700 Subject: [PATCH 37/58] Happify phpunit --- tests/{TestCase.php => BaseTestCase.php} | 4 ++-- tests/Feature/{TestCase.php => BaseTestCase.php} | 4 ++-- tests/Feature/ConnectorTest.php | 2 +- tests/Feature/QueueTest.php | 2 +- tests/Feature/SslQueueTest.php | 2 +- tests/Functional/{TestCase.php => BaseTestCase.php} | 4 ++-- tests/Functional/RabbitMQQueueTest.php | 1 - 7 files changed, 9 insertions(+), 10 deletions(-) rename tests/{TestCase.php => BaseTestCase.php} (94%) rename tests/Feature/{TestCase.php => BaseTestCase.php} (98%) rename tests/Functional/{TestCase.php => BaseTestCase.php} (98%) diff --git a/tests/TestCase.php b/tests/BaseTestCase.php similarity index 94% rename from tests/TestCase.php rename to tests/BaseTestCase.php index 7d50fa67..a2ad4983 100644 --- a/tests/TestCase.php +++ b/tests/BaseTestCase.php @@ -3,12 +3,12 @@ namespace VladimirYuldashev\LaravelQueueRabbitMQ\Tests; use Illuminate\Support\Facades\Queue; -use Orchestra\Testbench\TestCase as BaseTestCase; +use Orchestra\Testbench\TestCase; use PhpAmqpLib\Connection\AMQPLazyConnection; use VladimirYuldashev\LaravelQueueRabbitMQ\LaravelQueueRabbitMQServiceProvider; use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue; -abstract class TestCase extends BaseTestCase +abstract class BaseTestCase extends TestCase { protected function getPackageProviders($app): array { diff --git a/tests/Feature/TestCase.php b/tests/Feature/BaseTestCase.php similarity index 98% rename from tests/Feature/TestCase.php rename to tests/Feature/BaseTestCase.php index c49d8608..11cedfb1 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/BaseTestCase.php @@ -8,10 +8,10 @@ use PhpAmqpLib\Exception\AMQPProtocolChannelException; use RuntimeException; use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob; +use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\BaseTestCase as TestCase; use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestJob; -use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase as BaseTestCase; -abstract class TestCase extends BaseTestCase +abstract class BaseTestCase extends TestCase { /** * @throws AMQPProtocolChannelException diff --git a/tests/Feature/ConnectorTest.php b/tests/Feature/ConnectorTest.php index 91660ad2..263fbd90 100644 --- a/tests/Feature/ConnectorTest.php +++ b/tests/Feature/ConnectorTest.php @@ -10,7 +10,7 @@ use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue; use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestSSLConnection; -class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase +class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\BaseTestCase { public function testLazyConnection(): void { diff --git a/tests/Feature/QueueTest.php b/tests/Feature/QueueTest.php index 5ecfb978..3c5ed540 100644 --- a/tests/Feature/QueueTest.php +++ b/tests/Feature/QueueTest.php @@ -8,7 +8,7 @@ use PhpAmqpLib\Exception\AMQPProtocolChannelException; use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestJob; -class QueueTest extends TestCase +class QueueTest extends BaseTestCase { public function setUp(): void { diff --git a/tests/Feature/SslQueueTest.php b/tests/Feature/SslQueueTest.php index e9c460ea..96383bbc 100644 --- a/tests/Feature/SslQueueTest.php +++ b/tests/Feature/SslQueueTest.php @@ -4,7 +4,7 @@ use PhpAmqpLib\Connection\AMQPSSLConnection; -class SslQueueTest extends TestCase +class SslQueueTest extends BaseTestCase { public function setUp(): void { diff --git a/tests/Functional/TestCase.php b/tests/Functional/BaseTestCase.php similarity index 98% rename from tests/Functional/TestCase.php rename to tests/Functional/BaseTestCase.php index 8b843561..0ab263b8 100644 --- a/tests/Functional/TestCase.php +++ b/tests/Functional/BaseTestCase.php @@ -6,9 +6,9 @@ use PhpAmqpLib\Channel\AMQPChannel; use ReflectionClass; use ReflectionException; -use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase as BaseTestCase; +use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\BaseTestCase as TestCase; -abstract class TestCase extends BaseTestCase +abstract class BaseTestCase extends TestCase { protected function getEnvironmentSetUp($app): void { diff --git a/tests/Functional/RabbitMQQueueTest.php b/tests/Functional/RabbitMQQueueTest.php index 7a106a08..936857ba 100644 --- a/tests/Functional/RabbitMQQueueTest.php +++ b/tests/Functional/RabbitMQQueueTest.php @@ -5,7 +5,6 @@ use Illuminate\Support\Str; use PhpAmqpLib\Exchange\AMQPExchangeType; use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue; -use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Functional\TestCase as BaseTestCase; class RabbitMQQueueTest extends BaseTestCase { From 74c05cdf72bc8f18b0bb5d8a5d9143c42cc60e66 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:55:48 -0700 Subject: [PATCH 38/58] Revert "Happify phpunit" This reverts commit 453324a0bcca2c8a781972861f789cb1e0db9eb7. --- tests/Feature/ConnectorTest.php | 2 +- tests/Feature/QueueTest.php | 2 +- tests/Feature/SslQueueTest.php | 2 +- tests/Feature/{BaseTestCase.php => TestCase.php} | 4 ++-- tests/Functional/RabbitMQQueueTest.php | 1 + tests/Functional/{BaseTestCase.php => TestCase.php} | 4 ++-- tests/{BaseTestCase.php => TestCase.php} | 4 ++-- 7 files changed, 10 insertions(+), 9 deletions(-) rename tests/Feature/{BaseTestCase.php => TestCase.php} (98%) rename tests/Functional/{BaseTestCase.php => TestCase.php} (98%) rename tests/{BaseTestCase.php => TestCase.php} (94%) diff --git a/tests/Feature/ConnectorTest.php b/tests/Feature/ConnectorTest.php index 263fbd90..91660ad2 100644 --- a/tests/Feature/ConnectorTest.php +++ b/tests/Feature/ConnectorTest.php @@ -10,7 +10,7 @@ use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue; use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestSSLConnection; -class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\BaseTestCase +class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase { public function testLazyConnection(): void { diff --git a/tests/Feature/QueueTest.php b/tests/Feature/QueueTest.php index 3c5ed540..5ecfb978 100644 --- a/tests/Feature/QueueTest.php +++ b/tests/Feature/QueueTest.php @@ -8,7 +8,7 @@ use PhpAmqpLib\Exception\AMQPProtocolChannelException; use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestJob; -class QueueTest extends BaseTestCase +class QueueTest extends TestCase { public function setUp(): void { diff --git a/tests/Feature/SslQueueTest.php b/tests/Feature/SslQueueTest.php index 96383bbc..e9c460ea 100644 --- a/tests/Feature/SslQueueTest.php +++ b/tests/Feature/SslQueueTest.php @@ -4,7 +4,7 @@ use PhpAmqpLib\Connection\AMQPSSLConnection; -class SslQueueTest extends BaseTestCase +class SslQueueTest extends TestCase { public function setUp(): void { diff --git a/tests/Feature/BaseTestCase.php b/tests/Feature/TestCase.php similarity index 98% rename from tests/Feature/BaseTestCase.php rename to tests/Feature/TestCase.php index 11cedfb1..c49d8608 100644 --- a/tests/Feature/BaseTestCase.php +++ b/tests/Feature/TestCase.php @@ -8,10 +8,10 @@ use PhpAmqpLib\Exception\AMQPProtocolChannelException; use RuntimeException; use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob; -use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\BaseTestCase as TestCase; use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestJob; +use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase as BaseTestCase; -abstract class BaseTestCase extends TestCase +abstract class TestCase extends BaseTestCase { /** * @throws AMQPProtocolChannelException diff --git a/tests/Functional/RabbitMQQueueTest.php b/tests/Functional/RabbitMQQueueTest.php index 936857ba..7a106a08 100644 --- a/tests/Functional/RabbitMQQueueTest.php +++ b/tests/Functional/RabbitMQQueueTest.php @@ -5,6 +5,7 @@ use Illuminate\Support\Str; use PhpAmqpLib\Exchange\AMQPExchangeType; use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue; +use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Functional\TestCase as BaseTestCase; class RabbitMQQueueTest extends BaseTestCase { diff --git a/tests/Functional/BaseTestCase.php b/tests/Functional/TestCase.php similarity index 98% rename from tests/Functional/BaseTestCase.php rename to tests/Functional/TestCase.php index 0ab263b8..8b843561 100644 --- a/tests/Functional/BaseTestCase.php +++ b/tests/Functional/TestCase.php @@ -6,9 +6,9 @@ use PhpAmqpLib\Channel\AMQPChannel; use ReflectionClass; use ReflectionException; -use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\BaseTestCase as TestCase; +use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase as BaseTestCase; -abstract class BaseTestCase extends TestCase +abstract class TestCase extends BaseTestCase { protected function getEnvironmentSetUp($app): void { diff --git a/tests/BaseTestCase.php b/tests/TestCase.php similarity index 94% rename from tests/BaseTestCase.php rename to tests/TestCase.php index a2ad4983..7d50fa67 100644 --- a/tests/BaseTestCase.php +++ b/tests/TestCase.php @@ -3,12 +3,12 @@ namespace VladimirYuldashev\LaravelQueueRabbitMQ\Tests; use Illuminate\Support\Facades\Queue; -use Orchestra\Testbench\TestCase; +use Orchestra\Testbench\TestCase as BaseTestCase; use PhpAmqpLib\Connection\AMQPLazyConnection; use VladimirYuldashev\LaravelQueueRabbitMQ\LaravelQueueRabbitMQServiceProvider; use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\RabbitMQQueue; -abstract class BaseTestCase extends TestCase +abstract class TestCase extends BaseTestCase { protected function getPackageProviders($app): array { From 2408bba9f11f20dc07252584a6efeea5a0dfed64 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 11:57:36 -0700 Subject: [PATCH 39/58] only use test files --- phpunit.xml.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5d537691..da6c9d37 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,7 +12,7 @@ backupStaticProperties="false"> - ./tests/ + ./tests/ From 75fa317e65f2889eca617b7c589dbfd276d95a69 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 12:13:31 -0700 Subject: [PATCH 40/58] yo --- phpunit.xml.dist | 57 +++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index da6c9d37..c3fc3599 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,34 +1,27 @@ - - - - ./tests/ - - - - - - - - - - - - src/ - - + + + + src/ + + + + + + + + ./tests/ + + + + + + + + + From dd97e4b3cb30b2f3260fec12f177f8dfb93ffb40 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 12:16:30 -0700 Subject: [PATCH 41/58] fixie --- phpunit.xml.dist | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c3fc3599..219f4c66 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,25 @@ - - - - src/ - - - - - - - - ./tests/ - - - - - - - - - + + + + + + + + + ./tests/ + + + + + + + + + + + + src/ + + From 3f8df65433a1bda50a0b6f7077e858e4523a6861 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 12:19:13 -0700 Subject: [PATCH 42/58] nocov --- phpunit.xml.dist | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 219f4c66..10a342a9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,5 @@ - - - - - ./tests/ From f550805d944bf130a9e607e0eb061de0b2f38cab Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 12:21:36 -0700 Subject: [PATCH 43/58] nosource --- phpunit.xml.dist | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 10a342a9..71be4e98 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,9 +12,4 @@ - - - src/ - - From 83c646ea55f7350d1549a107e39230371c547055 Mon Sep 17 00:00:00 2001 From: Seb Date: Wed, 13 Mar 2024 12:26:41 -0700 Subject: [PATCH 44/58] mew --- .github/workflows/tests.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7baac992..fccb0608 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -50,5 +50,4 @@ jobs: run: ./vendor/bin/pint --test - name: Execute tests - if: run: sleep 10 && vendor/bin/phpunit From f87aa9d63b39eb9fb14433f29f2a05db5eb35e4c Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 14 Mar 2024 08:29:16 -0700 Subject: [PATCH 45/58] changelog --- CHANGELOG-14x.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 CHANGELOG-14x.md diff --git a/CHANGELOG-14x.md b/CHANGELOG-14x.md new file mode 100644 index 00000000..c94b3dd2 --- /dev/null +++ b/CHANGELOG-14x.md @@ -0,0 +1,8 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [unreleased](https://github.com/vyuldashev/laravel-queue-rabbitmq/compare/v13.3.0...master) + +## [14.0.0] +- First release compatible with Laravel 11 From fc341b3f19496bc1c66cd38a665c2d2da8b8baaf Mon Sep 17 00:00:00 2001 From: therecluse26 <8239106+therecluse26@users.noreply.github.com> Date: Sun, 21 Apr 2024 15:26:25 -0400 Subject: [PATCH 46/58] Allow for encrypted command data Added a bugfix to handle fetching priority from encrypted command data if the job class implements `ShouldBeEncrypted` --- src/Queue/RabbitMQQueue.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Queue/RabbitMQQueue.php b/src/Queue/RabbitMQQueue.php index 19c4efb2..6cb2126f 100644 --- a/src/Queue/RabbitMQQueue.php +++ b/src/Queue/RabbitMQQueue.php @@ -525,6 +525,11 @@ protected function createMessage($payload, int $attempts = 0): array } if (isset($currentPayload['data']['command'])) { + // If the command data is encrypted, decrypt it first before attempting to unserialize + if (in_array(ShouldBeEncrypted::class, class_implements($currentPayload['data']['commandName']))) { + $currentPayload['data']['command'] = decrypt($currentPayload['data']['command']); + } + $commandData = unserialize($currentPayload['data']['command']); if (property_exists($commandData, 'priority')) { $properties['priority'] = $commandData->priority; From 9bd427a6d281d6e0f0fa576ae04435100380b4dd Mon Sep 17 00:00:00 2001 From: therecluse26 Date: Wed, 24 Apr 2024 17:28:09 -0400 Subject: [PATCH 47/58] Added encryption key, tests and requested updates --- phpunit.xml.dist | 1 + src/Queue/RabbitMQQueue.php | 8 ++- tests/Feature/TestCase.php | 98 ++++++++++++++++++++++++++++++++ tests/Mocks/TestEncryptedJob.php | 25 ++++++++ 4 files changed, 129 insertions(+), 3 deletions(-) create mode 100644 tests/Mocks/TestEncryptedJob.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 71be4e98..d213fd63 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,6 +10,7 @@ + diff --git a/src/Queue/RabbitMQQueue.php b/src/Queue/RabbitMQQueue.php index 6cb2126f..ce63494d 100644 --- a/src/Queue/RabbitMQQueue.php +++ b/src/Queue/RabbitMQQueue.php @@ -7,8 +7,10 @@ use ErrorException; use Exception; use Illuminate\Contracts\Queue\Queue as QueueContract; +use Illuminate\Contracts\Queue\ShouldBeEncrypted; use Illuminate\Queue\Queue; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Crypt; use Illuminate\Support\Str; use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Connection\AbstractConnection; @@ -526,10 +528,10 @@ protected function createMessage($payload, int $attempts = 0): array if (isset($currentPayload['data']['command'])) { // If the command data is encrypted, decrypt it first before attempting to unserialize - if (in_array(ShouldBeEncrypted::class, class_implements($currentPayload['data']['commandName']))) { - $currentPayload['data']['command'] = decrypt($currentPayload['data']['command']); + if (is_subclass_of($currentPayload['data']['commandName'], ShouldBeEncrypted::class)) { + $currentPayload['data']['command'] = Crypt::decrypt($currentPayload['data']['command']); } - + $commandData = unserialize($currentPayload['data']['command']); if (property_exists($commandData, 'priority')) { $properties['priority'] = $commandData->priority; diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php index c49d8608..16fd5faa 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/TestCase.php @@ -8,6 +8,7 @@ use PhpAmqpLib\Exception\AMQPProtocolChannelException; use RuntimeException; use VladimirYuldashev\LaravelQueueRabbitMQ\Queue\Jobs\RabbitMQJob; +use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestEncryptedJob; use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\Mocks\TestJob; use VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase as BaseTestCase; @@ -194,6 +195,103 @@ public function testBulk(): void $this->assertSame($count, Queue::size()); } + public function testPushEncrypted(): void + { + Queue::push(new TestEncryptedJob()); + + sleep(1); + + $this->assertSame(1, Queue::size()); + $this->assertNotNull($job = Queue::pop()); + $this->assertSame(1, $job->attempts()); + $this->assertInstanceOf(RabbitMQJob::class, $job); + $this->assertSame(TestEncryptedJob::class, $job->resolveName()); + $this->assertNotNull($job->getJobId()); + + $payload = $job->payload(); + + $this->assertSame(TestEncryptedJob::class, $payload['displayName']); + $this->assertSame('Illuminate\Queue\CallQueuedHandler@call', $payload['job']); + $this->assertNull($payload['maxTries']); + $this->assertNull($payload['backoff']); + $this->assertNull($payload['timeout']); + $this->assertNull($payload['retryUntil']); + $this->assertSame($job->getJobId(), $payload['id']); + + $job->delete(); + $this->assertSame(0, Queue::size()); + } + + public function testPushEncryptedAfterCommit(): void + { + $transaction = new DatabaseTransactionsManager; + + $this->app->singleton('db.transactions', function ($app) use ($transaction) { + $transaction->begin('FakeDBConnection', 1); + + return $transaction; + }); + + TestEncryptedJob::dispatch()->afterCommit(); + + sleep(1); + $this->assertSame(0, Queue::size()); + $this->assertNull(Queue::pop()); + + $transaction->commit('FakeDBConnection', 1, 0); + + sleep(1); + + $this->assertSame(1, Queue::size()); + $this->assertNotNull($job = Queue::pop()); + + $job->delete(); + $this->assertSame(0, Queue::size()); + } + + public function testEncryptedLater(): void + { + Queue::later(3, new TestEncryptedJob()); + + sleep(1); + + $this->assertSame(0, Queue::size()); + $this->assertNull(Queue::pop()); + + sleep(3); + + $this->assertSame(1, Queue::size()); + $this->assertNotNull($job = Queue::pop()); + + $this->assertInstanceOf(RabbitMQJob::class, $job); + + $body = json_decode($job->getRawBody(), true); + + $this->assertSame(TestEncryptedJob::class, $body['displayName']); + $this->assertSame('Illuminate\Queue\CallQueuedHandler@call', $body['job']); + $this->assertSame(TestEncryptedJob::class, $body['data']['commandName']); + $this->assertNotNull($job->getJobId()); + + $job->delete(); + $this->assertSame(0, Queue::size()); + } + + public function testEncryptedBulk(): void + { + $count = 100; + $jobs = []; + + for ($i = 0; $i < $count; $i++) { + $jobs[$i] = new TestEncryptedJob($i); + } + + Queue::bulk($jobs); + + sleep(1); + + $this->assertSame($count, Queue::size()); + } + public function testReleaseRaw(): void { Queue::pushRaw($payload = Str::random()); diff --git a/tests/Mocks/TestEncryptedJob.php b/tests/Mocks/TestEncryptedJob.php new file mode 100644 index 00000000..1c0e1762 --- /dev/null +++ b/tests/Mocks/TestEncryptedJob.php @@ -0,0 +1,25 @@ +i = $i; + } + + public function handle(): void + { + // + } +} From 813086aa9bb6e56fef09219e43eba481f9f3f66e Mon Sep 17 00:00:00 2001 From: Fabien Villepinte Date: Mon, 8 Jul 2024 09:13:26 +0200 Subject: [PATCH 48/58] Document the exceptions thrown by publishBasic() --- src/Queue/RabbitMQQueue.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Queue/RabbitMQQueue.php b/src/Queue/RabbitMQQueue.php index ce63494d..957620ef 100644 --- a/src/Queue/RabbitMQQueue.php +++ b/src/Queue/RabbitMQQueue.php @@ -15,6 +15,7 @@ use PhpAmqpLib\Channel\AMQPChannel; use PhpAmqpLib\Connection\AbstractConnection; use PhpAmqpLib\Exception\AMQPChannelClosedException; +use PhpAmqpLib\Exception\AMQPConnectionBlockedException; use PhpAmqpLib\Exception\AMQPConnectionClosedException; use PhpAmqpLib\Exception\AMQPProtocolChannelException; use PhpAmqpLib\Exception\AMQPRuntimeException; @@ -739,6 +740,11 @@ protected function getConfig(): QueueConfig return $this->config; } + /** + * @throws AMQPChannelClosedException + * @throws AMQPConnectionClosedException + * @throws AMQPConnectionBlockedException + */ protected function publishBasic($msg, $exchange = '', $destination = '', $mandatory = false, $immediate = false, $ticket = null): void { $this->getChannel()->basic_publish($msg, $exchange, $destination, $mandatory, $immediate, $ticket); From aaad79f2c7dd0a918de8b43dfe6ee2f117d6da94 Mon Sep 17 00:00:00 2001 From: VojtaB Date: Thu, 12 Dec 2024 19:47:42 +0100 Subject: [PATCH 49/58] load timeouts from laravel config --- README.md | 27 ++++++++++++++++++++++++++ src/Queue/Connection/ConfigFactory.php | 24 +++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/README.md b/README.md index adb7b2e9..30a10df9 100644 --- a/README.md +++ b/README.md @@ -529,6 +529,33 @@ Available protocols : `tcp`, `ssl`, `tls` ], ``` +### Network Timeouts + +For network timeouts configuration you can use option parameters. +All float values are in seconds and zero value can mean infinite timeout. +Example contains default values. + +```php +'connections' => [ + // ... + + 'rabbitmq' => [ + // ... + + 'options' => [ + // ... + + 'connection_timeout' => 3.0, + 'read_timeout' => 3.0, + 'write_timeout' => 3.0, + 'channel_rpc_timeout' => 0.0, + ], + ], + + // ... +], +``` + ### Octane support Starting with 13.3.0, this package supports [Laravel Octane](https://laravel.com/docs/octane) out of the box. diff --git a/src/Queue/Connection/ConfigFactory.php b/src/Queue/Connection/ConfigFactory.php index 7783b9cd..8e013efd 100644 --- a/src/Queue/Connection/ConfigFactory.php +++ b/src/Queue/Connection/ConfigFactory.php @@ -38,6 +38,7 @@ public static function make(array $config = []): AMQPConnectionConfig self::getHostFromConfig($connectionConfig, $config); self::getHeartbeatFromConfig($connectionConfig, $config); self::getNetworkProtocolFromConfig($connectionConfig, $config); + self::getTimeoutsFromConfig($connectionConfig, $config); }); } @@ -99,4 +100,27 @@ protected static function getNetworkProtocolFromConfig(AMQPConnectionConfig $con $connectionConfig->setNetworkProtocol($networkProtocol); } } + + protected static function getTimeoutsFromConfig(AMQPConnectionConfig $connectionConfig, array $config): void + { + $connectionTimeout = Arr::get($config, self::CONFIG_OPTIONS.'.connection_timeout'); + if (is_numeric($connectionTimeout) && floatval($connectionTimeout) >= 0) { + $connectionConfig->setConnectionTimeout((float) $connectionTimeout); + } + + $readTimeout = Arr::get($config, self::CONFIG_OPTIONS.'.read_timeout'); + if (is_numeric($readTimeout) && floatval($readTimeout) >= 0) { + $connectionConfig->setReadTimeout((float) $readTimeout); + } + + $writeTimeout = Arr::get($config, self::CONFIG_OPTIONS.'.write_timeout'); + if (is_numeric($writeTimeout) && floatval($writeTimeout) >= 0) { + $connectionConfig->setWriteTimeout((float) $writeTimeout); + } + + $chanelRpcTimeout = Arr::get($config, self::CONFIG_OPTIONS.'.channel_rpc_timeout'); + if (is_numeric($chanelRpcTimeout) && floatval($chanelRpcTimeout) >= 0) { + $connectionConfig->setChannelRPCTimeout((float) $chanelRpcTimeout); + } + } } From c00a8cce370a1525cacfff2b7c5e11d666943e5a Mon Sep 17 00:00:00 2001 From: Sergey Tarasenko Date: Thu, 23 Jan 2025 00:19:27 +0300 Subject: [PATCH 50/58] pint fixes --- pint.json | 4 ++-- src/Horizon/RabbitMQQueue.php | 2 +- src/Queue/Connection/ConfigFactory.php | 2 +- src/Queue/QueueConfigFactory.php | 2 +- src/Queue/RabbitMQQueue.php | 14 +++++++------- tests/Feature/QueueTest.php | 6 +++--- tests/Feature/SslQueueTest.php | 2 +- tests/Feature/TestCase.php | 20 ++++++++++---------- tests/Functional/RabbitMQQueueTest.php | 2 +- tests/TestCase.php | 2 +- 10 files changed, 28 insertions(+), 28 deletions(-) diff --git a/pint.json b/pint.json index 751c2203..029010c0 100644 --- a/pint.json +++ b/pint.json @@ -1,8 +1,8 @@ { "preset": "laravel", "rules": { - "nullable_type_declaration_for_default_null_value": { - "use_nullable_type_declaration": false + "php_unit_method_casing": { + "case": "camel_case" } } } diff --git a/src/Horizon/RabbitMQQueue.php b/src/Horizon/RabbitMQQueue.php index 894cc24b..e2ca400d 100644 --- a/src/Horizon/RabbitMQQueue.php +++ b/src/Horizon/RabbitMQQueue.php @@ -26,7 +26,7 @@ class RabbitMQQueue extends BaseRabbitMQQueue * * @throws AMQPProtocolChannelException */ - public function readyNow(string $queue = null): int + public function readyNow(?string $queue = null): int { return $this->size($queue); } diff --git a/src/Queue/Connection/ConfigFactory.php b/src/Queue/Connection/ConfigFactory.php index 7783b9cd..f3ecd409 100644 --- a/src/Queue/Connection/ConfigFactory.php +++ b/src/Queue/Connection/ConfigFactory.php @@ -16,7 +16,7 @@ class ConfigFactory */ public static function make(array $config = []): AMQPConnectionConfig { - return tap(new AMQPConnectionConfig(), function (AMQPConnectionConfig $connectionConfig) use ($config) { + return tap(new AMQPConnectionConfig, function (AMQPConnectionConfig $connectionConfig) use ($config) { // Set the connection to a Lazy by default $connectionConfig->setIsLazy(! in_array( Arr::get($config, 'lazy') ?? true, diff --git a/src/Queue/QueueConfigFactory.php b/src/Queue/QueueConfigFactory.php index 87fc2fac..6f2befc5 100644 --- a/src/Queue/QueueConfigFactory.php +++ b/src/Queue/QueueConfigFactory.php @@ -13,7 +13,7 @@ class QueueConfigFactory */ public static function make(array $config = []): QueueConfig { - return tap(new QueueConfig(), function (QueueConfig $queueConfig) use ($config) { + return tap(new QueueConfig, function (QueueConfig $queueConfig) use ($config) { if (! empty($queue = Arr::get($config, 'queue'))) { $queueConfig->setQueue($queue); } diff --git a/src/Queue/RabbitMQQueue.php b/src/Queue/RabbitMQQueue.php index 957620ef..fadedce5 100644 --- a/src/Queue/RabbitMQQueue.php +++ b/src/Queue/RabbitMQQueue.php @@ -204,7 +204,7 @@ protected function publishBatch($jobs, $data = '', $queue = null): void /** * @throws AMQPProtocolChannelException */ - public function bulkRaw(string $payload, string $queue = null, array $options = []): int|string|null + public function bulkRaw(string $payload, ?string $queue = null, array $options = []): int|string|null { [$destination, $exchange, $exchangeType, $attempts] = $this->publishProperties($queue, $options); @@ -397,7 +397,7 @@ public function deleteExchange(string $name, bool $unused = false): void * * @throws AMQPProtocolChannelException */ - public function isQueueExists(string $name = null): bool + public function isQueueExists(?string $name = null): bool { $queueName = $this->getQueue($name); @@ -484,7 +484,7 @@ public function bindQueue(string $queue, string $exchange, string $routingKey = /** * Purge the queue of messages. */ - public function purge(string $queue = null): void + public function purge(?string $queue = null): void { // create a temporary channel, so the main channel will not be closed on exception $channel = $this->createChannel(); @@ -637,7 +637,7 @@ protected function getDelayQueueArguments(string $destination, int $ttl): array /** * Get the exchange name, or empty string; as default value. */ - protected function getExchange(string $exchange = null): string + protected function getExchange(?string $exchange = null): string { return $exchange ?? $this->getConfig()->getExchange(); } @@ -654,7 +654,7 @@ protected function getRoutingKey(string $destination): string /** * Get the exchangeType, or AMQPExchangeType::DIRECT as default. */ - protected function getExchangeType(string $type = null): string + protected function getExchangeType(?string $type = null): string { $constant = AMQPExchangeType::class.'::'.Str::upper($type ?: $this->getConfig()->getExchangeType()); @@ -664,7 +664,7 @@ protected function getExchangeType(string $type = null): string /** * Get the exchange for failed messages. */ - protected function getFailedExchange(string $exchange = null): string + protected function getFailedExchange(?string $exchange = null): string { return $exchange ?? $this->getConfig()->getFailedExchange(); } @@ -699,7 +699,7 @@ protected function isQueueDeclared(string $name): bool * * @throws AMQPProtocolChannelException */ - protected function declareDestination(string $destination, string $exchange = null, string $exchangeType = AMQPExchangeType::DIRECT): void + protected function declareDestination(string $destination, ?string $exchange = null, string $exchangeType = AMQPExchangeType::DIRECT): void { // When an exchange is provided and no exchange is present in RabbitMQ, create an exchange. if ($exchange && ! $this->isExchangeExists($exchange)) { diff --git a/tests/Feature/QueueTest.php b/tests/Feature/QueueTest.php index 5ecfb978..ee324c9a 100644 --- a/tests/Feature/QueueTest.php +++ b/tests/Feature/QueueTest.php @@ -10,7 +10,7 @@ class QueueTest extends TestCase { - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -29,7 +29,7 @@ public function testWithoutReconnect(): void { $queue = $this->connection('rabbitmq'); - $queue->push(new TestJob()); + $queue->push(new TestJob); sleep(1); $this->assertSame(1, $queue->size()); @@ -38,6 +38,6 @@ public function testWithoutReconnect(): void $this->assertFalse($queue->getConnection()->isConnected()); $this->expectException(AMQPChannelClosedException::class); - $queue->push(new TestJob()); + $queue->push(new TestJob); } } diff --git a/tests/Feature/SslQueueTest.php b/tests/Feature/SslQueueTest.php index e9c460ea..02181c96 100644 --- a/tests/Feature/SslQueueTest.php +++ b/tests/Feature/SslQueueTest.php @@ -6,7 +6,7 @@ class SslQueueTest extends TestCase { - public function setUp(): void + protected function setUp(): void { $this->markTestSkipped(); } diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php index 16fd5faa..5afda85d 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/TestCase.php @@ -17,7 +17,7 @@ abstract class TestCase extends BaseTestCase /** * @throws AMQPProtocolChannelException */ - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -70,7 +70,7 @@ public function testPushRaw(): void public function testPush(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); sleep(1); @@ -154,7 +154,7 @@ public function testLaterRaw(): void public function testLater(): void { - Queue::later(3, new TestJob()); + Queue::later(3, new TestJob); sleep(1); @@ -197,7 +197,7 @@ public function testBulk(): void public function testPushEncrypted(): void { - Queue::push(new TestEncryptedJob()); + Queue::push(new TestEncryptedJob); sleep(1); @@ -251,7 +251,7 @@ public function testPushEncryptedAfterCommit(): void public function testEncryptedLater(): void { - Queue::later(3, new TestEncryptedJob()); + Queue::later(3, new TestEncryptedJob); sleep(1); @@ -320,7 +320,7 @@ public function testReleaseRaw(): void public function testRelease(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); sleep(1); @@ -377,7 +377,7 @@ public function testReleaseWithDelayRaw(): void public function testReleaseInThePast(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); $job = Queue::pop(); $job->release(-3); @@ -392,7 +392,7 @@ public function testReleaseInThePast(): void public function testReleaseAndReleaseWithDelayAttempts(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); sleep(1); @@ -419,7 +419,7 @@ public function testReleaseAndReleaseWithDelayAttempts(): void public function testDelete(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); $job = Queue::pop(); @@ -433,7 +433,7 @@ public function testDelete(): void public function testFailed(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); $job = Queue::pop(); diff --git a/tests/Functional/RabbitMQQueueTest.php b/tests/Functional/RabbitMQQueueTest.php index 7a106a08..1c5d94fb 100644 --- a/tests/Functional/RabbitMQQueueTest.php +++ b/tests/Functional/RabbitMQQueueTest.php @@ -87,7 +87,7 @@ public function testConfigExchangeType(): void $queue = $this->connection('rabbitmq-with-options-null'); $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); - //testing an unkown type with a default + // testing an unkown type with a default $this->callProperty($queue, 'config')->setExchangeType('unknown'); $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 7d50fa67..f1ffb8d4 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -50,7 +50,7 @@ protected function getEnvironmentSetUp($app): void ]); } - protected function connection(string $name = null): RabbitMQQueue + protected function connection(?string $name = null): RabbitMQQueue { return Queue::connection($name); } From 4765c204d3c86aef9d6e1eda75a413c38efdad36 Mon Sep 17 00:00:00 2001 From: Samuel Fontebasso Date: Sun, 20 Apr 2025 01:45:50 -0300 Subject: [PATCH 51/58] style: fix formatting issues to pass lint/tests --- src/Queue/Connection/ConfigFactory.php | 2 +- src/Queue/QueueConfigFactory.php | 2 +- tests/Feature/ConnectorTest.php | 8 ++-- tests/Feature/QueueTest.php | 10 ++--- tests/Feature/SslQueueTest.php | 4 +- tests/Feature/TestCase.php | 58 +++++++++++++------------- tests/Functional/RabbitMQQueueTest.php | 30 ++++++------- tests/Functional/TestCase.php | 4 +- 8 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/Queue/Connection/ConfigFactory.php b/src/Queue/Connection/ConfigFactory.php index 7783b9cd..f3ecd409 100644 --- a/src/Queue/Connection/ConfigFactory.php +++ b/src/Queue/Connection/ConfigFactory.php @@ -16,7 +16,7 @@ class ConfigFactory */ public static function make(array $config = []): AMQPConnectionConfig { - return tap(new AMQPConnectionConfig(), function (AMQPConnectionConfig $connectionConfig) use ($config) { + return tap(new AMQPConnectionConfig, function (AMQPConnectionConfig $connectionConfig) use ($config) { // Set the connection to a Lazy by default $connectionConfig->setIsLazy(! in_array( Arr::get($config, 'lazy') ?? true, diff --git a/src/Queue/QueueConfigFactory.php b/src/Queue/QueueConfigFactory.php index 87fc2fac..6f2befc5 100644 --- a/src/Queue/QueueConfigFactory.php +++ b/src/Queue/QueueConfigFactory.php @@ -13,7 +13,7 @@ class QueueConfigFactory */ public static function make(array $config = []): QueueConfig { - return tap(new QueueConfig(), function (QueueConfig $queueConfig) use ($config) { + return tap(new QueueConfig, function (QueueConfig $queueConfig) use ($config) { if (! empty($queue = Arr::get($config, 'queue'))) { $queueConfig->setQueue($queue); } diff --git a/tests/Feature/ConnectorTest.php b/tests/Feature/ConnectorTest.php index 91660ad2..f4e330c3 100644 --- a/tests/Feature/ConnectorTest.php +++ b/tests/Feature/ConnectorTest.php @@ -12,7 +12,7 @@ class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase { - public function testLazyConnection(): void + public function test_lazy_connection(): void { $this->app['config']->set('queue.connections.rabbitmq', [ 'driver' => 'rabbitmq', @@ -55,7 +55,7 @@ public function testLazyConnection(): void $this->assertTrue($connection->getConnection()->isConnected()); } - public function testLazyStreamConnection(): void + public function test_lazy_stream_connection(): void { $this->app['config']->set('queue.connections.rabbitmq', [ 'driver' => 'rabbitmq', @@ -98,7 +98,7 @@ public function testLazyStreamConnection(): void $this->assertTrue($connection->getConnection()->isConnected()); } - public function testSslConnection(): void + public function test_ssl_connection(): void { $this->markTestSkipped(); @@ -142,7 +142,7 @@ public function testSslConnection(): void } // Test to validate ssl connection params - public function testNoVerificationSslConnection(): void + public function test_no_verification_ssl_connection(): void { $this->app['config']->set('queue.connections.rabbitmq', [ 'driver' => 'rabbitmq', diff --git a/tests/Feature/QueueTest.php b/tests/Feature/QueueTest.php index 5ecfb978..609a48d8 100644 --- a/tests/Feature/QueueTest.php +++ b/tests/Feature/QueueTest.php @@ -10,7 +10,7 @@ class QueueTest extends TestCase { - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -20,16 +20,16 @@ public function setUp(): void ]); } - public function testConnection(): void + public function test_connection(): void { $this->assertInstanceOf(AMQPStreamConnection::class, $this->connection()->getChannel()->getConnection()); } - public function testWithoutReconnect(): void + public function test_without_reconnect(): void { $queue = $this->connection('rabbitmq'); - $queue->push(new TestJob()); + $queue->push(new TestJob); sleep(1); $this->assertSame(1, $queue->size()); @@ -38,6 +38,6 @@ public function testWithoutReconnect(): void $this->assertFalse($queue->getConnection()->isConnected()); $this->expectException(AMQPChannelClosedException::class); - $queue->push(new TestJob()); + $queue->push(new TestJob); } } diff --git a/tests/Feature/SslQueueTest.php b/tests/Feature/SslQueueTest.php index e9c460ea..53cf5d38 100644 --- a/tests/Feature/SslQueueTest.php +++ b/tests/Feature/SslQueueTest.php @@ -6,7 +6,7 @@ class SslQueueTest extends TestCase { - public function setUp(): void + protected function setUp(): void { $this->markTestSkipped(); } @@ -43,7 +43,7 @@ protected function getEnvironmentSetUp($app): void ]); } - public function testConnection(): void + public function test_connection(): void { $this->assertInstanceOf(AMQPSSLConnection::class, $this->connection()->getChannel()->getConnection()); } diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php index 16fd5faa..7d0fab9a 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/TestCase.php @@ -17,7 +17,7 @@ abstract class TestCase extends BaseTestCase /** * @throws AMQPProtocolChannelException */ - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -40,17 +40,17 @@ protected function tearDown(): void parent::tearDown(); } - public function testSizeDoesNotThrowExceptionOnUnknownQueue(): void + public function test_size_does_not_throw_exception_on_unknown_queue(): void { $this->assertEmpty(0, Queue::size(Str::random())); } - public function testPopNothing(): void + public function test_pop_nothing(): void { $this->assertNull(Queue::pop('foo')); } - public function testPushRaw(): void + public function test_push_raw(): void { Queue::pushRaw($payload = Str::random()); @@ -68,9 +68,9 @@ public function testPushRaw(): void $this->assertSame(0, Queue::size()); } - public function testPush(): void + public function test_push(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); sleep(1); @@ -95,7 +95,7 @@ public function testPush(): void $this->assertSame(0, Queue::size()); } - public function testPushAfterCommit(): void + public function test_push_after_commit(): void { $transaction = new DatabaseTransactionsManager; @@ -122,7 +122,7 @@ public function testPushAfterCommit(): void $this->assertSame(0, Queue::size()); } - public function testLaterRaw(): void + public function test_later_raw(): void { $payload = Str::random(); $data = [Str::random() => Str::random()]; @@ -152,9 +152,9 @@ public function testLaterRaw(): void $this->assertSame(0, Queue::size()); } - public function testLater(): void + public function test_later(): void { - Queue::later(3, new TestJob()); + Queue::later(3, new TestJob); sleep(1); @@ -179,7 +179,7 @@ public function testLater(): void $this->assertSame(0, Queue::size()); } - public function testBulk(): void + public function test_bulk(): void { $count = 100; $jobs = []; @@ -195,9 +195,9 @@ public function testBulk(): void $this->assertSame($count, Queue::size()); } - public function testPushEncrypted(): void + public function test_push_encrypted(): void { - Queue::push(new TestEncryptedJob()); + Queue::push(new TestEncryptedJob); sleep(1); @@ -222,7 +222,7 @@ public function testPushEncrypted(): void $this->assertSame(0, Queue::size()); } - public function testPushEncryptedAfterCommit(): void + public function test_push_encrypted_after_commit(): void { $transaction = new DatabaseTransactionsManager; @@ -249,9 +249,9 @@ public function testPushEncryptedAfterCommit(): void $this->assertSame(0, Queue::size()); } - public function testEncryptedLater(): void + public function test_encrypted_later(): void { - Queue::later(3, new TestEncryptedJob()); + Queue::later(3, new TestEncryptedJob); sleep(1); @@ -276,7 +276,7 @@ public function testEncryptedLater(): void $this->assertSame(0, Queue::size()); } - public function testEncryptedBulk(): void + public function test_encrypted_bulk(): void { $count = 100; $jobs = []; @@ -292,7 +292,7 @@ public function testEncryptedBulk(): void $this->assertSame($count, Queue::size()); } - public function testReleaseRaw(): void + public function test_release_raw(): void { Queue::pushRaw($payload = Str::random()); @@ -318,9 +318,9 @@ public function testReleaseRaw(): void $this->assertSame(0, Queue::size()); } - public function testRelease(): void + public function test_release(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); sleep(1); @@ -344,7 +344,7 @@ public function testRelease(): void $this->assertSame(0, Queue::size()); } - public function testReleaseWithDelayRaw(): void + public function test_release_with_delay_raw(): void { Queue::pushRaw($payload = Str::random()); @@ -375,9 +375,9 @@ public function testReleaseWithDelayRaw(): void $this->assertSame(0, Queue::size()); } - public function testReleaseInThePast(): void + public function test_release_in_the_past(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); $job = Queue::pop(); $job->release(-3); @@ -390,9 +390,9 @@ public function testReleaseInThePast(): void $this->assertSame(0, Queue::size()); } - public function testReleaseAndReleaseWithDelayAttempts(): void + public function test_release_and_release_with_delay_attempts(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); sleep(1); @@ -417,9 +417,9 @@ public function testReleaseAndReleaseWithDelayAttempts(): void $this->assertSame(0, Queue::size()); } - public function testDelete(): void + public function test_delete(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); $job = Queue::pop(); @@ -431,9 +431,9 @@ public function testDelete(): void $this->assertNull(Queue::pop()); } - public function testFailed(): void + public function test_failed(): void { - Queue::push(new TestJob()); + Queue::push(new TestJob); $job = Queue::pop(); diff --git a/tests/Functional/RabbitMQQueueTest.php b/tests/Functional/RabbitMQQueueTest.php index 7a106a08..21a2e1d4 100644 --- a/tests/Functional/RabbitMQQueueTest.php +++ b/tests/Functional/RabbitMQQueueTest.php @@ -9,7 +9,7 @@ class RabbitMQQueueTest extends BaseTestCase { - public function testConnection(): void + public function test_connection(): void { $queue = $this->connection(); $this->assertInstanceOf(RabbitMQQueue::class, $queue); @@ -21,7 +21,7 @@ public function testConnection(): void $this->assertInstanceOf(RabbitMQQueue::class, $queue); } - public function testConfigRerouteFailed(): void + public function test_config_reroute_failed(): void { $queue = $this->connection(); $this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed()); @@ -36,7 +36,7 @@ public function testConfigRerouteFailed(): void $this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed()); } - public function testConfigPrioritizeDelayed(): void + public function test_config_prioritize_delayed(): void { $queue = $this->connection(); $this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed()); @@ -51,7 +51,7 @@ public function testConfigPrioritizeDelayed(): void $this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed()); } - public function testQueueMaxPriority(): void + public function test_queue_max_priority(): void { $queue = $this->connection(); $this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority()); @@ -70,7 +70,7 @@ public function testQueueMaxPriority(): void $this->assertSame(2, $this->callProperty($queue, 'config')->getQueueMaxPriority()); } - public function testConfigExchangeType(): void + public function test_config_exchange_type(): void { $queue = $this->connection(); $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); @@ -87,12 +87,12 @@ public function testConfigExchangeType(): void $queue = $this->connection('rabbitmq-with-options-null'); $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); - //testing an unkown type with a default + // testing an unkown type with a default $this->callProperty($queue, 'config')->setExchangeType('unknown'); $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); } - public function testExchange(): void + public function test_exchange(): void { $queue = $this->connection(); $this->assertSame('test', $this->callMethod($queue, 'getExchange', ['test'])); @@ -119,7 +119,7 @@ public function testExchange(): void $this->assertSame('', $this->callMethod($queue, 'getExchange', [''])); } - public function testFailedExchange(): void + public function test_failed_exchange(): void { $queue = $this->connection(); $this->assertSame('test', $this->callMethod($queue, 'getFailedExchange', ['test'])); @@ -146,7 +146,7 @@ public function testFailedExchange(): void $this->assertSame('', $this->callMethod($queue, 'getFailedExchange', [''])); } - public function testRoutingKey(): void + public function test_routing_key(): void { $queue = $this->connection(); $this->assertSame('test', $this->callMethod($queue, 'getRoutingKey', ['test'])); @@ -165,7 +165,7 @@ public function testRoutingKey(): void $this->assertSame('an.alternate.routing-key', $this->callMethod($queue, 'getRoutingKey', ['test'])); } - public function testFailedRoutingKey(): void + public function test_failed_routing_key(): void { $queue = $this->connection(); $this->assertSame('test.failed', $this->callMethod($queue, 'getFailedRoutingKey', ['test'])); @@ -184,7 +184,7 @@ public function testFailedRoutingKey(): void $this->assertSame('an.alternate.routing-key', $this->callMethod($queue, 'getFailedRoutingKey', ['test'])); } - public function testConfigQuorum(): void + public function test_config_quorum(): void { $queue = $this->connection(); $this->assertFalse($this->callProperty($queue, 'config')->isQuorum()); @@ -202,7 +202,7 @@ public function testConfigQuorum(): void $this->assertTrue($this->callProperty($queue, 'config')->isQuorum()); } - public function testDeclareDeleteExchange(): void + public function test_declare_delete_exchange(): void { $queue = $this->connection(); @@ -217,7 +217,7 @@ public function testDeclareDeleteExchange(): void $this->assertFalse($queue->isExchangeExists($name)); } - public function testDeclareDeleteQueue(): void + public function test_declare_delete_queue(): void { $queue = $this->connection(); @@ -232,7 +232,7 @@ public function testDeclareDeleteQueue(): void $this->assertFalse($queue->isQueueExists($name)); } - public function testQueueArguments(): void + public function test_queue_arguments(): void { $name = Str::random(); @@ -272,7 +272,7 @@ public function testQueueArguments(): void $this->assertEquals(array_values($expected), array_values($actual)); } - public function testDelayQueueArguments(): void + public function test_delay_queue_arguments(): void { $name = Str::random(); $ttl = 12000; diff --git a/tests/Functional/TestCase.php b/tests/Functional/TestCase.php index 8b843561..b21aeaf8 100644 --- a/tests/Functional/TestCase.php +++ b/tests/Functional/TestCase.php @@ -236,7 +236,7 @@ protected function callProperty($object, string $property): mixed return $property->getValue($object); } - public function testConnectChannel(): void + public function test_connect_channel(): void { $queue = $this->connection(); $this->assertFalse($queue->getConnection()->isConnected()); @@ -248,7 +248,7 @@ public function testConnectChannel(): void $this->assertTrue($channel->is_open()); } - public function testReconnect(): void + public function test_reconnect(): void { $queue = $this->connection(); $this->assertFalse($queue->getConnection()->isConnected()); From 9c5fa17a0aa0d175d4849703553997b6edb72613 Mon Sep 17 00:00:00 2001 From: Samuel Fontebasso Date: Sun, 20 Apr 2025 02:01:38 -0300 Subject: [PATCH 52/58] fix: remove manual docker-compose v1 install to prevent CI failure on ubuntu-latest --- .github/workflows/tests.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fccb0608..0da38f44 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -33,15 +33,8 @@ jobs: extensions: dom, curl, libxml, mbstring, zip coverage: none - - name: Set up Docker - run: | - sudo rm /usr/local/bin/docker-compose - curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` > docker-compose - chmod +x docker-compose - sudo mv docker-compose /usr/local/bin - - name: Start Docker container - run: docker-compose up -d rabbitmq + run: docker compose up -d rabbitmq - name: Install dependencies run: composer update --with='laravel/framework:${{matrix.laravel}}' --${{ matrix.stability }} --prefer-dist --no-interaction --no-progress From e69dd13ebfde40ae6993ee977e67ca22bd3e9609 Mon Sep 17 00:00:00 2001 From: Samuel Fontebasso Date: Mon, 21 Apr 2025 15:28:51 -0300 Subject: [PATCH 53/58] feat: add Laravel 12 support and fix test connection by disabling SSL verify_peer --- .github/workflows/tests.yml | 4 +++- composer.json | 6 +++--- tests/TestCase.php | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0da38f44..d0588c10 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,10 +15,12 @@ jobs: matrix: php: ['8.1', '8.2', '8.3'] stability: ['prefer-lowest', 'prefer-stable'] - laravel: ['^10.0', '^11.0'] + laravel: ['^10.0', '^11.0', '^12.0'] exclude: - php: '8.1' laravel: '^11.0' + - php: '8.1' + laravel: '^12.0' name: 'PHP ${{ matrix.php }} - Laravel: ${{matrix.laravel}} - ${{ matrix.stability }}' diff --git a/composer.json b/composer.json index 1a91d725..caf8a0fc 100644 --- a/composer.json +++ b/composer.json @@ -11,16 +11,16 @@ "require": { "php": "^8.0", "ext-json": "*", - "illuminate/queue": "^10.0|^11.0", + "illuminate/queue": "^10.0|^11.0|^12.0", "php-amqplib/php-amqplib": "^v3.6" }, "require-dev": { "phpunit/phpunit": "^10.0|^11.0", "mockery/mockery": "^1.0", "laravel/horizon": "^5.0", - "orchestra/testbench": "^7.0|^8.0|^9.0", + "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", "laravel/pint": "^1.2", - "laravel/framework": "^9.0|^10.0|^11.0" + "laravel/framework": "^9.0|^10.0|^11.0|^12.0" }, "autoload": { "psr-4": { diff --git a/tests/TestCase.php b/tests/TestCase.php index 7d50fa67..f3f0705d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -40,7 +40,7 @@ protected function getEnvironmentSetUp($app): void 'cafile' => null, 'local_cert' => null, 'local_key' => null, - 'verify_peer' => true, + 'verify_peer' => false, 'passphrase' => null, ], ], From 6faa83ac6554a0b8340756c7ffee0f7b68741cd7 Mon Sep 17 00:00:00 2001 From: Samuel Fontebasso Date: Mon, 21 Apr 2025 17:02:52 -0300 Subject: [PATCH 54/58] feat: add --json flag to rabbitmq:consume and align option order with WorkCommand --- src/Console/ConsumeCommand.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Console/ConsumeCommand.php b/src/Console/ConsumeCommand.php index 50aab1d4..4072132a 100644 --- a/src/Console/ConsumeCommand.php +++ b/src/Console/ConsumeCommand.php @@ -21,9 +21,10 @@ class ConsumeCommand extends WorkCommand {--force : Force the worker to run even in maintenance mode} {--memory=128 : The memory limit in megabytes} {--sleep=3 : Number of seconds to sleep when no job is available} + {--rest=0 : Number of seconds to rest between jobs} {--timeout=60 : The number of seconds a child process can run} {--tries=1 : Number of times to attempt a job before logging it failed} - {--rest=0 : Number of seconds to rest between jobs} + {--json : Output the queue worker information as JSON} {--max-priority=} {--consumer-tag} From 4717111a1e3f7e70cc0e43e7752a5720fdd86207 Mon Sep 17 00:00:00 2001 From: Samuel Fontebasso Date: Wed, 30 Apr 2025 21:58:45 -0300 Subject: [PATCH 55/58] chore(ci): add PHP 8.4 to test matrix --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d0588c10..4aad6d20 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.1', '8.2', '8.3'] + php: ['8.1', '8.2', '8.3', '8.4'] stability: ['prefer-lowest', 'prefer-stable'] laravel: ['^10.0', '^11.0', '^12.0'] exclude: From e82de4ceef0ab3ddf5f4aaaa2816ea4c2dc49ef5 Mon Sep 17 00:00:00 2001 From: Samuel Fontebasso Date: Wed, 30 Apr 2025 22:24:44 -0300 Subject: [PATCH 56/58] style: rename PHPUnit test methods to camelCase --- pint.json | 2 +- tests/Feature/ConnectorTest.php | 8 +++--- tests/Feature/QueueTest.php | 4 +-- tests/Feature/SslQueueTest.php | 2 +- tests/Feature/TestCase.php | 38 +++++++++++++------------- tests/Functional/RabbitMQQueueTest.php | 28 +++++++++---------- tests/Functional/TestCase.php | 4 +-- 7 files changed, 43 insertions(+), 43 deletions(-) diff --git a/pint.json b/pint.json index 029010c0..05f4b41e 100644 --- a/pint.json +++ b/pint.json @@ -2,7 +2,7 @@ "preset": "laravel", "rules": { "php_unit_method_casing": { - "case": "camel_case" + "case": "camel_case" } } } diff --git a/tests/Feature/ConnectorTest.php b/tests/Feature/ConnectorTest.php index f4e330c3..91660ad2 100644 --- a/tests/Feature/ConnectorTest.php +++ b/tests/Feature/ConnectorTest.php @@ -12,7 +12,7 @@ class ConnectorTest extends \VladimirYuldashev\LaravelQueueRabbitMQ\Tests\TestCase { - public function test_lazy_connection(): void + public function testLazyConnection(): void { $this->app['config']->set('queue.connections.rabbitmq', [ 'driver' => 'rabbitmq', @@ -55,7 +55,7 @@ public function test_lazy_connection(): void $this->assertTrue($connection->getConnection()->isConnected()); } - public function test_lazy_stream_connection(): void + public function testLazyStreamConnection(): void { $this->app['config']->set('queue.connections.rabbitmq', [ 'driver' => 'rabbitmq', @@ -98,7 +98,7 @@ public function test_lazy_stream_connection(): void $this->assertTrue($connection->getConnection()->isConnected()); } - public function test_ssl_connection(): void + public function testSslConnection(): void { $this->markTestSkipped(); @@ -142,7 +142,7 @@ public function test_ssl_connection(): void } // Test to validate ssl connection params - public function test_no_verification_ssl_connection(): void + public function testNoVerificationSslConnection(): void { $this->app['config']->set('queue.connections.rabbitmq', [ 'driver' => 'rabbitmq', diff --git a/tests/Feature/QueueTest.php b/tests/Feature/QueueTest.php index 609a48d8..ee324c9a 100644 --- a/tests/Feature/QueueTest.php +++ b/tests/Feature/QueueTest.php @@ -20,12 +20,12 @@ protected function setUp(): void ]); } - public function test_connection(): void + public function testConnection(): void { $this->assertInstanceOf(AMQPStreamConnection::class, $this->connection()->getChannel()->getConnection()); } - public function test_without_reconnect(): void + public function testWithoutReconnect(): void { $queue = $this->connection('rabbitmq'); diff --git a/tests/Feature/SslQueueTest.php b/tests/Feature/SslQueueTest.php index 53cf5d38..02181c96 100644 --- a/tests/Feature/SslQueueTest.php +++ b/tests/Feature/SslQueueTest.php @@ -43,7 +43,7 @@ protected function getEnvironmentSetUp($app): void ]); } - public function test_connection(): void + public function testConnection(): void { $this->assertInstanceOf(AMQPSSLConnection::class, $this->connection()->getChannel()->getConnection()); } diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php index 7d0fab9a..5afda85d 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/TestCase.php @@ -40,17 +40,17 @@ protected function tearDown(): void parent::tearDown(); } - public function test_size_does_not_throw_exception_on_unknown_queue(): void + public function testSizeDoesNotThrowExceptionOnUnknownQueue(): void { $this->assertEmpty(0, Queue::size(Str::random())); } - public function test_pop_nothing(): void + public function testPopNothing(): void { $this->assertNull(Queue::pop('foo')); } - public function test_push_raw(): void + public function testPushRaw(): void { Queue::pushRaw($payload = Str::random()); @@ -68,7 +68,7 @@ public function test_push_raw(): void $this->assertSame(0, Queue::size()); } - public function test_push(): void + public function testPush(): void { Queue::push(new TestJob); @@ -95,7 +95,7 @@ public function test_push(): void $this->assertSame(0, Queue::size()); } - public function test_push_after_commit(): void + public function testPushAfterCommit(): void { $transaction = new DatabaseTransactionsManager; @@ -122,7 +122,7 @@ public function test_push_after_commit(): void $this->assertSame(0, Queue::size()); } - public function test_later_raw(): void + public function testLaterRaw(): void { $payload = Str::random(); $data = [Str::random() => Str::random()]; @@ -152,7 +152,7 @@ public function test_later_raw(): void $this->assertSame(0, Queue::size()); } - public function test_later(): void + public function testLater(): void { Queue::later(3, new TestJob); @@ -179,7 +179,7 @@ public function test_later(): void $this->assertSame(0, Queue::size()); } - public function test_bulk(): void + public function testBulk(): void { $count = 100; $jobs = []; @@ -195,7 +195,7 @@ public function test_bulk(): void $this->assertSame($count, Queue::size()); } - public function test_push_encrypted(): void + public function testPushEncrypted(): void { Queue::push(new TestEncryptedJob); @@ -222,7 +222,7 @@ public function test_push_encrypted(): void $this->assertSame(0, Queue::size()); } - public function test_push_encrypted_after_commit(): void + public function testPushEncryptedAfterCommit(): void { $transaction = new DatabaseTransactionsManager; @@ -249,7 +249,7 @@ public function test_push_encrypted_after_commit(): void $this->assertSame(0, Queue::size()); } - public function test_encrypted_later(): void + public function testEncryptedLater(): void { Queue::later(3, new TestEncryptedJob); @@ -276,7 +276,7 @@ public function test_encrypted_later(): void $this->assertSame(0, Queue::size()); } - public function test_encrypted_bulk(): void + public function testEncryptedBulk(): void { $count = 100; $jobs = []; @@ -292,7 +292,7 @@ public function test_encrypted_bulk(): void $this->assertSame($count, Queue::size()); } - public function test_release_raw(): void + public function testReleaseRaw(): void { Queue::pushRaw($payload = Str::random()); @@ -318,7 +318,7 @@ public function test_release_raw(): void $this->assertSame(0, Queue::size()); } - public function test_release(): void + public function testRelease(): void { Queue::push(new TestJob); @@ -344,7 +344,7 @@ public function test_release(): void $this->assertSame(0, Queue::size()); } - public function test_release_with_delay_raw(): void + public function testReleaseWithDelayRaw(): void { Queue::pushRaw($payload = Str::random()); @@ -375,7 +375,7 @@ public function test_release_with_delay_raw(): void $this->assertSame(0, Queue::size()); } - public function test_release_in_the_past(): void + public function testReleaseInThePast(): void { Queue::push(new TestJob); @@ -390,7 +390,7 @@ public function test_release_in_the_past(): void $this->assertSame(0, Queue::size()); } - public function test_release_and_release_with_delay_attempts(): void + public function testReleaseAndReleaseWithDelayAttempts(): void { Queue::push(new TestJob); @@ -417,7 +417,7 @@ public function test_release_and_release_with_delay_attempts(): void $this->assertSame(0, Queue::size()); } - public function test_delete(): void + public function testDelete(): void { Queue::push(new TestJob); @@ -431,7 +431,7 @@ public function test_delete(): void $this->assertNull(Queue::pop()); } - public function test_failed(): void + public function testFailed(): void { Queue::push(new TestJob); diff --git a/tests/Functional/RabbitMQQueueTest.php b/tests/Functional/RabbitMQQueueTest.php index 21a2e1d4..1c5d94fb 100644 --- a/tests/Functional/RabbitMQQueueTest.php +++ b/tests/Functional/RabbitMQQueueTest.php @@ -9,7 +9,7 @@ class RabbitMQQueueTest extends BaseTestCase { - public function test_connection(): void + public function testConnection(): void { $queue = $this->connection(); $this->assertInstanceOf(RabbitMQQueue::class, $queue); @@ -21,7 +21,7 @@ public function test_connection(): void $this->assertInstanceOf(RabbitMQQueue::class, $queue); } - public function test_config_reroute_failed(): void + public function testConfigRerouteFailed(): void { $queue = $this->connection(); $this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed()); @@ -36,7 +36,7 @@ public function test_config_reroute_failed(): void $this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed()); } - public function test_config_prioritize_delayed(): void + public function testConfigPrioritizeDelayed(): void { $queue = $this->connection(); $this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed()); @@ -51,7 +51,7 @@ public function test_config_prioritize_delayed(): void $this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed()); } - public function test_queue_max_priority(): void + public function testQueueMaxPriority(): void { $queue = $this->connection(); $this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority()); @@ -70,7 +70,7 @@ public function test_queue_max_priority(): void $this->assertSame(2, $this->callProperty($queue, 'config')->getQueueMaxPriority()); } - public function test_config_exchange_type(): void + public function testConfigExchangeType(): void { $queue = $this->connection(); $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); @@ -92,7 +92,7 @@ public function test_config_exchange_type(): void $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); } - public function test_exchange(): void + public function testExchange(): void { $queue = $this->connection(); $this->assertSame('test', $this->callMethod($queue, 'getExchange', ['test'])); @@ -119,7 +119,7 @@ public function test_exchange(): void $this->assertSame('', $this->callMethod($queue, 'getExchange', [''])); } - public function test_failed_exchange(): void + public function testFailedExchange(): void { $queue = $this->connection(); $this->assertSame('test', $this->callMethod($queue, 'getFailedExchange', ['test'])); @@ -146,7 +146,7 @@ public function test_failed_exchange(): void $this->assertSame('', $this->callMethod($queue, 'getFailedExchange', [''])); } - public function test_routing_key(): void + public function testRoutingKey(): void { $queue = $this->connection(); $this->assertSame('test', $this->callMethod($queue, 'getRoutingKey', ['test'])); @@ -165,7 +165,7 @@ public function test_routing_key(): void $this->assertSame('an.alternate.routing-key', $this->callMethod($queue, 'getRoutingKey', ['test'])); } - public function test_failed_routing_key(): void + public function testFailedRoutingKey(): void { $queue = $this->connection(); $this->assertSame('test.failed', $this->callMethod($queue, 'getFailedRoutingKey', ['test'])); @@ -184,7 +184,7 @@ public function test_failed_routing_key(): void $this->assertSame('an.alternate.routing-key', $this->callMethod($queue, 'getFailedRoutingKey', ['test'])); } - public function test_config_quorum(): void + public function testConfigQuorum(): void { $queue = $this->connection(); $this->assertFalse($this->callProperty($queue, 'config')->isQuorum()); @@ -202,7 +202,7 @@ public function test_config_quorum(): void $this->assertTrue($this->callProperty($queue, 'config')->isQuorum()); } - public function test_declare_delete_exchange(): void + public function testDeclareDeleteExchange(): void { $queue = $this->connection(); @@ -217,7 +217,7 @@ public function test_declare_delete_exchange(): void $this->assertFalse($queue->isExchangeExists($name)); } - public function test_declare_delete_queue(): void + public function testDeclareDeleteQueue(): void { $queue = $this->connection(); @@ -232,7 +232,7 @@ public function test_declare_delete_queue(): void $this->assertFalse($queue->isQueueExists($name)); } - public function test_queue_arguments(): void + public function testQueueArguments(): void { $name = Str::random(); @@ -272,7 +272,7 @@ public function test_queue_arguments(): void $this->assertEquals(array_values($expected), array_values($actual)); } - public function test_delay_queue_arguments(): void + public function testDelayQueueArguments(): void { $name = Str::random(); $ttl = 12000; diff --git a/tests/Functional/TestCase.php b/tests/Functional/TestCase.php index b21aeaf8..8b843561 100644 --- a/tests/Functional/TestCase.php +++ b/tests/Functional/TestCase.php @@ -236,7 +236,7 @@ protected function callProperty($object, string $property): mixed return $property->getValue($object); } - public function test_connect_channel(): void + public function testConnectChannel(): void { $queue = $this->connection(); $this->assertFalse($queue->getConnection()->isConnected()); @@ -248,7 +248,7 @@ public function test_connect_channel(): void $this->assertTrue($channel->is_open()); } - public function test_reconnect(): void + public function testReconnect(): void { $queue = $this->connection(); $this->assertFalse($queue->getConnection()->isConnected()); From b6c9fa88170b02725d7606192dc676e7bb36e32a Mon Sep 17 00:00:00 2001 From: Frederik Sauer Date: Tue, 21 Oct 2025 09:07:19 +0200 Subject: [PATCH 57/58] Fix compatibility with Laravel 12.34 --- src/Queue/RabbitMQQueue.php | 32 ++++++++--------- tests/Functional/RabbitMQQueueTest.php | 48 +++++++++++++------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/Queue/RabbitMQQueue.php b/src/Queue/RabbitMQQueue.php index fadedce5..04377a0d 100644 --- a/src/Queue/RabbitMQQueue.php +++ b/src/Queue/RabbitMQQueue.php @@ -62,14 +62,14 @@ class RabbitMQQueue extends Queue implements QueueContract, RabbitMQQueueContrac /** * Holds the Configuration */ - protected QueueConfig $config; + protected QueueConfig $rabbitMQConfig; /** * RabbitMQQueue constructor. */ public function __construct(QueueConfig $config) { - $this->config = $config; + $this->rabbitMQConfig = $config; $this->dispatchAfterCommit = $config->isDispatchAfterCommit(); } @@ -293,7 +293,7 @@ public function setConnection(AbstractConnection $connection): RabbitMQQueue */ public function getJobClass(): string { - $job = $this->getConfig()->getAbstractJob(); + $job = $this->getRabbitMQConfig()->getAbstractJob(); throw_if( ! is_a($job, RabbitMQJob::class, true), @@ -309,7 +309,7 @@ public function getJobClass(): string */ public function getQueue($queue = null): string { - return $queue ?: $this->getConfig()->getQueue(); + return $queue ?: $this->getRabbitMQConfig()->getQueue(); } /** @@ -523,7 +523,7 @@ protected function createMessage($payload, int $attempts = 0): array $properties['correlation_id'] = $correlationId; } - if ($this->getConfig()->isPrioritizeDelayed()) { + if ($this->getRabbitMQConfig()->isPrioritizeDelayed()) { $properties['priority'] = $attempts; } @@ -605,16 +605,16 @@ protected function getQueueArguments(string $destination): array // Messages with a priority which is higher than the queue's maximum, are treated as if they were // published with the maximum priority. // Quorum queues does not support priority. - if ($this->getConfig()->isPrioritizeDelayed() && ! $this->getConfig()->isQuorum()) { - $arguments['x-max-priority'] = $this->getConfig()->getQueueMaxPriority(); + if ($this->getRabbitMQConfig()->isPrioritizeDelayed() && ! $this->getRabbitMQConfig()->isQuorum()) { + $arguments['x-max-priority'] = $this->getRabbitMQConfig()->getQueueMaxPriority(); } - if ($this->getConfig()->isRerouteFailed()) { + if ($this->getRabbitMQConfig()->isRerouteFailed()) { $arguments['x-dead-letter-exchange'] = $this->getFailedExchange(); $arguments['x-dead-letter-routing-key'] = $this->getFailedRoutingKey($destination); } - if ($this->getConfig()->isQuorum()) { + if ($this->getRabbitMQConfig()->isQuorum()) { $arguments['x-queue-type'] = 'quorum'; } @@ -639,7 +639,7 @@ protected function getDelayQueueArguments(string $destination, int $ttl): array */ protected function getExchange(?string $exchange = null): string { - return $exchange ?? $this->getConfig()->getExchange(); + return $exchange ?? $this->getRabbitMQConfig()->getExchange(); } /** @@ -648,7 +648,7 @@ protected function getExchange(?string $exchange = null): string */ protected function getRoutingKey(string $destination): string { - return ltrim(sprintf($this->getConfig()->getExchangeRoutingKey(), $destination), '.'); + return ltrim(sprintf($this->getRabbitMQConfig()->getExchangeRoutingKey(), $destination), '.'); } /** @@ -656,7 +656,7 @@ protected function getRoutingKey(string $destination): string */ protected function getExchangeType(?string $type = null): string { - $constant = AMQPExchangeType::class.'::'.Str::upper($type ?: $this->getConfig()->getExchangeType()); + $constant = AMQPExchangeType::class.'::'.Str::upper($type ?: $this->getRabbitMQConfig()->getExchangeType()); return defined($constant) ? constant($constant) : AMQPExchangeType::DIRECT; } @@ -666,7 +666,7 @@ protected function getExchangeType(?string $type = null): string */ protected function getFailedExchange(?string $exchange = null): string { - return $exchange ?? $this->getConfig()->getFailedExchange(); + return $exchange ?? $this->getRabbitMQConfig()->getFailedExchange(); } /** @@ -675,7 +675,7 @@ protected function getFailedExchange(?string $exchange = null): string */ protected function getFailedRoutingKey(string $destination): string { - return ltrim(sprintf($this->getConfig()->getFailedRoutingKey(), $destination), '.'); + return ltrim(sprintf($this->getRabbitMQConfig()->getFailedRoutingKey(), $destination), '.'); } /** @@ -735,9 +735,9 @@ protected function publishProperties($queue, array $options = []): array return [$destination, $exchange, $exchangeType, $attempts]; } - protected function getConfig(): QueueConfig + protected function getRabbitMQConfig(): QueueConfig { - return $this->config; + return $this->rabbitMQConfig; } /** diff --git a/tests/Functional/RabbitMQQueueTest.php b/tests/Functional/RabbitMQQueueTest.php index 21a2e1d4..e190f3f0 100644 --- a/tests/Functional/RabbitMQQueueTest.php +++ b/tests/Functional/RabbitMQQueueTest.php @@ -24,50 +24,50 @@ public function test_connection(): void public function test_config_reroute_failed(): void { $queue = $this->connection(); - $this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isRerouteFailed()); $queue = $this->connection('rabbitmq-with-options'); - $this->assertTrue($this->callProperty($queue, 'config')->isRerouteFailed()); + $this->assertTrue($this->callProperty($queue, 'rabbitMQConfig')->isRerouteFailed()); $queue = $this->connection('rabbitmq-with-options-empty'); - $this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isRerouteFailed()); $queue = $this->connection('rabbitmq-with-options-null'); - $this->assertFalse($this->callProperty($queue, 'config')->isRerouteFailed()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isRerouteFailed()); } public function test_config_prioritize_delayed(): void { $queue = $this->connection(); - $this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isPrioritizeDelayed()); $queue = $this->connection('rabbitmq-with-options'); - $this->assertTrue($this->callProperty($queue, 'config')->isPrioritizeDelayed()); + $this->assertTrue($this->callProperty($queue, 'rabbitMQConfig')->isPrioritizeDelayed()); $queue = $this->connection('rabbitmq-with-options-empty'); - $this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isPrioritizeDelayed()); $queue = $this->connection('rabbitmq-with-options-null'); - $this->assertFalse($this->callProperty($queue, 'config')->isPrioritizeDelayed()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isPrioritizeDelayed()); } public function test_queue_max_priority(): void { $queue = $this->connection(); - $this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority()); - $this->assertSame(2, $this->callProperty($queue, 'config')->getQueueMaxPriority()); + $this->assertIsInt($this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority()); + $this->assertSame(2, $this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority()); $queue = $this->connection('rabbitmq-with-options'); - $this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority()); - $this->assertSame(20, $this->callProperty($queue, 'config')->getQueueMaxPriority()); + $this->assertIsInt($this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority()); + $this->assertSame(20, $this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority()); $queue = $this->connection('rabbitmq-with-options-empty'); - $this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority()); - $this->assertSame(2, $this->callProperty($queue, 'config')->getQueueMaxPriority()); + $this->assertIsInt($this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority()); + $this->assertSame(2, $this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority()); $queue = $this->connection('rabbitmq-with-options-null'); - $this->assertIsInt($this->callProperty($queue, 'config')->getQueueMaxPriority()); - $this->assertSame(2, $this->callProperty($queue, 'config')->getQueueMaxPriority()); + $this->assertIsInt($this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority()); + $this->assertSame(2, $this->callProperty($queue, 'rabbitMQConfig')->getQueueMaxPriority()); } public function test_config_exchange_type(): void @@ -88,7 +88,7 @@ public function test_config_exchange_type(): void $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); // testing an unkown type with a default - $this->callProperty($queue, 'config')->setExchangeType('unknown'); + $this->callProperty($queue, 'rabbitMQConfig')->setExchangeType('unknown'); $this->assertSame(AMQPExchangeType::DIRECT, $this->callMethod($queue, 'getExchangeType')); } @@ -161,7 +161,7 @@ public function test_routing_key(): void $queue = $this->connection('rabbitmq-with-options-null'); $this->assertSame('test', $this->callMethod($queue, 'getRoutingKey', ['test'])); - $this->callProperty($queue, 'config')->setExchangeRoutingKey('.an.alternate.routing-key'); + $this->callProperty($queue, 'rabbitMQConfig')->setExchangeRoutingKey('.an.alternate.routing-key'); $this->assertSame('an.alternate.routing-key', $this->callMethod($queue, 'getRoutingKey', ['test'])); } @@ -180,26 +180,26 @@ public function test_failed_routing_key(): void $queue = $this->connection('rabbitmq-with-options-null'); $this->assertSame('test.failed', $this->callMethod($queue, 'getFailedRoutingKey', ['test'])); - $this->callProperty($queue, 'config')->setFailedRoutingKey('.an.alternate.routing-key'); + $this->callProperty($queue, 'rabbitMQConfig')->setFailedRoutingKey('.an.alternate.routing-key'); $this->assertSame('an.alternate.routing-key', $this->callMethod($queue, 'getFailedRoutingKey', ['test'])); } public function test_config_quorum(): void { $queue = $this->connection(); - $this->assertFalse($this->callProperty($queue, 'config')->isQuorum()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isQuorum()); $queue = $this->connection('rabbitmq-with-options'); - $this->assertFalse($this->callProperty($queue, 'config')->isQuorum()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isQuorum()); $queue = $this->connection('rabbitmq-with-options-empty'); - $this->assertFalse($this->callProperty($queue, 'config')->isQuorum()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isQuorum()); $queue = $this->connection('rabbitmq-with-options-null'); - $this->assertFalse($this->callProperty($queue, 'config')->isQuorum()); + $this->assertFalse($this->callProperty($queue, 'rabbitMQConfig')->isQuorum()); $queue = $this->connection('rabbitmq-with-quorum-options'); - $this->assertTrue($this->callProperty($queue, 'config')->isQuorum()); + $this->assertTrue($this->callProperty($queue, 'rabbitMQConfig')->isQuorum()); } public function test_declare_delete_exchange(): void From faa8307cb45ff8079627c2a9b0c20f0f20319e94 Mon Sep 17 00:00:00 2001 From: Frederik Sauer Date: Tue, 11 Nov 2025 15:16:02 +0100 Subject: [PATCH 58/58] Properly handle skipped tests --- .gitignore | 2 +- tests/Feature/SslQueueTest.php | 4 ++++ tests/Feature/TestCase.php | 21 +++++++++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 00dea824..a2dcf885 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ composer.lock .phpstorm.meta.php phpunit.xml -.phpunit.result.cache +.phpunit.* .php_cs.cache diff --git a/tests/Feature/SslQueueTest.php b/tests/Feature/SslQueueTest.php index 02181c96..11c93f5a 100644 --- a/tests/Feature/SslQueueTest.php +++ b/tests/Feature/SslQueueTest.php @@ -6,8 +6,12 @@ class SslQueueTest extends TestCase { + protected bool $interactsWithConnection = false; + protected function setUp(): void { + parent::setUp(); + $this->markTestSkipped(); } diff --git a/tests/Feature/TestCase.php b/tests/Feature/TestCase.php index 5afda85d..f8a9cb05 100644 --- a/tests/Feature/TestCase.php +++ b/tests/Feature/TestCase.php @@ -14,6 +14,11 @@ abstract class TestCase extends BaseTestCase { + /** + * Set to false for skipped tests. + */ + protected bool $interactsWithConnection = true; + /** * @throws AMQPProtocolChannelException */ @@ -21,8 +26,10 @@ protected function setUp(): void { parent::setUp(); - if ($this->connection()->isQueueExists()) { - $this->connection()->purge(); + if ($this->interactsWithConnection) { + if ($this->connection()->isQueueExists()) { + $this->connection()->purge(); + } } } @@ -31,11 +38,13 @@ protected function setUp(): void */ protected function tearDown(): void { - if ($this->connection()->isQueueExists()) { - $this->connection()->purge(); - } + if ($this->interactsWithConnection) { + if ($this->connection()->isQueueExists()) { + $this->connection()->purge(); + } - self::assertSame(0, Queue::size()); + self::assertSame(0, Queue::size()); + } parent::tearDown(); }