From 0c98390e88b7eee81ba7842d69fea1bd172cc58a Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Mon, 28 Dec 2020 11:40:08 +0200 Subject: [PATCH 01/20] [php8][travis] Removed old php ^7 builds as this major release will support only php8 --- .travis.yml | 47 ++--------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7c3c68762..3b0eba86c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,53 +6,10 @@ dist: bionic matrix: include: - - php: 7.1 + - php: 8.0 sudo: false - env: SYMFONY_VERSION=4.3.* PHPSTAN=true - - php: 7.1 - sudo: false - env: SYMFONY_VERSION=4.3.* PHP_CS_FIXER=true - - php: 7.1 - sudo: false - env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true - - php: 7.2 - sudo: false - env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true - - php: 7.2 - sudo: false - env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true - - php: 7.3 - sudo: false - env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true - - php: 7.3 - sudo: false - env: SYMFONY_VERSION=4.4.* UNIT_TESTS=true - - php: 7.3 - sudo: false - env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true - - php: 7.4 - sudo: false - env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true - - php: 7.4 - sudo: false - env: SYMFONY_VERSION=4.4.* UNIT_TESTS=true - - php: 7.4 - sudo: false - env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true - - php: 7.1 - sudo: required - services: docker - env: SYMFONY_VERSION=4.3.* FUNCTIONAL_TESTS=true PREPARE_CONTAINER=true - - php: 7.3 - sudo: required - services: docker - env: SYMFONY_VERSION=5.0.* FUNCTIONAL_TESTS=true PREPARE_CONTAINER=true - - php: 7.1 - sudo: required services: docker - env: SYMFONY_VERSION=4.3.* RDKAFKA_TESTS=true PREPARE_CONTAINER=true - allow_failures: - - env: SYMFONY_VERSION=4.3.* RDKAFKA_TESTS=true PREPARE_CONTAINER=true + env: SYMFONY_VERSION=5.2.* UNIT_TESTS=true cache: directories: From 3aec3157db2d8475f737855801478fac66af9655 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Mon, 28 Dec 2020 11:41:26 +0200 Subject: [PATCH 02/20] [php8][deps] Bump php to ^8 and phpunit to ^ 9.5 in composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 21cf655c1..59182866f 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "phpstan": "bin/phpstan analyse --memory-limit=512M -c phpstan.neon" }, "require": { - "php": "^7.1.3", + "php": "^8.0", "ext-amqp": "^1.9.3", "ext-gearman": "^2.0", @@ -41,7 +41,7 @@ "datadog/php-datadogstatsd": "^1.3" }, "require-dev": { - "phpunit/phpunit": "^7.5", + "phpunit/phpunit": "^9.5", "phpstan/phpstan": "^0.12", "queue-interop/queue-spec": "^0.6", "symfony/browser-kit": "^3.4|^4", From 3f041de7638277437d12a63bfaddd70f22fcb412 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 14:11:04 +0200 Subject: [PATCH 03/20] [php8][travis] Restore php 7 builds but keep new php 8 build --- .travis.yml | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.travis.yml b/.travis.yml index 3b0eba86c..a8d49ccda 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,57 @@ dist: bionic matrix: include: + - php: 7.1 + sudo: false + env: SYMFONY_VERSION=4.3.* PHPSTAN=true + - php: 7.1 + sudo: false + env: SYMFONY_VERSION=4.3.* PHP_CS_FIXER=true + - php: 7.1 + sudo: false + env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true + - php: 7.2 + sudo: false + env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true + - php: 7.2 + sudo: false + env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true + - php: 7.3 + sudo: false + env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true + - php: 7.3 + sudo: false + env: SYMFONY_VERSION=4.4.* UNIT_TESTS=true + - php: 7.3 + sudo: false + env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true + - php: 7.4 + sudo: false + env: SYMFONY_VERSION=4.3.* UNIT_TESTS=true + - php: 7.4 + sudo: false + env: SYMFONY_VERSION=4.4.* UNIT_TESTS=true + - php: 7.4 + sudo: false + env: SYMFONY_VERSION=5.0.* UNIT_TESTS=true + - php: 7.1 + sudo: required + services: docker + env: SYMFONY_VERSION=4.3.* FUNCTIONAL_TESTS=true PREPARE_CONTAINER=true + - php: 7.3 + sudo: required + services: docker + env: SYMFONY_VERSION=5.0.* FUNCTIONAL_TESTS=true PREPARE_CONTAINER=true + - php: 7.1 + sudo: required + services: docker + env: SYMFONY_VERSION=4.3.* RDKAFKA_TESTS=true PREPARE_CONTAINER=true - php: 8.0 sudo: false services: docker env: SYMFONY_VERSION=5.2.* UNIT_TESTS=true + allow_failures: + - env: SYMFONY_VERSION=4.3.* RDKAFKA_TESTS=true PREPARE_CONTAINER=true cache: directories: From e48140f8de09647ea82c25e5b31c472e626ba9c0 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 14:12:43 +0200 Subject: [PATCH 04/20] [php8][deps] Bump php from ^7.1 to >=7.3 and phpunit from 7.5 to 9.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 59182866f..e806f6da8 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "phpstan": "bin/phpstan analyse --memory-limit=512M -c phpstan.neon" }, "require": { - "php": "^8.0", + "php": ">=7.3", "ext-amqp": "^1.9.3", "ext-gearman": "^2.0", From 0879a7d00f80a6c1c31983834b56f2995b5062a6 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 15:19:23 +0200 Subject: [PATCH 05/20] [php8][tests] Adjust setUp() to setUp(): void return typehint to be compatible with parent method --- pkg/enqueue-bundle/Tests/Functional/WebTestCase.php | 2 +- pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php | 2 +- pkg/job-queue/Tests/Functional/WebTestCase.php | 2 +- pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php | 2 +- pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php b/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php index 8e3569a98..ca462ea1e 100644 --- a/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php +++ b/pkg/enqueue-bundle/Tests/Functional/WebTestCase.php @@ -20,7 +20,7 @@ abstract class WebTestCase extends BaseWebTestCase */ protected static $container; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php index 7282aa42e..81bb0091b 100644 --- a/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php +++ b/pkg/enqueue/Tests/DoctrineConnectionFactoryFactoryTest.php @@ -25,7 +25,7 @@ class DoctrineConnectionFactoryFactoryTest extends TestCase */ private $factory; - protected function setUp() + protected function setUp(): void { $this->registry = $this->prophesize(ManagerRegistry::class); $this->fallbackFactory = $this->prophesize(ConnectionFactoryFactoryInterface::class); diff --git a/pkg/job-queue/Tests/Functional/WebTestCase.php b/pkg/job-queue/Tests/Functional/WebTestCase.php index 2f8e17cea..90a8188dd 100644 --- a/pkg/job-queue/Tests/Functional/WebTestCase.php +++ b/pkg/job-queue/Tests/Functional/WebTestCase.php @@ -18,7 +18,7 @@ abstract class WebTestCase extends BaseWebTestCase */ protected static $container; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php b/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php index ef8263fa6..7d06df229 100644 --- a/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php +++ b/pkg/sqs/Tests/Functional/SqsCommonUseCasesTest.php @@ -27,7 +27,7 @@ class SqsCommonUseCasesTest extends TestCase */ private $queueName; - protected function setUp() + protected function setUp(): void { parent::setUp(); diff --git a/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php index b9c1a2987..f003825d1 100644 --- a/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php +++ b/pkg/sqs/Tests/Functional/SqsConsumptionUseCasesTest.php @@ -26,7 +26,7 @@ class SqsConsumptionUseCasesTest extends TestCase */ private $context; - protected function setUp() + protected function setUp(): void { parent::setUp(); From 50851e9743801decade9c2d0637efbd5296878fc Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 15:23:11 +0200 Subject: [PATCH 06/20] [php8][tests] Adjust setUp() to setUp(): void return typehint to be compatible with parent method for all public methods --- pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php | 2 +- pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php | 2 +- pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php | 2 +- pkg/amqp-tools/Tests/SignalSocketHelperTest.php | 2 +- pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php | 2 +- pkg/dbal/Tests/Functional/DbalConsumerTest.php | 2 +- .../Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php | 2 +- .../DbalSendAndReceivePriorityMessagesFromQueueTest.php | 2 +- .../Tests/Functional/Events/AsyncListenerTest.php | 2 +- .../Tests/Functional/Events/AsyncProcessorTest.php | 2 +- .../Tests/Functional/Events/AsyncSubscriberTest.php | 2 +- pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php | 2 +- pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php | 2 +- pkg/fs/Tests/Functional/FsCommonUseCasesTest.php | 2 +- pkg/fs/Tests/Functional/FsConsumerTest.php | 2 +- pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php | 2 +- pkg/fs/Tests/Functional/FsProducerTest.php | 2 +- pkg/fs/Tests/Functional/FsRpcUseCasesTest.php | 2 +- pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php | 2 +- .../Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php | 2 +- .../Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php | 2 +- pkg/mongodb/Tests/Functional/MongodbConsumerTest.php | 2 +- .../Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php | 2 +- .../Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php | 2 +- .../Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php | 2 +- pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php | 2 +- pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php | 2 +- pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php | 2 +- pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php | 2 +- pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php | 2 +- pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php | 2 +- pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index ee73345e9..8e8ea2545 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php @@ -22,7 +22,7 @@ class AmqpCommonUseCasesTest extends TestCase */ private $amqpContext; - public function setUp() + public function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); diff --git a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php index 220554859..09d0a0e99 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php @@ -29,7 +29,7 @@ class AmqpConsumptionUseCasesTest extends TestCase */ private $amqpContext; - public function setUp() + public function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); diff --git a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php index 9e5dc4df3..5aafe96a4 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php @@ -23,7 +23,7 @@ class AmqpRpcUseCasesTest extends TestCase */ private $amqpContext; - public function setUp() + public function setUp(): void { $this->amqpContext = $this->buildAmqpContext(); diff --git a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php index d869878c9..10903d47d 100644 --- a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php +++ b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php @@ -16,7 +16,7 @@ class SignalSocketHelperTest extends TestCase private $backupSigIntHandler; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php b/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php index d05a9add5..f073ff515 100644 --- a/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php +++ b/pkg/async-event-dispatcher/Tests/Functional/UseCasesTest.php @@ -53,7 +53,7 @@ class UseCasesTest extends TestCase */ protected $asyncProcessor; - public function setUp() + public function setUp(): void { (new Filesystem())->remove(__DIR__.'/queues/'); diff --git a/pkg/dbal/Tests/Functional/DbalConsumerTest.php b/pkg/dbal/Tests/Functional/DbalConsumerTest.php index 69b644ed4..709f1eafe 100644 --- a/pkg/dbal/Tests/Functional/DbalConsumerTest.php +++ b/pkg/dbal/Tests/Functional/DbalConsumerTest.php @@ -21,7 +21,7 @@ class DbalConsumerTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->createDbalContext(); } diff --git a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php index 5a051a729..a26c58ef2 100644 --- a/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Mysql/DbalSendAndReceivePriorityMessagesFromQueueTest.php @@ -16,7 +16,7 @@ class DbalSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePrio private $publishedAt; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php index a645cbad6..44fba568f 100644 --- a/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/dbal/Tests/Spec/Postgresql/DbalSendAndReceivePriorityMessagesFromQueueTest.php @@ -16,7 +16,7 @@ class DbalSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceivePrio private $publishedAt; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php index 457a0ffcd..2dcdd251e 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncListenerTest.php @@ -16,7 +16,7 @@ */ class AsyncListenerTest extends WebTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php index e595414ae..8c8501ad4 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncProcessorTest.php @@ -18,7 +18,7 @@ */ class AsyncProcessorTest extends WebTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php index 7404e6af8..ce9f6456c 100644 --- a/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/Events/AsyncSubscriberTest.php @@ -16,7 +16,7 @@ */ class AsyncSubscriberTest extends WebTestCase { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php b/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php index fefbe882b..c41a4d2db 100644 --- a/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/LazyProducerTest.php @@ -11,7 +11,7 @@ */ class LazyProducerTest extends WebTestCase { - public function setUp() + public function setUp(): void { // do not call parent::setUp. // parent::setUp(); diff --git a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php index 7c2936c0e..2144e42d7 100644 --- a/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php +++ b/pkg/enqueue-bundle/Tests/Functional/UseCasesTest.php @@ -20,7 +20,7 @@ class UseCasesTest extends WebTestCase { const RECEIVE_TIMEOUT = 500; - public function setUp() + public function setUp(): void { // do not call parent::setUp. // parent::setUp(); diff --git a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php index 1ae462731..9b169a03d 100644 --- a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php @@ -17,7 +17,7 @@ class FsCommonUseCasesTest extends \PHPUnit\Framework\TestCase */ private $fsContext; - public function setUp() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/fs/Tests/Functional/FsConsumerTest.php b/pkg/fs/Tests/Functional/FsConsumerTest.php index 9dd7a0103..495989aad 100644 --- a/pkg/fs/Tests/Functional/FsConsumerTest.php +++ b/pkg/fs/Tests/Functional/FsConsumerTest.php @@ -15,7 +15,7 @@ class FsConsumerTest extends TestCase */ private $fsContext; - public function setUp() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php index 98895a62d..28457afbb 100644 --- a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php @@ -25,7 +25,7 @@ class FsConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase */ private $fsContext; - public function setUp() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/fs/Tests/Functional/FsProducerTest.php b/pkg/fs/Tests/Functional/FsProducerTest.php index 6f7e4b4fa..ae95ddf68 100644 --- a/pkg/fs/Tests/Functional/FsProducerTest.php +++ b/pkg/fs/Tests/Functional/FsProducerTest.php @@ -14,7 +14,7 @@ class FsProducerTest extends TestCase */ private $fsContext; - public function setUp() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php index 046a25f9c..01b8894f9 100644 --- a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php @@ -20,7 +20,7 @@ class FsRpcUseCasesTest extends TestCase */ private $fsContext; - public function setUp() + public function setUp(): void { $this->fsContext = (new FsConnectionFactory(['path' => sys_get_temp_dir()]))->createContext(); diff --git a/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php b/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php index 99419eb15..9c680bb67 100644 --- a/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php +++ b/pkg/gearman/Tests/SkipIfGearmanExtensionIsNotInstalledTrait.php @@ -4,7 +4,7 @@ trait SkipIfGearmanExtensionIsNotInstalledTrait { - public function setUp() + public function setUp(): void { if (false == class_exists(\GearmanClient::class)) { $this->markTestSkipped('The gearman extension is not installed'); diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php index c90432e00..e34d9d1d5 100644 --- a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveFromQueueTest.php @@ -13,7 +13,7 @@ class GearmanSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceiveFro { private $time; - public function setUp() + public function setUp(): void { $this->time = time(); } diff --git a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php index 469f9e997..b68b94480 100644 --- a/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/gearman/Tests/Spec/GearmanSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -13,7 +13,7 @@ class GearmanSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndRece { private $time; - public function setUp() + public function setUp(): void { $this->time = time(); } diff --git a/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php b/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php index 6e7f01e5c..ccefe0278 100644 --- a/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php +++ b/pkg/mongodb/Tests/Functional/MongodbConsumerTest.php @@ -19,7 +19,7 @@ class MongodbConsumerTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildMongodbContext(); } diff --git a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php index 9869d6e06..1f06aac5d 100644 --- a/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php +++ b/pkg/mongodb/Tests/Spec/MongodbSendAndReceivePriorityMessagesFromQueueTest.php @@ -18,7 +18,7 @@ class MongodbSendAndReceivePriorityMessagesFromQueueTest extends SendAndReceiveP private $publishedAt; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php index a6a5f925a..9a913e422 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveFromQueueTest.php @@ -13,7 +13,7 @@ class PheanstalkSendToTopicAndReceiveFromQueueTest extends SendToTopicAndReceive { private $time; - public function setUp() + public function setUp(): void { $this->time = time(); } diff --git a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php index 2bf9f9542..c3501f8aa 100644 --- a/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php +++ b/pkg/pheanstalk/Tests/Spec/PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest.php @@ -13,7 +13,7 @@ class PheanstalkSendToTopicAndReceiveNoWaitFromQueueTest extends SendToTopicAndR { private $time; - public function setUp() + public function setUp(): void { $this->time = time(); } diff --git a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php index a63672da8..f54aadf91 100644 --- a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php @@ -19,7 +19,7 @@ class PRedisCommonUseCasesTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildPRedisContext(); diff --git a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php index f748020f1..e657b1830 100644 --- a/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PRedisConsumptionUseCasesTest.php @@ -19,7 +19,7 @@ class PRedisConsumptionUseCasesTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildPRedisContext(); diff --git a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php index 41b403565..ee4a1a786 100644 --- a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php @@ -19,7 +19,7 @@ class PhpRedisCommonUseCasesTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildPhpRedisContext(); diff --git a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php index d48e4bcb4..f255d4ea0 100644 --- a/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php +++ b/pkg/redis/Tests/Functional/PhpRedisConsumptionUseCasesTest.php @@ -19,7 +19,7 @@ class PhpRedisConsumptionUseCasesTest extends TestCase */ private $context; - public function setUp() + public function setUp(): void { $this->context = $this->buildPhpRedisContext(); diff --git a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php index e2175b8af..1b56893b1 100644 --- a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php @@ -20,7 +20,7 @@ class StompCommonUseCasesTest extends \PHPUnit\Framework\TestCase */ private $stompContext; - public function setUp() + public function setUp(): void { $this->stompContext = $this->buildStompContext(); diff --git a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php index 36357ca21..fd816ccad 100644 --- a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php @@ -28,7 +28,7 @@ class StompConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase */ private $stompContext; - public function setUp() + public function setUp(): void { $this->stompContext = $this->buildStompContext(); diff --git a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php index 4c06d59b1..657510c19 100644 --- a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php @@ -22,7 +22,7 @@ class StompRpcUseCasesTest extends \PHPUnit\Framework\TestCase */ private $stompContext; - public function setUp() + public function setUp(): void { $this->stompContext = $this->buildStompContext(); From cb833c82a75d3035e12d85a9eee2be17928d0dce Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 16:00:09 +0200 Subject: [PATCH 07/20] [php8][tests] Typehint for setUpBeforeClass (added :void) --- pkg/wamp/Tests/Functional/WampConsumerTest.php | 2 +- pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/wamp/Tests/Functional/WampConsumerTest.php b/pkg/wamp/Tests/Functional/WampConsumerTest.php index f76cce71b..57dc32fd5 100644 --- a/pkg/wamp/Tests/Functional/WampConsumerTest.php +++ b/pkg/wamp/Tests/Functional/WampConsumerTest.php @@ -19,7 +19,7 @@ class WampConsumerTest extends TestCase use WampExtension; use RetryTrait; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { Logger::set(new NullLogger()); } diff --git a/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php b/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php index c28b3e0a5..e272f42ed 100644 --- a/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php +++ b/pkg/wamp/Tests/Functional/WampSubscriptionConsumerTest.php @@ -16,7 +16,7 @@ class WampSubscriptionConsumerTest extends TestCase { use WampExtension; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { Logger::set(new NullLogger()); } From 636cea3b93a2ded61a0d2989e6e8da03fdb55d67 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 22:00:07 +0200 Subject: [PATCH 08/20] [php8][tests] Fix getQueue invalid return type error. Added nullQueue instead of null --- .../DelayRedeliveredMessageExtensionTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php index 050b4f2f5..be991ab93 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php @@ -106,7 +106,7 @@ public function testShouldDoNothingIfMessageIsNotRedelivered() $messageReceived = new MessageReceived( $this->createContextMock(), - $this->createConsumerStub(null), + $this->createConsumerStub(new NullQueue('queue')), $message, $this->createProcessorMock(), 1, @@ -132,7 +132,7 @@ public function testShouldDoNothingIfMessageIsRedeliveredButResultWasAlreadySetO $messageReceived = new MessageReceived( $this->createContextMock(), - $this->createConsumerStub(null), + $this->createConsumerStub(new NullQueue('queue')), $message, $this->createProcessorMock(), 1, From e27eb567b0ee7f16abeff4f8a0bd97b820e7d4c4 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 22:14:57 +0200 Subject: [PATCH 09/20] [php8][tests] Enqueu Client - ExclusiveCommandExtensionTest fix queue stub return type. Use NullQueue instead of null --- .../ExclusiveCommandExtensionTest.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php index 878778b30..595d84894 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/ExclusiveCommandExtensionTest.php @@ -15,6 +15,7 @@ use Interop\Queue\Consumer; use Interop\Queue\Context as InteropContext; use Interop\Queue\Processor; +use Interop\Queue\Queue; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; @@ -51,7 +52,7 @@ public function testShouldDoNothingIfMessageHasTopicPropertySetOnPreReceive() $messageReceived = new MessageReceived( $this->createContextMock(), - $this->createConsumerStub(null), + $this->createConsumerStub(), $message, $this->createProcessorMock(), 1, @@ -245,13 +246,13 @@ public function testShouldDoNothingIfAnotherQueue() /** * @return MockObject */ - private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface + private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface { $driver = $this->createMock(DriverInterface::class); $driver ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection) + ->willReturn($routeCollection ?? new RouteCollection([])) ; return $driver; @@ -278,13 +279,13 @@ private function createProcessorMock(): Processor * * @return MockObject */ - private function createConsumerStub($queue): Consumer + private function createConsumerStub(?Queue $queue = null): Consumer { $consumerMock = $this->createMock(Consumer::class); $consumerMock ->expects($this->any()) ->method('getQueue') - ->willReturn($queue) + ->willReturn($queue ?? new NullQueue('queue')) ; return $consumerMock; From 8ab130bce11de1e406b450337c3c6e6b7f103631 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 22:17:44 +0200 Subject: [PATCH 10/20] [php8][tests] Enqueu Client - fix queue stub return type. Use NullQueue instead of null --- .../DelayRedeliveredMessageExtensionTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php index be991ab93..c122bcd5c 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php @@ -15,6 +15,7 @@ use Interop\Queue\Destination; use Interop\Queue\Message as TransportMessage; use Interop\Queue\Processor; +use Interop\Queue\Queue; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; @@ -173,13 +174,13 @@ private function createProcessorMock(): Processor * * @return MockObject */ - private function createConsumerStub($queue): Consumer + private function createConsumerStub(?Queue $queue = null): Consumer { $consumerMock = $this->createMock(Consumer::class); $consumerMock ->expects($this->any()) ->method('getQueue') - ->willReturn($queue) + ->willReturn($queue ?? new NullQueue('queue')) ; return $consumerMock; From f7044ea2d39a85d979ea4d88a030d5c45b45f015 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 22:26:42 +0200 Subject: [PATCH 11/20] [php8][tests] enqueue/Client/ConsumtionExtension fix queue return type mismatch (NullQueue instead of null) --- .../SetRouterPropertiesExtensionTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php index 18760e9bf..d59a6f59e 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php @@ -13,6 +13,7 @@ use Interop\Queue\Consumer; use Interop\Queue\Context as InteropContext; use Interop\Queue\Processor; +use Interop\Queue\Queue; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Log\NullLogger; @@ -190,13 +191,13 @@ private function createProcessorMock(): Processor * * @return MockObject */ - private function createConsumerStub($queue): Consumer + private function createConsumerStub(?Queue $queue = null): Consumer { $consumerMock = $this->createMock(Consumer::class); $consumerMock ->expects($this->any()) ->method('getQueue') - ->willReturn($queue) + ->willReturn($queue ?? new NullQueue('queue')) ; return $consumerMock; From e65c82bb675a825251c576468fd8e77238ee531d Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 22:53:12 +0200 Subject: [PATCH 12/20] [php8][deps] Added extenstion to support assertArraySubset as this method was removed from phpunit 9 --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e806f6da8..c340af735 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,8 @@ "doctrine/mongodb-odm-bundle": "^3.5|^4", "alcaeus/mongo-php-adapter": "^1.0", "kwn/php-rdkafka-stubs": "^1.0.2 | ^2.0", - "friendsofphp/php-cs-fixer": "^2" + "friendsofphp/php-cs-fixer": "^2", + "dms/phpunit-arraysubset-asserts": "^0.2.1" }, "autoload": { "psr-4": { From 8673be3e1f06a6efcdeea93169e4d20fdfb80612 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 22:55:25 +0200 Subject: [PATCH 13/20] [php8][tests] Fix ConsumptionExtension tests that were failing because of missing assertArraySubset method --- pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php b/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php index 4f1c81566..c23cb7f71 100644 --- a/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php +++ b/pkg/enqueue/Tests/Client/Driver/GenericDriverTestsTrait.php @@ -14,6 +14,7 @@ use Interop\Queue\Producer as InteropProducer; use Interop\Queue\Queue as InteropQueue; use Interop\Queue\Topic as InteropTopic; +use DMS\PHPUnitExtensions\ArraySubset\Assert; trait GenericDriverTestsTrait { @@ -1191,10 +1192,10 @@ protected function assertTransportMessage(InteropMessage $transportMessage): voi protected function assertClientMessage(Message $clientMessage): void { $this->assertSame('body', $clientMessage->getBody()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'hkey' => 'hval', ], $clientMessage->getHeaders()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'pkey' => 'pval', Config::CONTENT_TYPE => 'theContentType', Config::EXPIRE => '22', From 134586e9481953802a595c148c438e6a0551e7ac Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 23:02:36 +0200 Subject: [PATCH 14/20] [php8][tests] Replace ->assertArraySubset by \DMS\PHPUnitExtensions\ArraySubset\Assert::assertArraySubset --- .../Tests/Client/Driver/AmqpDriverTest.php | 3 +- .../Tests/Client/Driver/GenericDriverTest.php | 3 +- .../Client/Driver/RabbitMqDriverTest.php | 3 +- .../Tests/Client/TraceableProducerTest.php | 29 ++++++++++--------- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php index 4e4cc62fd..3234c45f0 100644 --- a/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/AmqpDriverTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client\Driver; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Config; use Enqueue\Client\Driver\AmqpDriver; use Enqueue\Client\Driver\GenericDriver; @@ -336,7 +337,7 @@ protected function getRouterTransportName(): string protected function assertTransportMessage(InteropMessage $transportMessage): void { $this->assertSame('body', $transportMessage->getBody()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'hkey' => 'hval', 'delivery_mode' => AmqpMessage::DELIVERY_MODE_PERSISTENT, 'content_type' => 'ContentType', diff --git a/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php b/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php index 98b6c2285..78f7f6e83 100644 --- a/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/GenericDriverTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client\Driver; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Config; use Enqueue\Client\Driver\GenericDriver; use Enqueue\Client\DriverInterface; @@ -60,7 +61,7 @@ protected function createMessage(): InteropMessage protected function assertTransportMessage(InteropMessage $transportMessage): void { $this->assertSame('body', $transportMessage->getBody()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'hkey' => 'hval', 'message_id' => 'theMessageId', 'timestamp' => 1000, diff --git a/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php b/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php index 2f6e20a82..6b61465c3 100644 --- a/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php +++ b/pkg/enqueue/Tests/Client/Driver/RabbitMqDriverTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client\Driver; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Config; use Enqueue\Client\Driver\AmqpDriver; use Enqueue\Client\Driver\GenericDriver; @@ -115,7 +116,7 @@ protected function getRouterTransportName(): string protected function assertTransportMessage(InteropMessage $transportMessage): void { $this->assertSame('body', $transportMessage->getBody()); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'hkey' => 'hval', 'delivery_mode' => AmqpMessage::DELIVERY_MODE_PERSISTENT, 'content_type' => 'ContentType', diff --git a/pkg/enqueue/Tests/Client/TraceableProducerTest.php b/pkg/enqueue/Tests/Client/TraceableProducerTest.php index ff5ee83eb..ac0a52961 100644 --- a/pkg/enqueue/Tests/Client/TraceableProducerTest.php +++ b/pkg/enqueue/Tests/Client/TraceableProducerTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Tests\Client; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Client\Message; use Enqueue\Client\ProducerInterface; use Enqueue\Client\TraceableProducer; @@ -45,7 +46,7 @@ public function testShouldCollectInfoIfStringGivenAsEventMessage() $producer->sendEvent('aFooTopic', 'aFooBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => 'aFooTopic', 'command' => null, @@ -70,7 +71,7 @@ public function testShouldCollectInfoIfArrayGivenAsEventMessage() $producer->sendEvent('aFooTopic', ['foo' => 'fooVal', 'bar' => 'barVal']); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => 'aFooTopic', 'command' => null, @@ -106,7 +107,7 @@ public function testShouldCollectInfoIfEventMessageObjectGivenAsMessage() $producer->sendEvent('aFooTopic', $message); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => 'aFooTopic', 'command' => null, @@ -168,7 +169,7 @@ public function testShouldCollectInfoIfStringGivenAsCommandMessage() $producer->sendCommand('aFooCommand', 'aFooBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => null, 'command' => 'aFooCommand', @@ -193,7 +194,7 @@ public function testShouldCollectInfoIfArrayGivenAsCommandMessage() $producer->sendCommand('aFooCommand', ['foo' => 'fooVal', 'bar' => 'barVal']); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => null, 'command' => 'aFooCommand', @@ -229,7 +230,7 @@ public function testShouldCollectInfoIfCommandMessageObjectGivenAsMessage() $producer->sendCommand('aFooCommand', $message); - $this->assertArraySubset([ + Assert::assertArraySubset([ [ 'topic' => null, 'command' => 'aFooCommand', @@ -275,7 +276,7 @@ public function testShouldAllowGetInfoSentToSameTopic() $producer->sendEvent('aFooTopic', 'aFooBody'); $producer->sendEvent('aFooTopic', 'aFooBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ], $producer->getTraces()); @@ -288,7 +289,7 @@ public function testShouldAllowGetInfoSentToDifferentTopics() $producer->sendEvent('aFooTopic', 'aFooBody'); $producer->sendEvent('aBarTopic', 'aBarBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ['topic' => 'aBarTopic', 'body' => 'aBarBody'], ], $producer->getTraces()); @@ -301,11 +302,11 @@ public function testShouldAllowGetInfoSentToSpecialTopic() $producer->sendEvent('aFooTopic', 'aFooBody'); $producer->sendEvent('aBarTopic', 'aBarBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['topic' => 'aFooTopic', 'body' => 'aFooBody'], ], $producer->getTopicTraces('aFooTopic')); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['topic' => 'aBarTopic', 'body' => 'aBarBody'], ], $producer->getTopicTraces('aBarTopic')); } @@ -317,7 +318,7 @@ public function testShouldAllowGetInfoSentToSameCommand() $producer->sendCommand('aFooCommand', 'aFooBody'); $producer->sendCommand('aFooCommand', 'aFooBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['command' => 'aFooCommand', 'body' => 'aFooBody'], ['command' => 'aFooCommand', 'body' => 'aFooBody'], ], $producer->getTraces()); @@ -330,7 +331,7 @@ public function testShouldAllowGetInfoSentToDifferentCommands() $producer->sendCommand('aFooCommand', 'aFooBody'); $producer->sendCommand('aBarCommand', 'aBarBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['command' => 'aFooCommand', 'body' => 'aFooBody'], ['command' => 'aBarCommand', 'body' => 'aBarBody'], ], $producer->getTraces()); @@ -343,11 +344,11 @@ public function testShouldAllowGetInfoSentToSpecialCommand() $producer->sendCommand('aFooCommand', 'aFooBody'); $producer->sendCommand('aBarCommand', 'aBarBody'); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['command' => 'aFooCommand', 'body' => 'aFooBody'], ], $producer->getCommandTraces('aFooCommand')); - $this->assertArraySubset([ + Assert::assertArraySubset([ ['command' => 'aBarCommand', 'body' => 'aBarBody'], ], $producer->getCommandTraces('aBarCommand')); } From 6bb7bbdf79de8e7bb8fd60fb75e06009b7688d6e Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Wed, 30 Dec 2020 23:30:33 +0200 Subject: [PATCH 15/20] [php8][enqueue][tests] Replace depracated methods to check types --- pkg/enqueue/Tests/Client/ResourcesTest.php | 6 +++--- pkg/enqueue/Tests/Client/RouterProcessorTest.php | 13 ++----------- .../Tests/Symfony/Client/ConsumeCommandTest.php | 4 ++-- .../Symfony/Client/SimpleConsumeCommandTest.php | 4 ++-- 4 files changed, 9 insertions(+), 18 deletions(-) diff --git a/pkg/enqueue/Tests/Client/ResourcesTest.php b/pkg/enqueue/Tests/Client/ResourcesTest.php index c2d2b117d..045e0a112 100644 --- a/pkg/enqueue/Tests/Client/ResourcesTest.php +++ b/pkg/enqueue/Tests/Client/ResourcesTest.php @@ -28,7 +28,7 @@ public function testShouldGetAvailableDriverInExpectedFormat() { $availableDrivers = Resources::getAvailableDrivers(); - $this->assertInternalType('array', $availableDrivers); + $this->assertIsArray($availableDrivers); $this->assertGreaterThan(0, count($availableDrivers)); $driverInfo = $availableDrivers[0]; @@ -50,7 +50,7 @@ public function testShouldGetAvailableDriverWithRequiredExtensionInExpectedForma { $availableDrivers = Resources::getAvailableDrivers(); - $this->assertInternalType('array', $availableDrivers); + $this->assertIsArray($availableDrivers); $this->assertGreaterThan(0, count($availableDrivers)); $driverInfo = $availableDrivers[1]; @@ -72,7 +72,7 @@ public function testShouldGetKnownDriversInExpectedFormat() { $knownDrivers = Resources::getAvailableDrivers(); - $this->assertInternalType('array', $knownDrivers); + $this->assertIsArray($knownDrivers); $this->assertGreaterThan(0, count($knownDrivers)); $driverInfo = $knownDrivers[0]; diff --git a/pkg/enqueue/Tests/Client/RouterProcessorTest.php b/pkg/enqueue/Tests/Client/RouterProcessorTest.php index cdd44df7a..81c6e495c 100644 --- a/pkg/enqueue/Tests/Client/RouterProcessorTest.php +++ b/pkg/enqueue/Tests/Client/RouterProcessorTest.php @@ -32,15 +32,6 @@ public function testShouldBeFinal() $this->assertClassFinal(RouterProcessor::class); } - public function testCouldBeConstructedWithDriver() - { - $driver = $this->createDriverStub(); - - $processor = new RouterProcessor($driver); - - $this->assertAttributeSame($driver, 'driver', $processor); - } - public function testShouldRejectIfTopicNotSet() { $router = new RouterProcessor($this->createDriverStub()); @@ -197,13 +188,13 @@ public function testShouldDoNotModifyOriginalMessage() /** * @return \PHPUnit\Framework\MockObject\MockObject */ - private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface + private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface { $driver = $this->createMock(DriverInterface::class); $driver ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection) + ->willReturn($routeCollection ?? new RouteCollection([])) ; return $driver; diff --git a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php index be7de228e..706aee07c 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ConsumeCommandTest.php @@ -605,13 +605,13 @@ private function createQueueConsumerMock() /** * @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface */ - private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface + private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface { $driverMock = $this->createMock(DriverInterface::class); $driverMock ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection) + ->willReturn($routeCollection ?? new RouteCollection([])) ; $driverMock diff --git a/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php index 8f23acdbc..fb89dae32 100644 --- a/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/SimpleConsumeCommandTest.php @@ -122,13 +122,13 @@ private function createQueueConsumerMock() /** * @return \PHPUnit\Framework\MockObject\MockObject|DriverInterface */ - private function createDriverStub(RouteCollection $routeCollection = null): DriverInterface + private function createDriverStub(?RouteCollection $routeCollection = null): DriverInterface { $driverMock = $this->createMock(DriverInterface::class); $driverMock ->expects($this->any()) ->method('getRouteCollection') - ->willReturn($routeCollection) + ->willReturn($routeCollection ?? new RouteCollection([])) ; $driverMock From 088bd665931c2b1ba52b322c37e148958ec425e7 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Thu, 31 Dec 2020 13:41:30 +0200 Subject: [PATCH 16/20] [php8][enqueue][tests] FallbackSubscription - rewrite tests that used assertAttribute --- .../FallbackSubscriptionConsumerTest.php | 95 ++++--------------- 1 file changed, 18 insertions(+), 77 deletions(-) diff --git a/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php b/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php index 62066737c..cfea9a085 100644 --- a/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/FallbackSubscriptionConsumerTest.php @@ -23,32 +23,6 @@ public function testCouldBeConstructedWithoutAnyArguments() new FallbackSubscriptionConsumer(); } - public function testShouldInitSubscribersPropertyWithEmptyArray() - { - $subscriptionConsumer = new FallbackSubscriptionConsumer(); - - $this->assertAttributeSame([], 'subscribers', $subscriptionConsumer); - } - - public function testShouldAddConsumerAndCallbackToSubscribersPropertyOnSubscribe() - { - $subscriptionConsumer = new FallbackSubscriptionConsumer(); - - $fooCallback = function () {}; - $fooConsumer = $this->createConsumerStub('foo_queue'); - - $barCallback = function () {}; - $barConsumer = $this->createConsumerStub('bar_queue'); - - $subscriptionConsumer->subscribe($fooConsumer, $fooCallback); - $subscriptionConsumer->subscribe($barConsumer, $barCallback); - - $this->assertAttributeSame([ - 'foo_queue' => [$fooConsumer, $fooCallback], - 'bar_queue' => [$barConsumer, $barCallback], - ], 'subscribers', $subscriptionConsumer); - } - public function testThrowsIfTrySubscribeAnotherConsumerToAlreadySubscribedQueue() { $subscriptionConsumer = new FallbackSubscriptionConsumer(); @@ -66,76 +40,43 @@ public function testThrowsIfTrySubscribeAnotherConsumerToAlreadySubscribedQueue( $subscriptionConsumer->subscribe($barConsumer, $barCallback); } - public function testShouldAllowSubscribeSameConsumerAndCallbackSecondTime() - { - $subscriptionConsumer = new FallbackSubscriptionConsumer(); - - $fooCallback = function () {}; - $fooConsumer = $this->createConsumerStub('foo_queue'); - - $subscriptionConsumer->subscribe($fooConsumer, $fooCallback); - $subscriptionConsumer->subscribe($fooConsumer, $fooCallback); - } - - public function testShouldRemoveSubscribedConsumerOnUnsubscribeCall() - { - $subscriptionConsumer = new FallbackSubscriptionConsumer(); - - $fooConsumer = $this->createConsumerStub('foo_queue'); - $barConsumer = $this->createConsumerStub('bar_queue'); - - $subscriptionConsumer->subscribe($fooConsumer, function () {}); - $subscriptionConsumer->subscribe($barConsumer, function () {}); - - // guard - $this->assertAttributeCount(2, 'subscribers', $subscriptionConsumer); - - $subscriptionConsumer->unsubscribe($fooConsumer); - - $this->assertAttributeCount(1, 'subscribers', $subscriptionConsumer); - } - - public function testShouldDoNothingIfTryUnsubscribeNotSubscribedQueueName() + public function testShouldRemoveAllSubscriberOnUnsubscribeAllCall() { $subscriptionConsumer = new FallbackSubscriptionConsumer(); $subscriptionConsumer->subscribe($this->createConsumerStub('foo_queue'), function () {}); + $subscriptionConsumer->subscribe($this->createConsumerStub('bar_queue'), function () {}); - // guard - $this->assertAttributeCount(1, 'subscribers', $subscriptionConsumer); - - $subscriptionConsumer->unsubscribe($this->createConsumerStub('bar_queue')); + $subscriptionConsumer->unsubscribeAll(); - $this->assertAttributeCount(1, 'subscribers', $subscriptionConsumer); + $this->expectException(\LogicException::class); + $this->expectExceptionMessage('No subscribers'); + $subscriptionConsumer->consume(); } - public function testShouldDoNothingIfTryUnsubscribeNotSubscribedConsumer() + public function testShouldRemoveSubscriberOnUnsubscribeCall() { $subscriptionConsumer = new FallbackSubscriptionConsumer(); - $subscriptionConsumer->subscribe($this->createConsumerStub('foo_queue'), function () {}); - - // guard - $this->assertAttributeCount(1, 'subscribers', $subscriptionConsumer); + $consumer = $this->createConsumerStub('foo_queue'); + $subscriptionConsumer->subscribe($consumer, function () {}); - $subscriptionConsumer->unsubscribe($this->createConsumerStub('foo_queue')); + $subscriptionConsumer->unsubscribe($consumer); - $this->assertAttributeCount(1, 'subscribers', $subscriptionConsumer); + $this->expectException(\LogicException::class); + $this->expectExceptionMessage('No subscribers'); + $subscriptionConsumer->consume(); } - public function testShouldRemoveAllSubscriberOnUnsubscribeAllCall() + public function testShouldAllowSubscribeSameConsumerAndCallbackSecondTime() { $subscriptionConsumer = new FallbackSubscriptionConsumer(); - $subscriptionConsumer->subscribe($this->createConsumerStub('foo_queue'), function () {}); - $subscriptionConsumer->subscribe($this->createConsumerStub('bar_queue'), function () {}); - - // guard - $this->assertAttributeCount(2, 'subscribers', $subscriptionConsumer); - - $subscriptionConsumer->unsubscribeAll(); + $fooCallback = function () {}; + $fooConsumer = $this->createConsumerStub('foo_queue'); - $this->assertAttributeCount(0, 'subscribers', $subscriptionConsumer); + $subscriptionConsumer->subscribe($fooConsumer, $fooCallback); + $subscriptionConsumer->subscribe($fooConsumer, $fooCallback); } public function testShouldConsumeMessagesFromTwoQueuesInExpectedOrder() From e24eee5d85b5202062f7c80c05f6756e08043670 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Thu, 31 Dec 2020 13:54:53 +0200 Subject: [PATCH 17/20] [php8][enqueue][tests] QueueConsumerTest - remove tests with assertAttribute and fix return type of consume() to void --- .../Tests/Consumption/QueueConsumerTest.php | 88 +------------------ 1 file changed, 1 insertion(+), 87 deletions(-) diff --git a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php index 9e25ab931..941abe7bc 100644 --- a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php @@ -51,41 +51,6 @@ public function testCouldBeConstructedWithContextAndSingleExtension() new QueueConsumer($this->createContextStub(), $this->createExtension()); } - public function testShouldSetEmptyArrayToBoundProcessorsPropertyInConstructor() - { - $consumer = new QueueConsumer($this->createContextStub(), null, [], null, 0); - - $this->assertAttributeSame([], 'boundProcessors', $consumer); - } - - public function testShouldSetProvidedBoundProcessorsToThePropertyInConstructor() - { - $boundProcessors = [ - new BoundProcessor(new NullQueue('foo'), $this->createProcessorMock()), - new BoundProcessor(new NullQueue('bar'), $this->createProcessorMock()), - ]; - - $consumer = new QueueConsumer($this->createContextStub(), null, $boundProcessors, null, 0); - - $this->assertAttributeSame($boundProcessors, 'boundProcessors', $consumer); - } - - public function testShouldSetNullLoggerIfNoneProvidedInConstructor() - { - $consumer = new QueueConsumer($this->createContextStub(), null, [], null, 0); - - $this->assertAttributeInstanceOf(NullLogger::class, 'logger', $consumer); - } - - public function testShouldSetProvidedLoggerToThePropertyInConstructor() - { - $expectedLogger = $this->createMock(LoggerInterface::class); - - $consumer = new QueueConsumer($this->createContextStub(), null, [], $expectedLogger, 0); - - $this->assertAttributeSame($expectedLogger, 'logger', $consumer); - } - public function testShouldAllowGetContextSetInConstructor() { $expectedContext = $this->createContextStub(); @@ -119,22 +84,6 @@ public function testThrowIfQueueAlreadyBoundToProcessorOnBind() $consumer->bind(new NullQueue('theQueueName'), $processorMock); } - public function testShouldAllowBindProcessorToQueue() - { - $queue = new NullQueue('theQueueName'); - $processorMock = $this->createProcessorMock(); - - $consumer = new QueueConsumer($this->createContextStub()); - - $consumer->bind($queue, $processorMock); - - $this->assertAttributeEquals( - ['theQueueName' => new BoundProcessor($queue, $processorMock)], - 'boundProcessors', - $consumer - ); - } - public function testThrowIfQueueNeitherInstanceOfQueueNorString() { $processorMock = $this->createProcessorMock(); @@ -155,37 +104,6 @@ public function testCouldSetGetReceiveTimeout() $this->assertSame(123456, $consumer->getReceiveTimeout()); } - public function testShouldAllowBindCallbackToQueueName() - { - $callback = function () { - }; - - $queueName = 'theQueueName'; - $queue = new NullQueue($queueName); - - $context = $this->createContextWithoutSubscriptionConsumerMock(); - $context - ->expects($this->once()) - ->method('createQueue') - ->with($queueName) - ->willReturn($queue) - ; - - $consumer = new QueueConsumer($context); - - $consumer->bindCallback($queueName, $callback); - - $boundProcessors = $this->readAttribute($consumer, 'boundProcessors'); - - $this->assertInternalType('array', $boundProcessors); - $this->assertCount(1, $boundProcessors); - $this->assertArrayHasKey($queueName, $boundProcessors); - - $this->assertInstanceOf(BoundProcessor::class, $boundProcessors[$queueName]); - $this->assertSame($queue, $boundProcessors[$queueName]->getQueue()); - $this->assertInstanceOf(CallbackProcessor::class, $boundProcessors[$queueName]->getProcessor()); - } - public function testShouldReturnSelfOnBind() { $processorMock = $this->createProcessorMock(); @@ -203,7 +121,6 @@ public function testShouldUseContextSubscriptionConsumerIfSupport() $contextSubscriptionConsumer ->expects($this->once()) ->method('consume') - ->willReturn(null) ; $fallbackSubscriptionConsumer = $this->createSubscriptionConsumerMock(); @@ -251,7 +168,6 @@ public function testShouldUseFallbackSubscriptionConsumerIfNotSupported() $fallbackSubscriptionConsumer ->expects($this->once()) ->method('consume') - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); @@ -288,7 +204,6 @@ public function testShouldSubscribeToGivenQueueWithExpectedTimeout() ->expects($this->once()) ->method('consume') ->with(12345) - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); @@ -319,7 +234,6 @@ public function testShouldSubscribeToGivenQueueAndQuitAfterFifthConsumeCycle() $subscriptionConsumerMock ->expects($this->exactly(5)) ->method('consume') - ->willReturn(null) ; $contextMock = $this->createContextWithoutSubscriptionConsumerMock(); @@ -1546,7 +1460,7 @@ private function createConsumerStub($queue = null): Consumer $consumerMock ->expects($this->any()) ->method('getQueue') - ->willReturn($queue) + ->willReturn($queue ?? new NullQueue('queue')) ; return $consumerMock; From 0f729a4f14b4ef944a574cc3609636c9e763eb7a Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Thu, 31 Dec 2020 14:41:12 +0200 Subject: [PATCH 18/20] [php8][enqueue][tests] Replace assertContains to assertStringContainsString + assertInternalType to assertIsArray --- pkg/enqueue/Tests/ResourcesTest.php | 12 ++++++------ .../BuildClientExtensionsPassTest.php | 14 +++++++------- .../BuildCommandSubscriberRoutesPassTest.php | 18 +++++++++--------- .../BuildConsumptionExtensionsPassTest.php | 14 +++++++------- .../BuildProcessorRoutesPassTest.php | 14 +++++++------- .../BuildTopicSubscriberRoutesPassTest.php | 16 ++++++++-------- .../Client/FlushSpoolProducerListenerTest.php | 4 ++-- .../Tests/Symfony/Client/RoutesCommandTest.php | 2 +- .../Symfony/Client/SetupBrokerCommandTest.php | 4 ++-- .../Client/SimpleSetupBrokerCommandTest.php | 2 +- .../BuildConsumptionExtensionsPassTest.php | 14 +++++++------- pkg/enqueue/Tests/Util/UUIDTest.php | 2 +- 12 files changed, 58 insertions(+), 58 deletions(-) diff --git a/pkg/enqueue/Tests/ResourcesTest.php b/pkg/enqueue/Tests/ResourcesTest.php index 214a0836f..7f23d13fe 100644 --- a/pkg/enqueue/Tests/ResourcesTest.php +++ b/pkg/enqueue/Tests/ResourcesTest.php @@ -28,7 +28,7 @@ public function testShouldGetAvailableConnectionsInExpectedFormat() { $availableConnections = Resources::getAvailableConnections(); - $this->assertInternalType('array', $availableConnections); + $this->assertIsArray($availableConnections); $this->assertArrayHasKey(RedisConnectionFactory::class, $availableConnections); $connectionInfo = $availableConnections[RedisConnectionFactory::class]; @@ -46,7 +46,7 @@ public function testShouldGetKnownConnectionsInExpectedFormat() { $availableConnections = Resources::getKnownConnections(); - $this->assertInternalType('array', $availableConnections); + $this->assertIsArray($availableConnections); $this->assertArrayHasKey(RedisConnectionFactory::class, $availableConnections); $connectionInfo = $availableConnections[RedisConnectionFactory::class]; @@ -93,12 +93,12 @@ public function testShouldAllowRegisterConnectionThatIsNotInstalled() Resources::addConnection('theConnectionClass', ['foo'], [], 'foo'); $knownConnections = Resources::getKnownConnections(); - $this->assertInternalType('array', $knownConnections); + $this->assertIsArray($knownConnections); $this->assertArrayHasKey('theConnectionClass', $knownConnections); $availableConnections = Resources::getAvailableConnections(); - $this->assertInternalType('array', $availableConnections); + $this->assertIsArray($availableConnections); $this->assertArrayNotHasKey('theConnectionClass', $availableConnections); } @@ -115,7 +115,7 @@ public function testShouldAllowGetPreviouslyRegisteredConnection() $availableConnections = Resources::getAvailableConnections(); - $this->assertInternalType('array', $availableConnections); + $this->assertIsArray($availableConnections); $this->assertArrayHasKey($connectionClass, $availableConnections); $connectionInfo = $availableConnections[$connectionClass]; @@ -133,7 +133,7 @@ public function testShouldHaveRegisteredWampConfiguration() { $availableConnections = Resources::getKnownConnections(); - $this->assertInternalType('array', $availableConnections); + $this->assertIsArray($availableConnections); $this->assertArrayHasKey(WampConnectionFactory::class, $availableConnections); $connectionInfo = $availableConnections[WampConnectionFactory::class]; diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php index af69293d1..56689ccd9 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildClientExtensionsPassTest.php @@ -72,7 +72,7 @@ public function testShouldRegisterClientExtension() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -99,7 +99,7 @@ public function testShouldIgnoreOtherClientExtensions() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -125,7 +125,7 @@ public function testShouldAddExtensionIfClientAll() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -151,7 +151,7 @@ public function testShouldTreatTagsWithoutClientAsDefaultClient() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -247,7 +247,7 @@ public function testShouldMergeWithAddedPreviously() $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertCount(4, $extensions->getArgument(0)); } @@ -275,12 +275,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingExtensi $pass = new BuildClientExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $fooExtensions->getArgument(0)); + $this->assertIsArray($fooExtensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $fooExtensions->getArgument(0)); - $this->assertInternalType('array', $barExtensions->getArgument(0)); + $this->assertIsArray($barExtensions->getArgument(0)); $this->assertEquals([ new Reference('aBarExtension'), ], $barExtensions->getArgument(0)); diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php index 346c0cbdb..481bf9a3f 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildCommandSubscriberRoutesPassTest.php @@ -96,7 +96,7 @@ public function testShouldRegisterProcessorWithMatchedName() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -120,7 +120,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -144,7 +144,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -166,7 +166,7 @@ public function testShouldRegisterProcessorIfCommandsIsString() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -222,7 +222,7 @@ public function testShouldRegisterProcessorIfCommandsAreStrings() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( @@ -266,7 +266,7 @@ public function testShouldRegisterProcessorIfParamSingleCommandArray() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); @@ -305,7 +305,7 @@ public function testShouldRegisterProcessorIfCommandsAreParamArrays() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( @@ -372,7 +372,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(3, $routeCollection->getArgument(0)); $this->assertEquals( @@ -422,7 +422,7 @@ public function testShouldRegister08CommandProcessor() $pass = new BuildCommandSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php index db991e982..a05d731ce 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildConsumptionExtensionsPassTest.php @@ -72,7 +72,7 @@ public function testShouldRegisterClientExtension() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -99,7 +99,7 @@ public function testShouldIgnoreOtherClientExtensions() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -125,7 +125,7 @@ public function testShouldAddExtensionIfClientAll() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -151,7 +151,7 @@ public function testShouldTreatTagsWithoutClientAsDefaultClient() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -247,7 +247,7 @@ public function testShouldMergeWithAddedPreviously() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertCount(4, $extensions->getArgument(0)); } @@ -275,12 +275,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingExtensi $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $fooExtensions->getArgument(0)); + $this->assertIsArray($fooExtensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $fooExtensions->getArgument(0)); - $this->assertInternalType('array', $barExtensions->getArgument(0)); + $this->assertIsArray($barExtensions->getArgument(0)); $this->assertEquals([ new Reference('aBarExtension'), ], $barExtensions->getArgument(0)); diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php index 74553e6eb..11abc1997 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildProcessorRoutesPassTest.php @@ -112,7 +112,7 @@ public function testShouldRegisterProcessorWithMatchedName() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -136,7 +136,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -160,7 +160,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -180,7 +180,7 @@ public function testShouldRegisterAsTopicProcessor() $pass = new BuildProcessorRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -212,7 +212,7 @@ public function testShouldRegisterAsCommandProcessor() $pass = new BuildProcessorRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -244,7 +244,7 @@ public function testShouldRegisterWithCustomProcessorName() $pass = new BuildProcessorRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -279,7 +279,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection() $pass = new BuildProcessorRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(3, $routeCollection->getArgument(0)); $this->assertEquals( diff --git a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php index 65b64dcc8..2590ab23e 100644 --- a/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/DependencyInjection/BuildTopicSubscriberRoutesPassTest.php @@ -96,7 +96,7 @@ public function testShouldRegisterProcessorWithMatchedName() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -120,7 +120,7 @@ public function testShouldRegisterProcessorWithoutNameToDefaultClient() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -144,7 +144,7 @@ public function testShouldRegisterProcessorIfClientNameEqualsAll() $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); } @@ -166,7 +166,7 @@ public function testShouldRegisterProcessorIfTopicsIsString() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(1, $routeCollection->getArgument(0)); $this->assertEquals( @@ -222,7 +222,7 @@ public function testShouldRegisterProcessorIfTopicsAreStrings() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( @@ -265,7 +265,7 @@ public function testShouldRegisterProcessorIfTopicsAreParamArrays() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( @@ -332,7 +332,7 @@ public function testShouldMergeExtractedRoutesWithAlreadySetInCollection() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(3, $routeCollection->getArgument(0)); $this->assertEquals( @@ -379,7 +379,7 @@ public function testShouldRegister08TopicSubscriber() $pass = new BuildTopicSubscriberRoutesPass(); $pass->process($container); - $this->assertInternalType('array', $routeCollection->getArgument(0)); + $this->assertIsArray($routeCollection->getArgument(0)); $this->assertCount(2, $routeCollection->getArgument(0)); $this->assertEquals( diff --git a/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php b/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php index e7ca3ffd5..539217e94 100644 --- a/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/FlushSpoolProducerListenerTest.php @@ -23,7 +23,7 @@ public function testShouldSubscribeOnKernelTerminateEvent() { $events = FlushSpoolProducerListener::getSubscribedEvents(); - $this->assertInternalType('array', $events); + $this->assertIsArray($events); $this->assertArrayHasKey(KernelEvents::TERMINATE, $events); $this->assertEquals('flushMessages', $events[KernelEvents::TERMINATE]); @@ -33,7 +33,7 @@ public function testShouldSubscribeOnConsoleTerminateEvent() { $events = FlushSpoolProducerListener::getSubscribedEvents(); - $this->assertInternalType('array', $events); + $this->assertIsArray($events); $this->assertArrayHasKey(ConsoleEvents::TERMINATE, $events); $this->assertEquals('flushMessages', $events[ConsoleEvents::TERMINATE]); diff --git a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php index d9935bdf4..71744b2eb 100644 --- a/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/RoutesCommandTest.php @@ -116,7 +116,7 @@ public function testShouldUseFooDriver() '--client' => 'foo', ]); - $this->assertContains('Found 1 routes', $tester->getDisplay()); + $this->assertStringContainsString('Found 1 routes', $tester->getDisplay()); } public function testThrowIfClientNotFound() diff --git a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php index 358206dc7..82345b2bf 100644 --- a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php @@ -78,7 +78,7 @@ public function testShouldCallDriverSetupBrokerMethod() $tester = new CommandTester($command); $tester->execute([]); - $this->assertContains('Broker set up', $tester->getDisplay()); + $this->assertStringContainsString('Broker set up', $tester->getDisplay()); } public function testShouldCallRequestedClientDriverSetupBrokerMethod() @@ -105,7 +105,7 @@ public function testShouldCallRequestedClientDriverSetupBrokerMethod() '--client' => 'foo', ]); - $this->assertContains('Broker set up', $tester->getDisplay()); + $this->assertStringContainsString('Broker set up', $tester->getDisplay()); } public function testShouldThrowIfClientNotFound() diff --git a/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php index 0d30582e1..f9a66129c 100644 --- a/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/SimpleSetupBrokerCommandTest.php @@ -74,7 +74,7 @@ public function testShouldCallDriverSetupBrokerMethod() $tester = new CommandTester($command); $tester->execute([]); - $this->assertContains('Broker set up', $tester->getDisplay()); + $this->assertStringContainsString('Broker set up', $tester->getDisplay()); } /** diff --git a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php index b26b4481f..1030d90c8 100644 --- a/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php +++ b/pkg/enqueue/Tests/Symfony/DependencyInjection/BuildConsumptionExtensionsPassTest.php @@ -72,7 +72,7 @@ public function testShouldRegisterTransportExtension() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -99,7 +99,7 @@ public function testShouldIgnoreOtherTransportExtensions() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -125,7 +125,7 @@ public function testShouldAddExtensionIfTransportAll() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $extensions->getArgument(0)); @@ -151,7 +151,7 @@ public function testShouldTreatTagsWithoutTransportAsDefaultTransport() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), new Reference('aBarExtension'), @@ -247,7 +247,7 @@ public function testShouldMergeWithAddedPreviously() $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $extensions->getArgument(0)); + $this->assertIsArray($extensions->getArgument(0)); $this->assertCount(4, $extensions->getArgument(0)); } @@ -275,12 +275,12 @@ public function testShouldRegisterProcessorWithMatchedNameToCorrespondingRegistr $pass = new BuildConsumptionExtensionsPass(); $pass->process($container); - $this->assertInternalType('array', $fooExtensions->getArgument(0)); + $this->assertIsArray($fooExtensions->getArgument(0)); $this->assertEquals([ new Reference('aFooExtension'), ], $fooExtensions->getArgument(0)); - $this->assertInternalType('array', $barExtensions->getArgument(0)); + $this->assertIsArray($barExtensions->getArgument(0)); $this->assertEquals([ new Reference('aBarExtension'), ], $barExtensions->getArgument(0)); diff --git a/pkg/enqueue/Tests/Util/UUIDTest.php b/pkg/enqueue/Tests/Util/UUIDTest.php index ac3090315..f21693e78 100644 --- a/pkg/enqueue/Tests/Util/UUIDTest.php +++ b/pkg/enqueue/Tests/Util/UUIDTest.php @@ -11,7 +11,7 @@ public function testShouldGenerateUniqueId() { $uuid = UUID::generate(); - $this->assertInternalType('string', $uuid); + $this->assertIsString($uuid); $this->assertEquals(36, strlen($uuid)); } From d17dfa606dfd8d058f3d0d9e22922635536c1e3c Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Fri, 8 Jan 2021 12:34:02 +0200 Subject: [PATCH 19/20] [php8][tests] Replace phpunit's assertArraySubset by extension's method as this assertion was removed from phpunit 9.5 --- .../Tests/SignalSocketHelperTest.php | 2 +- .../DependencyInjection/ConfigurationTest.php | 45 ++++++++++--------- .../Profiler/MessageQueueCollectorTest.php | 3 +- pkg/rdkafka/Tests/JsonSerializerTest.php | 2 +- pkg/redis/Tests/Spec/JsonSerializerTest.php | 2 +- pkg/wamp/Tests/Spec/JsonSerializerTest.php | 2 +- 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php index 10903d47d..f87f646c6 100644 --- a/pkg/amqp-tools/Tests/SignalSocketHelperTest.php +++ b/pkg/amqp-tools/Tests/SignalSocketHelperTest.php @@ -76,7 +76,7 @@ public function testShouldRegisterHandlerOnBeforeSocketAndBackupCurrentOne() $handlers = $this->readAttribute($this->signalHelper, 'handlers'); - $this->assertInternalType('array', $handlers); + $this->assertIsArray($handlers); $this->assertArrayHasKey(SIGTERM, $handlers); $this->assertSame($handler, $handlers[SIGTERM]); } diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php index 3f3aae8ee..d641227ef 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Bundle\Tests\Unit\DependencyInjection; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Bundle\DependencyInjection\Configuration; use Enqueue\Test\ClassExtensionTrait; use PHPUnit\Framework\TestCase; @@ -222,7 +223,7 @@ public function testJobShouldBeDisabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'job' => [ 'enabled' => false, @@ -243,7 +244,7 @@ public function testCouldEnableJob() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'job' => true, ], @@ -261,7 +262,7 @@ public function testDoctrinePingConnectionExtensionShouldBeDisabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_ping_connection_extension' => false, @@ -284,7 +285,7 @@ public function testDoctrinePingConnectionExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_ping_connection_extension' => true, @@ -304,7 +305,7 @@ public function testDoctrineClearIdentityMapExtensionShouldBeDisabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_clear_identity_map_extension' => false, @@ -327,7 +328,7 @@ public function testDoctrineClearIdentityMapExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_clear_identity_map_extension' => true, @@ -347,7 +348,7 @@ public function testDoctrineOdmClearIdentityMapExtensionShouldBeDisabledByDefaul ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_odm_clear_identity_map_extension' => false, @@ -370,7 +371,7 @@ public function testDoctrineOdmClearIdentityMapExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_odm_clear_identity_map_extension' => true, @@ -390,7 +391,7 @@ public function testDoctrineClosedEntityManagerExtensionShouldBeDisabledByDefaul ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_closed_entity_manager_extension' => false, @@ -413,7 +414,7 @@ public function testDoctrineClosedEntityManagerExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'doctrine_closed_entity_manager_extension' => true, @@ -433,7 +434,7 @@ public function testResetServicesExtensionShouldBeDisabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'reset_services_extension' => false, @@ -456,7 +457,7 @@ public function testResetServicesExtensionCouldBeEnabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'reset_services_extension' => true, @@ -478,7 +479,7 @@ public function testSignalExtensionShouldBeEnabledIfPcntlExtensionIsLoaded() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'signal_extension' => $isLoaded, @@ -501,7 +502,7 @@ public function testSignalExtensionCouldBeDisabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'signal_extension' => false, @@ -521,7 +522,7 @@ public function testReplyExtensionShouldBeEnabledByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'reply_extension' => true, @@ -544,7 +545,7 @@ public function testReplyExtensionCouldBeDisabled() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'extensions' => [ 'reply_extension' => false, @@ -564,7 +565,7 @@ public function testShouldDisableAsyncEventsByDefault() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'async_events' => [ 'enabled' => false, @@ -586,7 +587,7 @@ public function testShouldAllowEnableAsyncEvents() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'async_events' => [ 'enabled' => true, @@ -603,7 +604,7 @@ public function testShouldAllowEnableAsyncEvents() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'async_events' => [ 'enabled' => true, @@ -623,7 +624,7 @@ public function testShouldSetDefaultConfigurationForConsumption() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'consumption' => [ 'receive_timeout' => 10000, @@ -646,7 +647,7 @@ public function testShouldAllowConfigureConsumption() ], ]]); - $this->assertArraySubset([ + Assert::assertArraySubset([ 'default' => [ 'consumption' => [ 'receive_timeout' => 456, @@ -657,6 +658,6 @@ public function testShouldAllowConfigureConsumption() private function assertConfigEquals(array $expected, array $actual): void { - $this->assertArraySubset($expected, $actual, false, var_export($actual, true)); + Assert::assertArraySubset($expected, $actual, false, var_export($actual, true)); } } diff --git a/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php b/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php index 96d4bc940..55f415d03 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Bundle\Tests\Unit\Profiler; +use DMS\PHPUnitExtensions\ArraySubset\Assert; use Enqueue\Bundle\Profiler\MessageQueueCollector; use Enqueue\Client\MessagePriority; use Enqueue\Client\ProducerInterface; @@ -59,7 +60,7 @@ public function testShouldReturnSentMessageArrayTakenFromTraceableProducers() $collector->collect(new Request(), new Response()); - $this->assertArraySubset( + Assert::assertArraySubset( [ 'foo' => [ [ diff --git a/pkg/rdkafka/Tests/JsonSerializerTest.php b/pkg/rdkafka/Tests/JsonSerializerTest.php index 6513a2257..84f09a698 100644 --- a/pkg/rdkafka/Tests/JsonSerializerTest.php +++ b/pkg/rdkafka/Tests/JsonSerializerTest.php @@ -43,7 +43,7 @@ public function testThrowIfFailedToEncodeMessageToJson() $resource = fopen(__FILE__, 'r'); //guard - $this->assertInternalType('resource', $resource); + $this->assertIsResource($resource); $message = new RdKafkaMessage('theBody', ['aProp' => $resource]); diff --git a/pkg/redis/Tests/Spec/JsonSerializerTest.php b/pkg/redis/Tests/Spec/JsonSerializerTest.php index 7516090a9..e374ea170 100644 --- a/pkg/redis/Tests/Spec/JsonSerializerTest.php +++ b/pkg/redis/Tests/Spec/JsonSerializerTest.php @@ -43,7 +43,7 @@ public function testThrowIfFailedToEncodeMessageToJson() $resource = fopen(__FILE__, 'r'); //guard - $this->assertInternalType('resource', $resource); + $this->assertIsResource($resource); $message = new RedisMessage('theBody', ['aProp' => $resource]); diff --git a/pkg/wamp/Tests/Spec/JsonSerializerTest.php b/pkg/wamp/Tests/Spec/JsonSerializerTest.php index 1e7e29413..eaa3c6bc2 100644 --- a/pkg/wamp/Tests/Spec/JsonSerializerTest.php +++ b/pkg/wamp/Tests/Spec/JsonSerializerTest.php @@ -43,7 +43,7 @@ public function testThrowIfFailedToEncodeMessageToJson() $resource = fopen(__FILE__, 'r'); //guard - $this->assertInternalType('resource', $resource); + $this->assertIsResource($resource); $message = new WampMessage('theBody', ['aProp' => $resource]); From d836014f74539d60371ecbb0e427daccd2802b14 Mon Sep 17 00:00:00 2001 From: Valentyn Saik Date: Fri, 8 Jan 2021 13:03:07 +0200 Subject: [PATCH 20/20] [php8][tests] Added ReadAttributeTrait to test proper configuration parsing --- .../Tests/DbalConnectionFactoryConfigTest.php | 2 ++ pkg/gps/Tests/GpsConnectionFactoryConfigTest.php | 4 +++- pkg/test/ReadAttributeTrait.php | 15 +++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 pkg/test/ReadAttributeTrait.php diff --git a/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php b/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php index fb5cae5d5..dda690f9f 100644 --- a/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php +++ b/pkg/dbal/Tests/DbalConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Dbal\DbalConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class DbalConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { diff --git a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php index a1700f64f..d45b3b3f9 100644 --- a/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php +++ b/pkg/gps/Tests/GpsConnectionFactoryConfigTest.php @@ -4,6 +4,7 @@ use Enqueue\Gps\GpsConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use Enqueue\Test\ReadAttributeTrait; use PHPUnit\Framework\TestCase; /** @@ -12,6 +13,7 @@ class GpsConnectionFactoryConfigTest extends TestCase { use ClassExtensionTrait; + use ReadAttributeTrait; public function testThrowNeitherArrayStringNorNullGivenAsConfig() { @@ -47,7 +49,7 @@ public function testShouldParseConfigurationAsExpected($config, $expectedConfig) { $factory = new GpsConnectionFactory($config); - $this->assertAttributeEquals($expectedConfig, 'config', $factory); + self::assertEquals($expectedConfig, $this->readAttribute($factory, 'config')); } public static function provideConfigs() diff --git a/pkg/test/ReadAttributeTrait.php b/pkg/test/ReadAttributeTrait.php new file mode 100644 index 000000000..333193206 --- /dev/null +++ b/pkg/test/ReadAttributeTrait.php @@ -0,0 +1,15 @@ +setAccessible(true); + $value = $refProperty->getValue($object); + $refProperty->setAccessible(false); + return $value; + } +}