From b6c9fa88170b02725d7606192dc676e7bb36e32a Mon Sep 17 00:00:00 2001 From: Frederik Sauer Date: Tue, 21 Oct 2025 09:07:19 +0200 Subject: [PATCH 1/2] 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 2/2] 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(); }