From 4cedf24c8b04dedc78b337569607a303ab4c70cf Mon Sep 17 00:00:00 2001 From: Alejandro Perez Favieres Date: Fri, 4 Oct 2024 11:40:04 +0100 Subject: [PATCH 1/2] fix test --- Makefile | 6 ++-- Tests/BaseKernelTestCase.php | 3 +- .../Consumers/AsyncQueueConsumerTest.php | 10 ++++-- .../DB/Dbal/DbalStepsProviderTest.php | 18 +++++----- .../Consumers/AbstractAsyncConsumerTest.php | 36 ++++++++++++------- .../Messages/DelayedExchangeEnvelopeTest.php | 2 +- .../ControlFlow/DelayInterceptorTest.php | 15 ++++---- .../SmokeTests/DatabaseSmokeTestTest.php | 4 +-- 8 files changed, 57 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 87d5df64..401fb7c5 100644 --- a/Makefile +++ b/Makefile @@ -31,8 +31,8 @@ start: ## Start the project $(DOCKER_COMPOSE) up -d --remove-orphans --no-recreate useradd: ## Add your host user to the container - $(EXEC_SUDO_PHP) groupadd -f -g $(shell id -g) $(USER_NAME) - $(EXEC_SUDO_PHP) useradd -u $(shell id -u) -g $(shell id -g) -m $(USER_NAME) + $(EXEC_SUDO_PHP) groupadd -f -g $(shell id -g) $(USER_NAME) 2> /dev/null + $(EXEC_SUDO_PHP) useradd -u $(shell id -u) -g $(shell id -g) -m $(USER_NAME) 2> /dev/null stop: ## Stop the project $(DOCKER_COMPOSE) stop @@ -44,7 +44,7 @@ clear-cache: $(EXEC_SUDO_PHP) bash -c 'rm -rf var/cache/*' vendor: - $(EXEC_PHP) composer install --prefer-dist + $(EXEC_PHP) composer install test: $(EXEC_PHP) php ./bin/phpunit diff --git a/Tests/BaseKernelTestCase.php b/Tests/BaseKernelTestCase.php index 8b14b321..fba17d89 100644 --- a/Tests/BaseKernelTestCase.php +++ b/Tests/BaseKernelTestCase.php @@ -7,6 +7,7 @@ use Smartbox\Integration\FrameworkBundle\Core\Messages\Context; use Symfony\Bridge\Doctrine\RegistryInterface; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Class BaseKernelTestCase. @@ -23,7 +24,7 @@ protected function setUp() $this->helper = $this->getContainer()->get('smartesb.helper'); } - public function getContainer() + public function getContainer(): ContainerInterface { return self::$kernel->getContainer(); } diff --git a/Tests/Functional/Consumers/AsyncQueueConsumerTest.php b/Tests/Functional/Consumers/AsyncQueueConsumerTest.php index 4421b0e9..6319f987 100644 --- a/Tests/Functional/Consumers/AsyncQueueConsumerTest.php +++ b/Tests/Functional/Consumers/AsyncQueueConsumerTest.php @@ -4,7 +4,9 @@ namespace Smartbox\Integration\FrameworkBundle\Tests\Functional\Consumers; +use Smartbox\Integration\FrameworkBundle\Components\Queues\AsyncQueueConsumer; use Smartbox\Integration\FrameworkBundle\Components\Queues\Drivers\AsyncQueueDriverInterface; +use Smartbox\Integration\FrameworkBundle\Components\Queues\Drivers\QueueDriverInterface; use Smartbox\Integration\FrameworkBundle\Components\Queues\QueueMessage; use Smartbox\Integration\FrameworkBundle\Components\Queues\QueueProtocol; use Smartbox\Integration\FrameworkBundle\Core\Endpoints\Endpoint; @@ -21,12 +23,14 @@ class AsyncQueueConsumerTest extends BaseKernelTestCase { const QUEUE = '/test/async'; - private function getConsumer() + private function getConsumer(): AsyncQueueConsumer { - return $this->helper->getConsumer('async_queue'); + /** @var AsyncQueueConsumer $consumer */ + $consumer = $this->helper->getConsumer('async_queue'); + return $consumer; } - private function getQueueDriver(string $queueDriverName): AsyncQueueDriverInterface + private function getQueueDriver(string $queueDriverName): QueueDriverInterface { return $this->helper->getQueueDriver($queueDriverName); } diff --git a/Tests/Unit/Components/DB/Dbal/DbalStepsProviderTest.php b/Tests/Unit/Components/DB/Dbal/DbalStepsProviderTest.php index bbec2d45..e17d6100 100644 --- a/Tests/Unit/Components/DB/Dbal/DbalStepsProviderTest.php +++ b/Tests/Unit/Components/DB/Dbal/DbalStepsProviderTest.php @@ -4,7 +4,8 @@ use Doctrine\Bundle\DoctrineBundle\Registry; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Driver\PDO\Statement; +use Doctrine\DBAL\Result; use Smartbox\Integration\FrameworkBundle\Components\DB\Dbal\DbalStepsProvider; use Smartbox\Integration\FrameworkBundle\Configurability\ConfigurableServiceHelper; @@ -55,20 +56,21 @@ public function testDoctrineGetConnection(array $context, array $options, $conne $parameters = []; $sql = 'SELECT test FROM test'; - $stmt = $this->getMockBuilder(Statement::class)->getMock(); - $stmt->expects($this->once()) + $pdoStatement = $this->createMock(\PDOStatement::class); + $pdoStatement->expects($this->once()) ->method('columnCount') - ->will($this->returnValue(1)); - $stmt->expects($this->once()) + ->willReturn(1); + $pdoStatement->expects($this->once()) ->method('fetchAll') - ->will($this->returnValue(['test' => 1])); + ->willReturn(['test' => 1]); $dbal = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() ->getMock(); + $result = new Result(new \Doctrine\DBAL\Driver\PDO\Result($pdoStatement), $dbal); $dbal->expects($this->once()) ->method('executeQuery') - ->will($this->returnValue($stmt)); + ->willReturn($result); $doctrine = $this->getMockBuilder(Registry::class) ->disableOriginalConstructor() @@ -76,7 +78,7 @@ public function testDoctrineGetConnection(array $context, array $options, $conne $doctrine->expects($this->once()) ->method('getConnection') ->with($connectionName) - ->will($this->returnValue($dbal)); + ->willReturn($dbal); $confHelper = $this->getMockBuilder(ConfigurableServiceHelper::class)->getMock(); $confHelper->expects($this->exactly(2)) diff --git a/Tests/Unit/Core/Consumers/AbstractAsyncConsumerTest.php b/Tests/Unit/Core/Consumers/AbstractAsyncConsumerTest.php index 2bf39722..6a444fe9 100644 --- a/Tests/Unit/Core/Consumers/AbstractAsyncConsumerTest.php +++ b/Tests/Unit/Core/Consumers/AbstractAsyncConsumerTest.php @@ -89,11 +89,12 @@ function () use ($consumer) { */ public function testConsumerDoesNotSleepWhenFlagIsSet() { - $consumer = $this->getConsumer(new QueueMessage(), 2); + $endpoint = $this->createMock(EndpointInterface::class); + $consumer = $this->getConsumer(new QueueMessage(), 2, $endpoint); $stopwatch = new Stopwatch(); $stopwatch->start('consume'); - $consumer->consume($this->createMock(EndpointInterface::class)); + $consumer->consume($endpoint); $stopwatch->stop('consume'); $this->assertLessThanOrEqual(AbstractAsyncConsumer::SLEEP_DURATION / 1000, $stopwatch->getEvent('consume')->getDuration(), 'Consumer took longer than expected to consume a message, most likely it ignored the sleep flag.'); @@ -108,15 +109,17 @@ public function testCallbackMeasuresProcessingDuration() $dispatcher->expects($this->once()) ->method('dispatch') ->with( - $this->isType('string'), + TimingEvent::CONSUMER_TIMING, $this->callback(function (TimingEvent $event) { - return $event->getIntervalMs() > 0; + return $event->getIntervalMs() == 0; })); + $endpoint = $this->createMock(EndpointInterface::class); /** @var AbstractAsyncConsumer|MockObject $consumer */ - $consumer = $this->getConsumer(new QueueMessage(), 1); + $consumer = $this->getConsumer(new QueueMessage(), 1, $endpoint); $consumer->setEventDispatcher($dispatcher); - $consumer->consume($this->createMock(EndpointInterface::class)); + + $consumer->consume($endpoint); } /** @@ -125,7 +128,8 @@ public function testCallbackMeasuresProcessingDuration() public function testMessageIsConfirmedAfterProcessing() { $message = new QueueMessage(); - $consumer = $this->getConsumer($message, 1); + $endpoint = $this->createMock(EndpointInterface::class); + $consumer = $this->getConsumer($message, 1, $endpoint); $consumer->expects($this->once()) ->method('confirmMessage') @@ -133,7 +137,7 @@ public function testMessageIsConfirmedAfterProcessing() $this->anything(), $this->equalTo($message)); - $consumer->consume($this->createMock(EndpointInterface::class)); + $consumer->consume($endpoint); } /** @@ -142,13 +146,13 @@ public function testMessageIsConfirmedAfterProcessing() public function testMessageIsNotConfirmedAfterFailedProcessing() { $this->expectException(\RuntimeException::class); + $endpoint = $this->createMock(EndpointInterface::class); $message = new QueueMessage(); - $consumer = $this->getConsumer($message); + $consumer = $this->getConsumer($message, -1, $endpoint); $consumer->expects($this->never()) ->method('confirmMessage'); - $endpoint = $this->createMock(EndpointInterface::class); $endpoint->expects($this->once()) ->method('handle') ->willThrowException(new \RuntimeException()); @@ -178,23 +182,29 @@ public function testConsumerWillNotThrowExceptionIfItHasBeenStopped() /** * @param MessageInterface $message Message to pass to the callback * @param int $rounds Amount of messages to consume before stopping + * @return AbstractAsyncConsumer|MockObject */ - private function getConsumer(MessageInterface $message, int $rounds = -1): MockObject + private function getConsumer(MessageInterface $message, int $rounds = -1, EndpointInterface $endpoint): AbstractAsyncConsumer { $consumer = $this->getMockForAbstractClass(AbstractAsyncConsumer::class); /** @var \Closure $callback */ $callback = null; + $consumer->expects($this->once()) ->method('asyncConsume') ->with( - $this->anything(), + $endpoint ?? $this->anything(), // Steal the callback so we can call it manually and pretend we are "consuming" $this->callback(function ($stolenCallback) use (&$callback) { - return $callback = $stolenCallback; + $this->isInstanceOf(\Closure::class); + $callback = $stolenCallback; + return true; })); + $consumer->expects(-1 === $rounds ? $this->any() : $this->exactly($rounds)) ->method('waitNoBlock') + ->with($endpoint) ->willReturnCallback(function () use (&$callback, $consumer, $message) { $callback($message); }); diff --git a/Tests/Unit/Core/Messages/DelayedExchangeEnvelopeTest.php b/Tests/Unit/Core/Messages/DelayedExchangeEnvelopeTest.php index e244f9bd..0a19b0b2 100644 --- a/Tests/Unit/Core/Messages/DelayedExchangeEnvelopeTest.php +++ b/Tests/Unit/Core/Messages/DelayedExchangeEnvelopeTest.php @@ -28,7 +28,7 @@ protected function setUp() $exchange = new Exchange($message); - $this->delayedExchangeEnvelope = new DelayedExchangeEnvelope($exchange); + $this->delayedExchangeEnvelope = new DelayedExchangeEnvelope($exchange, 1); } protected function tearDown() diff --git a/Tests/Unit/Core/Processors/ControlFlow/DelayInterceptorTest.php b/Tests/Unit/Core/Processors/ControlFlow/DelayInterceptorTest.php index 02f6d429..3a6f68db 100644 --- a/Tests/Unit/Core/Processors/ControlFlow/DelayInterceptorTest.php +++ b/Tests/Unit/Core/Processors/ControlFlow/DelayInterceptorTest.php @@ -13,7 +13,7 @@ /** * Class DelayInterceptorTest. * - * @coversDefaultClass \Smartbox\Integration\FrameworkBundle\Core\Processors\ControlFlow\DelayInterceptorTest + * @coversDefaultClass \Smartbox\Integration\FrameworkBundle\Core\Processors\ControlFlow\DelayInterceptor */ class DelayInterceptorTest extends \PHPUnit\Framework\TestCase { @@ -28,20 +28,23 @@ public function testExceptionsDelayIsSet() ->getMock(); $eventDispatcherMock = $this->createMock(EventDispatcher::class); - $throttlerMock->setEventDispatcher($eventDispatcherMock); + $throttlerMock->method('getEventDispatcher') + ->willReturn($eventDispatcherMock); - $exchange = new Exchange(new Message(new TestEntity())); + $message = new Message(new TestEntity()); + $message->setHeader('delay', 10); + + $exchange = new Exchange($message); //We do not use expectException, instead we want to actually inspect what is in the exception - $thrown = false; try { $throttlerMock->process($exchange); } catch (\Exception $e) { - $thrown = true; $this->assertInstanceOf(ProcessingException::class, $e); $this->assertInstanceOf(DelayException::class, $e->getOriginalException()); + return; } - $this->assertTrue($thrown, 'Process did not throw an exception'); + $this->fail('Process did not throw an exception'); } } diff --git a/Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php b/Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php index 423f835a..a0dd01cf 100644 --- a/Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php +++ b/Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php @@ -4,7 +4,7 @@ use Doctrine\Common\Persistence\ConnectionRegistry; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Schema\AbstractSchemaManager; use PHPUnit\Framework\TestCase; use Smartbox\CoreBundle\Utils\SmokeTest\Output\SmokeTestOutputInterface; @@ -89,7 +89,7 @@ public function testFailedRun() private function getConnection($throw = false) { $method = 'willThrowException'; - $expected = new DBALException('Black Hawk 64 is going down, I repeat, Black Hawk 64 is going dow...'); + $expected = new Exception('Black Hawk 64 is going down, I repeat, Black Hawk 64 is going dow...'); if (!$throw) { $method = 'willReturn'; From 14ae5a0e6895555e514cf5f3ff7bf59978677cc4 Mon Sep 17 00:00:00 2001 From: Alejandro Perez Favieres Date: Fri, 4 Oct 2024 14:16:04 +0100 Subject: [PATCH 2/2] bump phpunit to 8.5 --- .gitignore | 1 + Components/Queues/Drivers/AmqpQueueDriver.php | 6 ++++++ Core/Processors/Routing/ContentRouter.php | 8 ++++++++ Tests/BaseKernelTestCase.php | 2 +- Tests/Functional/Consumers/AsyncQueueConsumerTest.php | 3 ++- Tests/Functional/Consumers/QueueConsumerTest.php | 4 ++-- .../Drivers/Queue/AbstractQueueDriverTest.php | 4 ++-- .../Functional/Handlers/DeferredEventsHandlerTest.php | 2 +- Tests/Functional/Handlers/MessageHandlerTest.php | 2 +- Tests/Functional/ProcessorTest.php | 2 +- .../Functional/Producers/ConfigurableProducerTest.php | 2 +- .../Producers/JsonFileLoaderProducerTest.php | 2 +- .../Producers/RestConfigurableProducerTest.php | 2 +- .../StepProviders/CsvConfigurableStepsProviderTest.php | 6 +++--- Tests/Functional/Storage/Driver/MongoDBDriverTest.php | 4 ++-- .../Tools/Evaluator/ExpressionEvaluatorTest.php | 4 ++-- Tests/Functional/Tools/Mapper/MapperTest.php | 4 ++-- Tests/Unit/Command/ConsumeCommandTest.php | 10 +++++----- .../Unit/Components/DB/DBConfigurableConsumerTest.php | 2 +- .../DB/Dbal/ConfigurableDbalProtocolTest.php | 4 ++-- .../Unit/Components/DB/Dbal/DbalStepsProviderTest.php | 4 ++-- .../WebService/Rest/RestConfigurableProducerTest.php | 2 +- .../WebService/Soap/ParseHeadersTraitTest.php | 6 +++--- Tests/Unit/Core/Handlers/MessageHandlerTest.php | 4 ++-- Tests/Unit/Core/Itinerary/ItineraryResolverTest.php | 4 ++-- Tests/Unit/Core/Itinerary/ItineraryTest.php | 4 ++-- Tests/Unit/Core/Messages/ContextTest.php | 4 +--- .../Unit/Core/Messages/DelayedExchangeEnvelopeTest.php | 4 ++-- Tests/Unit/Core/Messages/ExchangeEnvelopeTest.php | 4 ++-- Tests/Unit/Core/Messages/RetryExchangeEnvelopeTest.php | 4 ++-- .../Core/Processors/ControlFlow/ThrowExceptionTest.php | 4 ++-- .../Unit/Core/Processors/Miscellaneous/ProcessTest.php | 4 ++-- .../Core/Processors/Routing/ConditionalClauseTest.php | 4 ++-- .../Unit/Core/Processors/Routing/ContentRouterTest.php | 6 +++--- Tests/Unit/Core/Processors/Routing/MulticastTest.php | 4 ++-- Tests/Unit/Core/Processors/Routing/PipelineTest.php | 4 ++-- .../Unit/Core/Processors/Routing/RecipientListTest.php | 4 ++-- .../Core/Processors/Transformation/TransformerTest.php | 4 ++-- Tests/Unit/Core/Producers/DirectProducerTest.php | 4 ++-- Tests/Unit/Events/EventDispatcherTest.php | 2 +- Tests/Unit/Events/EventTest.php | 2 +- Tests/Unit/Events/HandlerEventTest.php | 2 +- Tests/Unit/Events/ProcessingErrorEventTest.php | 4 ++-- Tests/Unit/Storage/Driver/MongoDBDateHandlerTest.php | 2 +- Tests/Unit/Tools/Evaluator/ApcuParserCacheTest.php | 4 ++-- Tests/Unit/Tools/Evaluator/ExpressionEvaluatorTest.php | 2 +- Tests/Unit/Tools/Logs/EventsLoggerListenerTest.php | 4 ++-- Tests/Unit/Tools/Mapper/MapperTest.php | 4 ++-- Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php | 2 +- Tests/Unit/Traits/UsesEvaluatorTest.php | 2 +- Tests/Unit/Traits/UsesEventDispatcherTest.php | 2 +- Tests/Unit/Traits/UsesSerializerTest.php | 2 +- Tests/Unit/Traits/UsesValidatorTest.php | 2 +- composer.json | 7 ++++--- phpunit.xml.dist | 8 +++----- 55 files changed, 108 insertions(+), 95 deletions(-) diff --git a/.gitignore b/.gitignore index 1bb76567..9d445176 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ composer.lock # PHP CS Fixer .php_cs.cache +/.phpunit.result.cache diff --git a/Components/Queues/Drivers/AmqpQueueDriver.php b/Components/Queues/Drivers/AmqpQueueDriver.php index f23de294..04f6c921 100644 --- a/Components/Queues/Drivers/AmqpQueueDriver.php +++ b/Components/Queues/Drivers/AmqpQueueDriver.php @@ -307,4 +307,10 @@ protected function validateConnection() { return $this->stream instanceof AbstractConnection; } + + public function purge(string $queue): void + { + $this->declareChannel(); + $this->channel->queue_purge($queue); + } } diff --git a/Core/Processors/Routing/ContentRouter.php b/Core/Processors/Routing/ContentRouter.php index f1040a60..8831df7e 100644 --- a/Core/Processors/Routing/ContentRouter.php +++ b/Core/Processors/Routing/ContentRouter.php @@ -91,4 +91,12 @@ protected function onPostProcessEvent(ProcessEvent $event) $condition = $event->getProcessingContext()->get(self::CONDITION_MATCHED); $event->setEventDetails('Matched condition: '.$condition); } + + /** + * @return ConditionalClause[] + */ + public function clauses(): array + { + return $this->clauses; + } } diff --git a/Tests/BaseKernelTestCase.php b/Tests/BaseKernelTestCase.php index fba17d89..3f1dde72 100644 --- a/Tests/BaseKernelTestCase.php +++ b/Tests/BaseKernelTestCase.php @@ -17,7 +17,7 @@ class BaseKernelTestCase extends KernelTestCase /** @var SmartesbHelper */ protected $helper; - protected function setUp() + protected function setUp(): void { $this->bootKernel(); $this->getContainer()->set('doctrine', $this->createMock(RegistryInterface::class)); diff --git a/Tests/Functional/Consumers/AsyncQueueConsumerTest.php b/Tests/Functional/Consumers/AsyncQueueConsumerTest.php index 6319f987..2cb19736 100644 --- a/Tests/Functional/Consumers/AsyncQueueConsumerTest.php +++ b/Tests/Functional/Consumers/AsyncQueueConsumerTest.php @@ -44,6 +44,7 @@ public function testConsume() $serializer = $consumer->getSerializer(); $queueDriver = $this->getQueueDriver('amqp'); $queueDriver->connect(); + $queueDriver->purge(self::QUEUE); $message = $this->createMessage(new EntityX(333)); $queueMessage = new QueueMessage(); @@ -72,7 +73,7 @@ public function testConsume() $consumer->consume($endpoint); $output = $this->getActualOutput(); - $this->assertNotContains('A message was consumed', $output); + $this->assertStringNotContainsString('A message was consumed', $output); } /** diff --git a/Tests/Functional/Consumers/QueueConsumerTest.php b/Tests/Functional/Consumers/QueueConsumerTest.php index 92b4a474..8a8bfe20 100644 --- a/Tests/Functional/Consumers/QueueConsumerTest.php +++ b/Tests/Functional/Consumers/QueueConsumerTest.php @@ -127,7 +127,7 @@ function (Endpoint $endpoint) use ($queues) { \pcntl_alarm(0); $output = $this->getActualOutput(); - $this->assertNotContains('A message was consumed', $output); // The consumer should not display message information if no logger + $this->assertStringNotContainsString('A message was consumed', $output); // The consumer should not display message information if no logger } /** @@ -197,6 +197,6 @@ function (Endpoint $endpoint) use ($queues) { \pcntl_alarm(0); $output = $this->getActualOutput(); - $this->assertNotContains('A message was consumed', $output); // The consumer should not display message information with NullLogger + $this->assertStringNotContainsString('A message was consumed', $output); // The consumer should not display message information with NullLogger } } diff --git a/Tests/Functional/Drivers/Queue/AbstractQueueDriverTest.php b/Tests/Functional/Drivers/Queue/AbstractQueueDriverTest.php index bee24773..bc1fb60b 100644 --- a/Tests/Functional/Drivers/Queue/AbstractQueueDriverTest.php +++ b/Tests/Functional/Drivers/Queue/AbstractQueueDriverTest.php @@ -29,7 +29,7 @@ abstract class AbstractQueueDriverTest extends BaseTestCase */ protected $driver; - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->driver = $this->createDriver(); @@ -37,7 +37,7 @@ protected function setUp() $this->queueName = static::QUEUE_PREFIX.(new \ReflectionClass($this->driver))->getShortName().md5(random_bytes(10)); } - protected function tearDown() + protected function tearDown(): void { $this->driver->disconnect(); $this->driver = null; diff --git a/Tests/Functional/Handlers/DeferredEventsHandlerTest.php b/Tests/Functional/Handlers/DeferredEventsHandlerTest.php index 6b21028b..ed24ac58 100644 --- a/Tests/Functional/Handlers/DeferredEventsHandlerTest.php +++ b/Tests/Functional/Handlers/DeferredEventsHandlerTest.php @@ -23,7 +23,7 @@ class DeferredEventsHandlerTest extends \PHPUnit\Framework\TestCase /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject */ public $eventDispatcherMock; - public function setUp() + public function setUp(): void { $this->eventDispatcherMock = $this->createMock(EventDispatcherInterface::class); $this->handler = new DeferredEventsHandler(); diff --git a/Tests/Functional/Handlers/MessageHandlerTest.php b/Tests/Functional/Handlers/MessageHandlerTest.php index e7bc6ea6..e6958ef8 100644 --- a/Tests/Functional/Handlers/MessageHandlerTest.php +++ b/Tests/Functional/Handlers/MessageHandlerTest.php @@ -45,7 +45,7 @@ class MessageHandlerTest extends \PHPUnit\Framework\TestCase /** @var MessageFactoryInterface */ public $factory; - protected function setUp() + protected function setUp(): void { $this->eventDispatcherMock = $this->createMock(EventDispatcherInterface::class); $this->handler = new MessageHandler(); diff --git a/Tests/Functional/ProcessorTest.php b/Tests/Functional/ProcessorTest.php index 752521ca..0a034117 100644 --- a/Tests/Functional/ProcessorTest.php +++ b/Tests/Functional/ProcessorTest.php @@ -17,7 +17,7 @@ abstract public function getInvalidMessages(); abstract public function getWorkingMessages(); - public function setUp() + public function setUp(): void { parent::setUp(); $this->processor = $this->createProcessor(); diff --git a/Tests/Functional/Producers/ConfigurableProducerTest.php b/Tests/Functional/Producers/ConfigurableProducerTest.php index 92f382ad..6f80cd7d 100644 --- a/Tests/Functional/Producers/ConfigurableProducerTest.php +++ b/Tests/Functional/Producers/ConfigurableProducerTest.php @@ -67,7 +67,7 @@ class ConfigurableProducerTest extends BaseTestCase ], ]; - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/Tests/Functional/Producers/JsonFileLoaderProducerTest.php b/Tests/Functional/Producers/JsonFileLoaderProducerTest.php index 86ae3b32..e1ebbc25 100644 --- a/Tests/Functional/Producers/JsonFileLoaderProducerTest.php +++ b/Tests/Functional/Producers/JsonFileLoaderProducerTest.php @@ -14,7 +14,7 @@ class JsonFileLoaderProducerTest extends BaseTestCase /** @var JsonFileLoaderProducer */ protected $producer; - public function setUp() + public function setUp(): void { parent::setUp(); $this->producer = new JsonFileLoaderProducer(); diff --git a/Tests/Functional/Producers/RestConfigurableProducerTest.php b/Tests/Functional/Producers/RestConfigurableProducerTest.php index 3cb17c2d..e9b3e260 100644 --- a/Tests/Functional/Producers/RestConfigurableProducerTest.php +++ b/Tests/Functional/Producers/RestConfigurableProducerTest.php @@ -25,7 +25,7 @@ class RestConfigurableProducerTest extends BaseTestCase /** @var RestConfigurableProducer */ protected $producer; - public function setUp() + public function setUp(): void { parent::setUp(); $producer = new RestConfigurableProducer(); diff --git a/Tests/Functional/StepProviders/CsvConfigurableStepsProviderTest.php b/Tests/Functional/StepProviders/CsvConfigurableStepsProviderTest.php index 44638d78..08039e98 100644 --- a/Tests/Functional/StepProviders/CsvConfigurableStepsProviderTest.php +++ b/Tests/Functional/StepProviders/CsvConfigurableStepsProviderTest.php @@ -26,7 +26,7 @@ class CsvConfigurableStepsProviderTest extends BaseTestCase /** * {@inheritdoc} */ - public function setUp() + public function setUp(): void { parent::setUp(); @@ -41,7 +41,7 @@ public function setUp() /** * {@inheritdoc} */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); //create a temporary folder @@ -51,7 +51,7 @@ public static function setUpBeforeClass() /** * {@inheritdoc} */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { $files = \glob(self::TMP_FOLDER.'*'); foreach ($files as $file) { diff --git a/Tests/Functional/Storage/Driver/MongoDBDriverTest.php b/Tests/Functional/Storage/Driver/MongoDBDriverTest.php index 064298fd..7d1909b5 100644 --- a/Tests/Functional/Storage/Driver/MongoDBDriverTest.php +++ b/Tests/Functional/Storage/Driver/MongoDBDriverTest.php @@ -33,7 +33,7 @@ class MongoDBDriverTest extends KernelTestCase /** @var NoSQLDriverInterface */ protected static $storageDriver; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { if (!\extension_loaded('mongodb')) { self::markTestSkipped( @@ -55,7 +55,7 @@ public static function setUpBeforeClass() parent::setUpBeforeClass(); } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { self::$storageDriver = null; parent::tearDownAfterClass(); diff --git a/Tests/Functional/Tools/Evaluator/ExpressionEvaluatorTest.php b/Tests/Functional/Tools/Evaluator/ExpressionEvaluatorTest.php index c6f98b31..12dbe282 100644 --- a/Tests/Functional/Tools/Evaluator/ExpressionEvaluatorTest.php +++ b/Tests/Functional/Tools/Evaluator/ExpressionEvaluatorTest.php @@ -20,13 +20,13 @@ class ExpressionEvaluatorTest extends KernelTestCase */ protected $evaluator; - protected function setUp() + protected function setUp(): void { $this->bootKernel(); $this->evaluator = static::$kernel->getContainer()->get('smartesb.util.evaluator'); } - protected function tearDown() + protected function tearDown(): void { $this->evaluator = null; } diff --git a/Tests/Functional/Tools/Mapper/MapperTest.php b/Tests/Functional/Tools/Mapper/MapperTest.php index 4092b94d..6ee46e18 100644 --- a/Tests/Functional/Tools/Mapper/MapperTest.php +++ b/Tests/Functional/Tools/Mapper/MapperTest.php @@ -17,13 +17,13 @@ class MapperTest extends BaseTestCase /** @var Mapper|MapperInterface */ protected $mapper; - public function setUp() + public function setUp(): void { $this->bootKernel(['debug' => false]); $this->mapper = $this->getContainer()->get('smartesb.util.mapper'); } - public function tearDown() + public function tearDown(): void { $this->mapper = null; } diff --git a/Tests/Unit/Command/ConsumeCommandTest.php b/Tests/Unit/Command/ConsumeCommandTest.php index 3e8070cc..9f1a54a2 100644 --- a/Tests/Unit/Command/ConsumeCommandTest.php +++ b/Tests/Unit/Command/ConsumeCommandTest.php @@ -17,7 +17,7 @@ class ConsumeCommandTest extends KernelTestCase const NB_MESSAGES = 1; const URI = 'queue://main/api'; - protected function setUp() + protected function setUp(): void { self::bootKernel(); self::$kernel->getContainer()->set('doctrine', $this->createMock(RegistryInterface::class)); @@ -49,8 +49,8 @@ public function testExecuteWithKillAfter() ]); $output = $commandTester->getDisplay(); - $this->assertContains('limited to', $output); - $this->assertContains('Consumer was gracefully stopped', $output); + $this->assertStringContainsString('limited to', $output); + $this->assertStringContainsString('Consumer was gracefully stopped', $output); } public function testExecuteWithoutKillAfter() @@ -68,7 +68,7 @@ public function testExecuteWithoutKillAfter() ]); $output = $commandTester->getDisplay(); - $this->assertNotContains('limited to', $output); - $this->assertContains('Consumer was gracefully stopped', $output); + $this->assertStringNotContainsString('limited to', $output); + $this->assertStringContainsString('Consumer was gracefully stopped', $output); } } diff --git a/Tests/Unit/Components/DB/DBConfigurableConsumerTest.php b/Tests/Unit/Components/DB/DBConfigurableConsumerTest.php index 0fde2c41..89fe68e0 100644 --- a/Tests/Unit/Components/DB/DBConfigurableConsumerTest.php +++ b/Tests/Unit/Components/DB/DBConfigurableConsumerTest.php @@ -39,7 +39,7 @@ class DBConfigurableConsumerTest extends \PHPUnit\Framework\TestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { $this->messageFactory = $this->createMock(MessageFactory::class); $this->stepProvider = $this->createMock(ConfigurableStepsProviderInterface::class); diff --git a/Tests/Unit/Components/DB/Dbal/ConfigurableDbalProtocolTest.php b/Tests/Unit/Components/DB/Dbal/ConfigurableDbalProtocolTest.php index ce537d6e..837be81b 100644 --- a/Tests/Unit/Components/DB/Dbal/ConfigurableDbalProtocolTest.php +++ b/Tests/Unit/Components/DB/Dbal/ConfigurableDbalProtocolTest.php @@ -20,7 +20,7 @@ class ConfigurableDbalProtocolTest extends \PHPUnit\Framework\TestCase */ private $expectedOptions; - protected function setUp() + protected function setUp(): void { $this->dbalProtocol = new ConfigurableDbalProtocol(); $this->expectedOptions = [ @@ -33,7 +33,7 @@ protected function setUp() ]; } - protected function tearDown() + protected function tearDown(): void { $this->dbalProtocol = null; $this->expectedOptions = null; diff --git a/Tests/Unit/Components/DB/Dbal/DbalStepsProviderTest.php b/Tests/Unit/Components/DB/Dbal/DbalStepsProviderTest.php index e17d6100..efd2e5c0 100644 --- a/Tests/Unit/Components/DB/Dbal/DbalStepsProviderTest.php +++ b/Tests/Unit/Components/DB/Dbal/DbalStepsProviderTest.php @@ -13,12 +13,12 @@ class DbalStepsProviderTest extends \PHPUnit\Framework\TestCase { private $dbalStepsProvider; - protected function setUp() + protected function setUp(): void { $this->dbalStepsProvider = new DbalStepsProvider(); } - protected function tearDown() + protected function tearDown(): void { $this->dbalStepsProvider = null; } diff --git a/Tests/Unit/Components/WebService/Rest/RestConfigurableProducerTest.php b/Tests/Unit/Components/WebService/Rest/RestConfigurableProducerTest.php index 44a578ef..e8273408 100644 --- a/Tests/Unit/Components/WebService/Rest/RestConfigurableProducerTest.php +++ b/Tests/Unit/Components/WebService/Rest/RestConfigurableProducerTest.php @@ -41,7 +41,7 @@ class RestConfigurableProducerTest extends \PHPUnit\Framework\TestCase /** @var EventDispatcher */ private $eventDispatcher; - public function setUp() + public function setUp(): void { $this->client = $this->getMockBuilder(ClientInterface::class)->getMock(); $this->evaluator = $this->getMockBuilder(ExpressionEvaluator::class) diff --git a/Tests/Unit/Components/WebService/Soap/ParseHeadersTraitTest.php b/Tests/Unit/Components/WebService/Soap/ParseHeadersTraitTest.php index 0d26a76d..89680007 100644 --- a/Tests/Unit/Components/WebService/Soap/ParseHeadersTraitTest.php +++ b/Tests/Unit/Components/WebService/Soap/ParseHeadersTraitTest.php @@ -29,7 +29,7 @@ class ParseHeadersTraitTest extends TestCase Request::METHOD_TRACE, ]; - public function setUp() + public function setUp(): void { $this->parseTrait = $this->getMockForTrait(ParseHeadersTrait::class); } @@ -42,7 +42,7 @@ public function testParseHeadersToArray($header, $expected) { $result = $this->parseTrait->parseHeadersToArray($header); - $this->assertInternalType('array', $result, 'The parser should return an array'); + $this->assertIsArray($result, 'The parser should return an array'); $this->assertNotEmpty($result, 'The parser should not return an empty array'); $this->assertEquals($expected, $result, 'The parser did not returned the same as expected.'); } @@ -55,7 +55,7 @@ public function testUnParseHeadersToArray($data) { $result = $this->parseTrait->parseHeadersToArray($data); - $this->assertInternalType('array', $result, 'The parser should return an array'); + $this->assertIsArray($result, 'The parser should return an array'); $this->assertTrue(\is_array($result), 'The parser should return an array'); $this->assertCount(0, $result, 'The parser should return an empty array'); } diff --git a/Tests/Unit/Core/Handlers/MessageHandlerTest.php b/Tests/Unit/Core/Handlers/MessageHandlerTest.php index d5cdd1b2..1ebb8c9d 100644 --- a/Tests/Unit/Core/Handlers/MessageHandlerTest.php +++ b/Tests/Unit/Core/Handlers/MessageHandlerTest.php @@ -23,12 +23,12 @@ class MessageHandlerTest extends \PHPUnit\Framework\TestCase /** @var MessageHandler */ private $messageHandler; - protected function setUp() + protected function setUp(): void { $this->messageHandler = new MessageHandler(); } - protected function tearDown() + protected function tearDown(): void { $this->messageHandler = null; } diff --git a/Tests/Unit/Core/Itinerary/ItineraryResolverTest.php b/Tests/Unit/Core/Itinerary/ItineraryResolverTest.php index b34b0956..01c0ebda 100644 --- a/Tests/Unit/Core/Itinerary/ItineraryResolverTest.php +++ b/Tests/Unit/Core/Itinerary/ItineraryResolverTest.php @@ -12,12 +12,12 @@ class ItineraryResolverTest extends \PHPUnit\Framework\TestCase /** @var ItineraryResolver */ private $itineraryResolver; - protected function setUp() + protected function setUp(): void { $this->itineraryResolver = new ItineraryResolver(); } - protected function tearDown() + protected function tearDown(): void { $this->itineraryResolver = null; } diff --git a/Tests/Unit/Core/Itinerary/ItineraryTest.php b/Tests/Unit/Core/Itinerary/ItineraryTest.php index d3187bc0..8fde97cd 100644 --- a/Tests/Unit/Core/Itinerary/ItineraryTest.php +++ b/Tests/Unit/Core/Itinerary/ItineraryTest.php @@ -14,12 +14,12 @@ class ItineraryTest extends \PHPUnit\Framework\TestCase /** @var Itinerary */ private $itinerary; - protected function setUp() + protected function setUp(): void { $this->itinerary = new Itinerary(); } - protected function tearDown() + protected function tearDown(): void { $this->itinerary = null; } diff --git a/Tests/Unit/Core/Messages/ContextTest.php b/Tests/Unit/Core/Messages/ContextTest.php index 50b5c001..4fe91ac1 100644 --- a/Tests/Unit/Core/Messages/ContextTest.php +++ b/Tests/Unit/Core/Messages/ContextTest.php @@ -29,11 +29,9 @@ public function testItShouldBeConstructedWithAnArray() $this->assertEquals('bar', $context->get(Context::ORIGINAL_FROM)); } - /** - * @expectedException \InvalidArgumentException - */ public function testItShouldNotBeConstructedWithOtherThings() { + $this->expectException(\InvalidArgumentException::class); new Context(new \stdClass()); } } diff --git a/Tests/Unit/Core/Messages/DelayedExchangeEnvelopeTest.php b/Tests/Unit/Core/Messages/DelayedExchangeEnvelopeTest.php index 0a19b0b2..7a4289bd 100644 --- a/Tests/Unit/Core/Messages/DelayedExchangeEnvelopeTest.php +++ b/Tests/Unit/Core/Messages/DelayedExchangeEnvelopeTest.php @@ -14,7 +14,7 @@ class DelayedExchangeEnvelopeTest extends \PHPUnit\Framework\TestCase /** @var DelayedExchangeEnvelope */ private $delayedExchangeEnvelope; - protected function setUp() + protected function setUp(): void { /** @var Context|\PHPUnit_Framework_MockObject_MockObject $context */ $context = $this->createMock(Context::class); @@ -31,7 +31,7 @@ protected function setUp() $this->delayedExchangeEnvelope = new DelayedExchangeEnvelope($exchange, 1); } - protected function tearDown() + protected function tearDown(): void { $this->delayedExchangeEnvelope = null; } diff --git a/Tests/Unit/Core/Messages/ExchangeEnvelopeTest.php b/Tests/Unit/Core/Messages/ExchangeEnvelopeTest.php index 36497e46..3167b5e6 100644 --- a/Tests/Unit/Core/Messages/ExchangeEnvelopeTest.php +++ b/Tests/Unit/Core/Messages/ExchangeEnvelopeTest.php @@ -13,7 +13,7 @@ class ExchangeEnvelopeTest extends \PHPUnit\Framework\TestCase /** @var ExchangeEnvelope */ private $exchangeEnvelope; - protected function setUp() + protected function setUp(): void { /** @var Context|\PHPUnit_Framework_MockObject_MockObject $context */ $context = $this->createMock(Context::class); @@ -30,7 +30,7 @@ protected function setUp() $this->exchangeEnvelope = new ExchangeEnvelope($exchange); } - protected function tearDown() + protected function tearDown(): void { $this->exchangeEnvelope = null; } diff --git a/Tests/Unit/Core/Messages/RetryExchangeEnvelopeTest.php b/Tests/Unit/Core/Messages/RetryExchangeEnvelopeTest.php index 31c0822a..8b18f115 100644 --- a/Tests/Unit/Core/Messages/RetryExchangeEnvelopeTest.php +++ b/Tests/Unit/Core/Messages/RetryExchangeEnvelopeTest.php @@ -14,7 +14,7 @@ class RetryExchangeEnvelopeTest extends \PHPUnit\Framework\TestCase /** @var RetryExchangeEnvelope */ private $retryExchangeEnvelope; - protected function setUp() + protected function setUp(): void { /** @var Context|\PHPUnit_Framework_MockObject_MockObject $context */ $context = $this->createMock(Context::class); @@ -31,7 +31,7 @@ protected function setUp() $this->retryExchangeEnvelope = new RetryExchangeEnvelope($exchange); } - protected function tearDown() + protected function tearDown(): void { $this->retryExchangeEnvelope = null; } diff --git a/Tests/Unit/Core/Processors/ControlFlow/ThrowExceptionTest.php b/Tests/Unit/Core/Processors/ControlFlow/ThrowExceptionTest.php index 2a03025c..80130fcb 100644 --- a/Tests/Unit/Core/Processors/ControlFlow/ThrowExceptionTest.php +++ b/Tests/Unit/Core/Processors/ControlFlow/ThrowExceptionTest.php @@ -22,7 +22,7 @@ class ThrowExceptionTest extends \PHPUnit\Framework\TestCase /** @var ThrowException */ private $throwException; - protected function setUp() + protected function setUp(): void { /** @var EventDispatcherInterface|\PHPUnit_Framework_MockObject_MockObject $eventDispatcherMock */ $eventDispatcherMock = $this->createMock(EventDispatcher::class); @@ -31,7 +31,7 @@ protected function setUp() $this->throwException->setEventDispatcher($eventDispatcherMock); } - protected function tearDown() + protected function tearDown(): void { $this->throwException = null; } diff --git a/Tests/Unit/Core/Processors/Miscellaneous/ProcessTest.php b/Tests/Unit/Core/Processors/Miscellaneous/ProcessTest.php index 2e6c0fb0..c3624386 100644 --- a/Tests/Unit/Core/Processors/Miscellaneous/ProcessTest.php +++ b/Tests/Unit/Core/Processors/Miscellaneous/ProcessTest.php @@ -24,7 +24,7 @@ class ProcessTest extends \PHPUnit\Framework\TestCase */ public $factory; - protected function setUp() + protected function setUp(): void { $this->eventDispatcherMock = $this->createMock(EventDispatcherInterface::class); @@ -35,7 +35,7 @@ protected function setUp() $this->factory->setFlowsVersion(0); } - protected function tearDown() + protected function tearDown(): void { $this->processProcessor = null; } diff --git a/Tests/Unit/Core/Processors/Routing/ConditionalClauseTest.php b/Tests/Unit/Core/Processors/Routing/ConditionalClauseTest.php index 6a7a401b..43b0a5ef 100644 --- a/Tests/Unit/Core/Processors/Routing/ConditionalClauseTest.php +++ b/Tests/Unit/Core/Processors/Routing/ConditionalClauseTest.php @@ -15,12 +15,12 @@ class ConditionalClauseTest extends \PHPUnit\Framework\TestCase /** @var Itinerary */ private $itinerary; - protected function setUp() + protected function setUp(): void { $this->itinerary = new Itinerary(); } - protected function tearDown() + protected function tearDown(): void { $this->itinerary = null; } diff --git a/Tests/Unit/Core/Processors/Routing/ContentRouterTest.php b/Tests/Unit/Core/Processors/Routing/ContentRouterTest.php index a0416a7e..718cc9dc 100644 --- a/Tests/Unit/Core/Processors/Routing/ContentRouterTest.php +++ b/Tests/Unit/Core/Processors/Routing/ContentRouterTest.php @@ -19,12 +19,12 @@ class ContentRouterTest extends \PHPUnit\Framework\TestCase /** @var ContentRouter */ private $contentRouter; - protected function setUp() + protected function setUp(): void { $this->contentRouter = new ContentRouter(); } - protected function tearDown() + protected function tearDown(): void { $this->contentRouter = null; } @@ -55,7 +55,7 @@ public function testAddWhen(array $whenClauses) $this->contentRouter->addWhen($whenClause->getCondition(), $whenClause->getItinerary()); } - $this->assertAttributeEquals($whenClauses, 'clauses', $this->contentRouter); + $this->assertEquals($whenClauses, $this->contentRouter->clauses()); } /** diff --git a/Tests/Unit/Core/Processors/Routing/MulticastTest.php b/Tests/Unit/Core/Processors/Routing/MulticastTest.php index b3beabb0..6b571e34 100644 --- a/Tests/Unit/Core/Processors/Routing/MulticastTest.php +++ b/Tests/Unit/Core/Processors/Routing/MulticastTest.php @@ -16,12 +16,12 @@ class MulticastTest extends \PHPUnit\Framework\TestCase /** @var Multicast */ private $multicast; - protected function setUp() + protected function setUp(): void { $this->multicast = new Multicast(); } - protected function tearDown() + protected function tearDown(): void { $this->multicast = null; } diff --git a/Tests/Unit/Core/Processors/Routing/PipelineTest.php b/Tests/Unit/Core/Processors/Routing/PipelineTest.php index a9699800..7801dd3e 100644 --- a/Tests/Unit/Core/Processors/Routing/PipelineTest.php +++ b/Tests/Unit/Core/Processors/Routing/PipelineTest.php @@ -15,12 +15,12 @@ class PipelineTest extends \PHPUnit\Framework\TestCase /** @var Pipeline */ private $pipeline; - protected function setUp() + protected function setUp(): void { $this->pipeline = new Pipeline(); } - protected function tearDown() + protected function tearDown(): void { $this->pipeline = null; } diff --git a/Tests/Unit/Core/Processors/Routing/RecipientListTest.php b/Tests/Unit/Core/Processors/Routing/RecipientListTest.php index 58bd1c69..e948b38b 100644 --- a/Tests/Unit/Core/Processors/Routing/RecipientListTest.php +++ b/Tests/Unit/Core/Processors/Routing/RecipientListTest.php @@ -24,12 +24,12 @@ class RecipientListTest extends TestCase /** @var RecipientList */ private $recipientList; - protected function setUp() + protected function setUp(): void { $this->recipientList = new RecipientList(); } - protected function tearDown() + protected function tearDown(): void { $this->recipientList = null; } diff --git a/Tests/Unit/Core/Processors/Transformation/TransformerTest.php b/Tests/Unit/Core/Processors/Transformation/TransformerTest.php index d266f236..88c3133d 100644 --- a/Tests/Unit/Core/Processors/Transformation/TransformerTest.php +++ b/Tests/Unit/Core/Processors/Transformation/TransformerTest.php @@ -19,7 +19,7 @@ class TransformerTest extends KernelTestCase /** @var Transformer */ private $transformer; - protected function setUp() + protected function setUp(): void { static::bootKernel(); $container = static::$kernel->getContainer(); @@ -32,7 +32,7 @@ protected function setUp() $this->transformer->setEvaluator($container->get('smartesb.util.evaluator')); } - protected function tearDown() + protected function tearDown(): void { $this->transformer = null; } diff --git a/Tests/Unit/Core/Producers/DirectProducerTest.php b/Tests/Unit/Core/Producers/DirectProducerTest.php index 4d585a25..8d7391f3 100644 --- a/Tests/Unit/Core/Producers/DirectProducerTest.php +++ b/Tests/Unit/Core/Producers/DirectProducerTest.php @@ -12,12 +12,12 @@ class DirectProducerTest extends \PHPUnit\Framework\TestCase /** @var DirectProducer */ private $directProducer; - protected function setUp() + protected function setUp(): void { $this->directProducer = new DirectProducer(); } - protected function tearDown() + protected function tearDown(): void { $this->directProducer = null; } diff --git a/Tests/Unit/Events/EventDispatcherTest.php b/Tests/Unit/Events/EventDispatcherTest.php index f50c0d4e..1a7c2729 100644 --- a/Tests/Unit/Events/EventDispatcherTest.php +++ b/Tests/Unit/Events/EventDispatcherTest.php @@ -156,7 +156,7 @@ public function testShouldNotDeferEventIfDoesNotPassFilter() $this->assertCount(0, $messages); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); ArrayQueueDriver::$array = []; diff --git a/Tests/Unit/Events/EventTest.php b/Tests/Unit/Events/EventTest.php index 5036d568..79ea6f0e 100644 --- a/Tests/Unit/Events/EventTest.php +++ b/Tests/Unit/Events/EventTest.php @@ -12,7 +12,7 @@ class EventTest extends \PHPUnit\Framework\TestCase /** @var Event|\PHPUnit_Framework_MockObject_MockObject */ private $event; - public function setup() + public function setup(): void { $this->event = $this->getMockBuilder(Event::class) ->enableOriginalConstructor() diff --git a/Tests/Unit/Events/HandlerEventTest.php b/Tests/Unit/Events/HandlerEventTest.php index 28dc4ee9..584dbb42 100644 --- a/Tests/Unit/Events/HandlerEventTest.php +++ b/Tests/Unit/Events/HandlerEventTest.php @@ -13,7 +13,7 @@ class HandlerEventTest extends \PHPUnit\Framework\TestCase /** @var HandlerEvent|\PHPUnit_Framework_MockObject_MockObject */ private $event; - public function setup() + public function setup(): void { $this->event = $this->getMockForAbstractClass(HandlerEvent::class); } diff --git a/Tests/Unit/Events/ProcessingErrorEventTest.php b/Tests/Unit/Events/ProcessingErrorEventTest.php index 8b63fe3f..a6333b18 100644 --- a/Tests/Unit/Events/ProcessingErrorEventTest.php +++ b/Tests/Unit/Events/ProcessingErrorEventTest.php @@ -27,7 +27,7 @@ class ProcessingErrorEventTest extends \PHPUnit\Framework\TestCase /** @var string */ private $name; - protected function setUp() + protected function setUp(): void { $this->processor = $this->createMock(Processor::class); $this->exchange = $this->createMock(Exchange::class); @@ -39,7 +39,7 @@ protected function setUp() $this->event->setTimestampToCurrent(); } - protected function tearDown() + protected function tearDown(): void { $this->processor = null; $this->exchange = null; diff --git a/Tests/Unit/Storage/Driver/MongoDBDateHandlerTest.php b/Tests/Unit/Storage/Driver/MongoDBDateHandlerTest.php index 4d4031d2..eeb3fe2e 100644 --- a/Tests/Unit/Storage/Driver/MongoDBDateHandlerTest.php +++ b/Tests/Unit/Storage/Driver/MongoDBDateHandlerTest.php @@ -16,7 +16,7 @@ class MongoDBDateHandlerTest extends \PHPUnit\Framework\TestCase /** @var MongoDBDateHandler */ private $handler; - public function setup() + public function setup(): void { if (!\extension_loaded('mongodb')) { $this->markTestSkipped( diff --git a/Tests/Unit/Tools/Evaluator/ApcuParserCacheTest.php b/Tests/Unit/Tools/Evaluator/ApcuParserCacheTest.php index b9dacb6d..e6ed2d6d 100644 --- a/Tests/Unit/Tools/Evaluator/ApcuParserCacheTest.php +++ b/Tests/Unit/Tools/Evaluator/ApcuParserCacheTest.php @@ -13,14 +13,14 @@ class ApcuParserCacheTest extends \PHPUnit\Framework\TestCase { private $cache_key = 'apcu_key_for_testing_purposes'; - protected function setUp() + protected function setUp(): void { if (!$this->apcuEnabled()) { $this->markTestSkipped('There is no APCu extension enabled.'); } } - protected function tearDown() + protected function tearDown(): void { if ($this->apcuEnabled()) { \apcu_delete($this->cache_key); diff --git a/Tests/Unit/Tools/Evaluator/ExpressionEvaluatorTest.php b/Tests/Unit/Tools/Evaluator/ExpressionEvaluatorTest.php index 8b4187dd..dfd15cdd 100644 --- a/Tests/Unit/Tools/Evaluator/ExpressionEvaluatorTest.php +++ b/Tests/Unit/Tools/Evaluator/ExpressionEvaluatorTest.php @@ -27,7 +27,7 @@ public function testEvaluateCatchesAndRethrowsEvaluationErrors() $failingExpression = 'expression'; $this->expectException(\RuntimeException::class); - $this->expectExceptionMessageRegExp("/.*'expression'\\. Original Message.*/"); + $this->expectExceptionMessageMatches("/.*'expression'\\. Original Message.*/"); $evaluator = new ExpressionEvaluator($language); $evaluator->evaluateWithVars($failingExpression, []); diff --git a/Tests/Unit/Tools/Logs/EventsLoggerListenerTest.php b/Tests/Unit/Tools/Logs/EventsLoggerListenerTest.php index 629032c3..a5297715 100644 --- a/Tests/Unit/Tools/Logs/EventsLoggerListenerTest.php +++ b/Tests/Unit/Tools/Logs/EventsLoggerListenerTest.php @@ -26,7 +26,7 @@ class EventsLoggerListenerTest extends \PHPUnit\Framework\TestCase /** @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $logger; - protected function setUp() + protected function setUp(): void { /** @var RequestStack|\PHPUnit_Framework_MockObject_MockObject $requestStack */ $requestStack = $this->createMock(RequestStack::class); @@ -35,7 +35,7 @@ protected function setUp() $this->listener = new EventsLoggerListener($this->logger, $requestStack); } - protected function tearDown() + protected function tearDown(): void { $this->logger = null; $this->listener = null; diff --git a/Tests/Unit/Tools/Mapper/MapperTest.php b/Tests/Unit/Tools/Mapper/MapperTest.php index cd26ff1e..31892905 100644 --- a/Tests/Unit/Tools/Mapper/MapperTest.php +++ b/Tests/Unit/Tools/Mapper/MapperTest.php @@ -11,12 +11,12 @@ class MapperTest extends \PHPUnit\Framework\TestCase private $mapper; - protected function setUp() + protected function setUp(): void { $this->mapper = new Mapper(); } - protected function tearDown() + protected function tearDown(): void { $this->mapper = null; } diff --git a/Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php b/Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php index a0dd01cf..285363ac 100644 --- a/Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php +++ b/Tests/Unit/Tools/SmokeTests/DatabaseSmokeTestTest.php @@ -28,7 +28,7 @@ class DatabaseSmokeTestTest extends TestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { $this->registry = $this->createMock(ConnectionRegistry::class); $this->smokeTest = new DatabaseSmokeTest($this->registry); diff --git a/Tests/Unit/Traits/UsesEvaluatorTest.php b/Tests/Unit/Traits/UsesEvaluatorTest.php index 0d98e28f..52e0a0be 100644 --- a/Tests/Unit/Traits/UsesEvaluatorTest.php +++ b/Tests/Unit/Traits/UsesEvaluatorTest.php @@ -16,7 +16,7 @@ class UsesEvaluatorTest extends \PHPUnit\Framework\TestCase */ private $fakeObject; - public function setUp() + public function setUp(): void { $this->fakeObject = new FakeTraitsUsage(); } diff --git a/Tests/Unit/Traits/UsesEventDispatcherTest.php b/Tests/Unit/Traits/UsesEventDispatcherTest.php index b6b32869..83016431 100644 --- a/Tests/Unit/Traits/UsesEventDispatcherTest.php +++ b/Tests/Unit/Traits/UsesEventDispatcherTest.php @@ -16,7 +16,7 @@ class UsesEventDispatcherTest extends \PHPUnit\Framework\TestCase */ private $fakeObject; - public function setUp() + public function setUp(): void { $this->fakeObject = new FakeTraitsUsage(); } diff --git a/Tests/Unit/Traits/UsesSerializerTest.php b/Tests/Unit/Traits/UsesSerializerTest.php index 6022ba6a..e8b602e8 100644 --- a/Tests/Unit/Traits/UsesSerializerTest.php +++ b/Tests/Unit/Traits/UsesSerializerTest.php @@ -16,7 +16,7 @@ class UsesSerializerTest extends \PHPUnit\Framework\TestCase */ private $fakeObject; - public function setUp() + public function setUp(): void { $this->fakeObject = new FakeTraitsUsage(); } diff --git a/Tests/Unit/Traits/UsesValidatorTest.php b/Tests/Unit/Traits/UsesValidatorTest.php index 356feeb1..e3122568 100644 --- a/Tests/Unit/Traits/UsesValidatorTest.php +++ b/Tests/Unit/Traits/UsesValidatorTest.php @@ -16,7 +16,7 @@ class UsesValidatorTest extends \PHPUnit\Framework\TestCase */ private $fakeObject; - public function setUp() + public function setUp(): void { $this->fakeObject = new FakeTraitsUsage(); } diff --git a/composer.json b/composer.json index 7473689d..4514e3d9 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ } }, "require": { - "php": ">=7.0", + "php": ">=7.4", "ext-pcntl": "*", "guzzlehttp/guzzle": "^6.0", "smartbox/besimple-soap": "^1.3", @@ -30,8 +30,9 @@ "symfony/monolog-bundle": "^2.4", "symfony/phpunit-bridge": "*", "symfony/stopwatch": "^2.8 || ^3.4", - "phpunit/phpunit": "^7.5", - "symfony/translation": "^4.3.8" + "phpunit/phpunit": "^8.5", + "symfony/translation": "^4.3.8", + "symfony/routing": "^3.4" }, "config": { "bin-dir": "bin" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6ed561de..6e2a949c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,7 +2,7 @@ + + ./Tests/ - - - - .