From 7a6b8b3f446c46f1651b814b8bf7c9cfbcae01aa Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Wed, 19 Apr 2017 22:22:17 +0300 Subject: [PATCH 1/6] [transport] Add redis backed transport. --- composer.json | 11 +- docker-compose.yml | 6 + docker/Dockerfile | 2 +- phpunit.xml.dist | 4 + pkg/amqp-ext/AmqpConnectionFactory.php | 3 +- pkg/enqueue/Rpc/Promise.php | 1 + pkg/fs/FsConsumer.php | 3 + pkg/redis/.gitignore | 6 + pkg/redis/.travis.yml | 21 ++ pkg/redis/LICENSE | 20 ++ pkg/redis/PRedis.php | 66 +++++ pkg/redis/PhpRedis.php | 93 +++++++ pkg/redis/README.md | 18 ++ pkg/redis/Redis.php | 32 +++ pkg/redis/RedisConnectionFactory.php | 91 +++++++ pkg/redis/RedisConsumer.php | 98 +++++++ pkg/redis/RedisContext.php | 128 +++++++++ pkg/redis/RedisDestination.php | 46 ++++ pkg/redis/RedisMessage.php | 233 +++++++++++++++++ pkg/redis/RedisProducer.php | 39 +++ pkg/redis/ServerException.php | 8 + .../Tests/RedisConnectionFactoryTest.php | 60 +++++ pkg/redis/Tests/RedisContextTest.php | 244 ++++++++++++++++++ pkg/redis/Tests/RedisDestinationTest.php | 28 ++ pkg/redis/Tests/RedisMessageTest.php | 179 +++++++++++++ pkg/redis/composer.json | 43 +++ pkg/redis/phpunit.xml.dist | 30 +++ 27 files changed, 1508 insertions(+), 5 deletions(-) create mode 100644 pkg/redis/.gitignore create mode 100644 pkg/redis/.travis.yml create mode 100644 pkg/redis/LICENSE create mode 100644 pkg/redis/PRedis.php create mode 100644 pkg/redis/PhpRedis.php create mode 100644 pkg/redis/README.md create mode 100644 pkg/redis/Redis.php create mode 100644 pkg/redis/RedisConnectionFactory.php create mode 100644 pkg/redis/RedisConsumer.php create mode 100644 pkg/redis/RedisContext.php create mode 100644 pkg/redis/RedisDestination.php create mode 100644 pkg/redis/RedisMessage.php create mode 100644 pkg/redis/RedisProducer.php create mode 100644 pkg/redis/ServerException.php create mode 100644 pkg/redis/Tests/RedisConnectionFactoryTest.php create mode 100644 pkg/redis/Tests/RedisContextTest.php create mode 100644 pkg/redis/Tests/RedisDestinationTest.php create mode 100644 pkg/redis/Tests/RedisMessageTest.php create mode 100644 pkg/redis/composer.json create mode 100644 pkg/redis/phpunit.xml.dist diff --git a/composer.json b/composer.json index 6d4ced0f3..92011f09b 100644 --- a/composer.json +++ b/composer.json @@ -8,14 +8,15 @@ "enqueue/enqueue": "*@dev", "enqueue/stomp": "*@dev", "enqueue/amqp-ext": "*@dev", + "enqueue/redis": "*@dev", "enqueue/fs": "*@dev", "enqueue/enqueue-bundle": "*@dev", "enqueue/job-queue": "*@dev", - "enqueue/test": "*@dev" - }, - "require-dev": { + "enqueue/test": "*@dev", + "phpunit/phpunit": "^5", "doctrine/doctrine-bundle": "~1.2", + "predis/predis": "^1.1", "symfony/monolog-bundle": "^2.8|^3", "symfony/browser-kit": "^2.8|^3", "symfony/expression-language": "^2.8|^3", @@ -46,6 +47,10 @@ "type": "path", "url": "pkg/amqp-ext" }, + { + "type": "path", + "url": "pkg/redis" + }, { "type": "path", "url": "pkg/enqueue-bundle" diff --git a/docker-compose.yml b/docker-compose.yml index e1b47790d..627f99a12 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: depends_on: - rabbitmq - mysql + - redis volumes: - ./:/mqdev environment: @@ -29,6 +30,11 @@ services: - RABBITMQ_DEFAULT_USER=guest - RABBITMQ_DEFAULT_PASS=guest - RABBITMQ_DEFAULT_VHOST=mqdev + redis: + image: 'redis:3' + ports: + - "6379:6379" + mysql: image: mariadb:10 volumes: diff --git a/docker/Dockerfile b/docker/Dockerfile index f07716913..531ff8016 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,7 +4,7 @@ FROM ubuntu:16.04 RUN set -x && \ apt-get update && \ apt-get install -y --no-install-recommends wget curl openssl ca-certificates nano netcat && \ - apt-get install -y --no-install-recommends php php-mysql php-curl php-intl php-mbstring php-zip php-mcrypt php-xdebug php-bcmath php-xml php-amqp + apt-get install -y --no-install-recommends php php-mysql php-redis php-curl php-intl php-mbstring php-zip php-mcrypt php-xdebug php-bcmath php-xml php-amqp ## confis diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fb3be97c3..9e2be5363 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -33,6 +33,10 @@ pkg/fs/Tests + + pkg/redis-ext/Tests + + pkg/enqueue-bundle/Tests diff --git a/pkg/amqp-ext/AmqpConnectionFactory.php b/pkg/amqp-ext/AmqpConnectionFactory.php index 8bff4c62d..4cd75ac62 100644 --- a/pkg/amqp-ext/AmqpConnectionFactory.php +++ b/pkg/amqp-ext/AmqpConnectionFactory.php @@ -26,7 +26,8 @@ class AmqpConnectionFactory implements PsrConnectionFactory * 'read_timeout' => Timeout in for income activity. Note: 0 or greater seconds. May be fractional. * 'write_timeout' => Timeout in for outcome activity. Note: 0 or greater seconds. May be fractional. * 'connect_timeout' => Connection timeout. Note: 0 or greater seconds. May be fractional. - * 'persisted' => bool + * 'persisted' => bool, Whether it use single persisted connection or open a new one for every context + * 'lazy' => the connection will be performed as later as possible, if the option set to true * ]. * * @param $config diff --git a/pkg/enqueue/Rpc/Promise.php b/pkg/enqueue/Rpc/Promise.php index be5fe5250..0c69d37bd 100644 --- a/pkg/enqueue/Rpc/Promise.php +++ b/pkg/enqueue/Rpc/Promise.php @@ -50,6 +50,7 @@ public function getMessage() return $message; } + $this->consumer->reject($message, true); } } diff --git a/pkg/fs/FsConsumer.php b/pkg/fs/FsConsumer.php index 7555686bc..519bf62d8 100644 --- a/pkg/fs/FsConsumer.php +++ b/pkg/fs/FsConsumer.php @@ -2,6 +2,7 @@ namespace Enqueue\Fs; +use Enqueue\Psr\InvalidMessageException; use Enqueue\Psr\PsrConsumer; use Enqueue\Psr\PsrMessage; @@ -118,6 +119,8 @@ public function acknowledge(PsrMessage $message) */ public function reject(PsrMessage $message, $requeue = false) { + InvalidMessageException::assertMessageInstanceOf($message, FsMessage::class); + // do nothing on reject. fs transport always works in auto ack mode if ($requeue) { diff --git a/pkg/redis/.gitignore b/pkg/redis/.gitignore new file mode 100644 index 000000000..a770439e5 --- /dev/null +++ b/pkg/redis/.gitignore @@ -0,0 +1,6 @@ +*~ +/composer.lock +/composer.phar +/phpunit.xml +/vendor/ +/.idea/ diff --git a/pkg/redis/.travis.yml b/pkg/redis/.travis.yml new file mode 100644 index 000000000..42374ddc7 --- /dev/null +++ b/pkg/redis/.travis.yml @@ -0,0 +1,21 @@ +sudo: false + +git: + depth: 1 + +language: php + +php: + - '5.6' + - '7.0' + +cache: + directories: + - $HOME/.composer/cache + +install: + - composer self-update + - composer install --prefer-source + +script: + - vendor/bin/phpunit --exclude-group=functional diff --git a/pkg/redis/LICENSE b/pkg/redis/LICENSE new file mode 100644 index 000000000..27881b7c4 --- /dev/null +++ b/pkg/redis/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) +Copyright (c) 2017 Forma-Pro + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is furnished +to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/pkg/redis/PRedis.php b/pkg/redis/PRedis.php new file mode 100644 index 000000000..a36b05876 --- /dev/null +++ b/pkg/redis/PRedis.php @@ -0,0 +1,66 @@ +redis = $redis; + } + + /** + * {@inheritdoc} + */ + public function lpush($key, $value) + { + try { + $this->redis->lpush($key, [$value]); + } catch (PRedisServerException $e) { + throw new ServerException('lpush command has failed', null, $e); + } + } + + /** + * {@inheritdoc} + */ + public function brpop($key, $timeout) + { + try { + return $this->brpop($key, (int) $timeout / 1000); + } catch (PRedisServerException $e) { + throw new ServerException('brpop command has failed', null, $e); + } + } + + /** + * {@inheritdoc} + */ + public function rpop($key) + { try { + return $this->rpop($key); + } catch (PRedisServerException $e) { + throw new ServerException('rpop command has failed', null, $e); + } + } + + public function connect() + { + $this->redis->connect(); + } + + public function disconnect() + { + $this->redis->disconnect(); + } +} diff --git a/pkg/redis/PhpRedis.php b/pkg/redis/PhpRedis.php new file mode 100644 index 000000000..1c767ffb5 --- /dev/null +++ b/pkg/redis/PhpRedis.php @@ -0,0 +1,93 @@ +redis = $redis; + + $this->config = array_replace([ + 'host' => null, + 'port' => null, + 'timeout' => null, + 'reserved' => null, + 'retry_interval' => null, + 'persisted' => false, + ], $config); + } + + /** + * {@inheritdoc} + */ + public function lpush($key, $value) + { + if (false == $this->redis->lPush($key, $value)) { + throw new ServerException($this->redis->getLastError()); + } + } + + /** + * {@inheritdoc} + */ + public function brpop($key, $timeout) + { + if ($result = $this->redis->brPop([$key], $timeout)) { + return $result[1]; + } + } + + /** + * {@inheritdoc} + */ + public function rpop($key) + { + return $this->redis->rPop($key); + } + + public function connect() + { + if (false == $this->redis) { + $this->redis = new \Redis(); + + if ($this->config['persisted']) { + $this->redis->pconnect( + $this->config['host'], + $this->config['port'], + $this->config['timeout'] + ); + } else { + $this->redis->connect( + $this->config['host'], + $this->config['port'], + $this->config['timeout'], + $this->config['reserved'], + $this->config['retry_interval'] + ); + } + } + + return $this->redis; + } + + public function disconnect() + { + if ($this->redis) { + $this->redis->close(); + } + } +} diff --git a/pkg/redis/README.md b/pkg/redis/README.md new file mode 100644 index 000000000..3b306b226 --- /dev/null +++ b/pkg/redis/README.md @@ -0,0 +1,18 @@ +# Redis Transport + +[![Gitter](https://badges.gitter.im/php-enqueue/Lobby.svg)](https://gitter.im/php-enqueue/Lobby) +[![Build Status](https://travis-ci.org/php-enqueue/redis-ext.png?branch=master)](https://travis-ci.org/php-enqueue/redis-ext) +[![Total Downloads](https://poser.pugx.org/enqueue/redis-ext/d/total.png)](https://packagist.org/packages/enqueue/redis-ext) +[![Latest Stable Version](https://poser.pugx.org/enqueue/redis-ext/version.png)](https://packagist.org/packages/enqueue/redis-ext) + +This is an implementation of PSR specification. It allows you to send and consume message with Redis store as a broker. + +## Resources + +* [Documentation](https://github.com/php-enqueue/enqueue-dev/blob/master/docs/index.md) +* [Questions](https://gitter.im/php-enqueue/Lobby) +* [Issue Tracker](https://github.com/php-enqueue/enqueue-dev/issues) + +## License + +It is released under the [MIT License](LICENSE). \ No newline at end of file diff --git a/pkg/redis/Redis.php b/pkg/redis/Redis.php new file mode 100644 index 000000000..8e69466fa --- /dev/null +++ b/pkg/redis/Redis.php @@ -0,0 +1,32 @@ + can be a host, or the path to a unix domain socket + * 'port' => optional + * 'timeout' => value in seconds (optional, default is 0.0 meaning unlimited) + * 'reserved' => should be null if $retry_interval is specified + * 'retry_interval' => retry interval in milliseconds. + * 'vendor' => 'The library used internally to interact with Redis server + * 'persisted' => bool, Whether it use single persisted connection or open a new one for every context + * 'lazy' => the connection will be performed as later as possible, if the option set to true + * ]. + * + * @param $config + */ + public function __construct(array $config) + { + $this->config = array_replace([ + 'host' => null, + 'port' => null, + 'timeout' => null, + 'reserved' => null, + 'retry_interval' => null, + 'vendor' => 'phpredis', + 'persisted' => false, + 'lazy' => true, + ], $config); + + $supportedVendors = ['predis', 'phpredis']; + if (false == in_array($this->config['vendor'], $supportedVendors)) { + throw new \LogicException(sprintf( + 'Unsupported redis vendor given. It must be either "%s". Got "%s"', + implode('", "', $supportedVendors), + $this->config['vendor'] + )); + } + } + + /** + * {@inheritdoc} + * + * @return RedisContext + */ + public function createContext() + { + if ($this->config['lazy']) { + return new RedisContext(function () { + $redis = $this->createRedis(); + $redis->connect(); + + return $redis; + }); + } + + return new RedisContext($this->createRedis()); + } + + /** + * @return Redis + */ + private function createRedis() + { + if ('phpredis' == $this->config['vendor'] && false == $this->redis) { + $this->redis = new PhpRedis(new \Redis(), $this->config); + } + + if ('predis' == $this->config['vendor'] && false == $this->redis) { + $this->redis = new PRedis(new Client($this->config, ['exceptions' => true])); + } + + return $this->redis; + } +} diff --git a/pkg/redis/RedisConsumer.php b/pkg/redis/RedisConsumer.php new file mode 100644 index 000000000..50cb7bec1 --- /dev/null +++ b/pkg/redis/RedisConsumer.php @@ -0,0 +1,98 @@ +context = $context; + $this->queue = $queue; + } + + /** + * {@inheritdoc} + * + * @return RedisDestination + */ + public function getQueue() + { + return $this->queue; + } + + /** + * {@inheritdoc} + * + * @return RedisMessage|null + */ + public function receive($timeout = 0) + { + if ($message = $this->getRedis()->brpop($this->queue->getName(), (int) $timeout / 1000)) { + return RedisMessage::jsonUnserialize($message); + } + } + + /** + * {@inheritdoc} + * + * @return RedisMessage|null + */ + public function receiveNoWait() + { + if ($message = $this->getRedis()->rpop($this->queue->getName())) { + return RedisMessage::jsonUnserialize($message); + } + } + + /** + * {@inheritdoc} + * + * @param RedisMessage $message + */ + public function acknowledge(PsrMessage $message) + { + // do nothing. redis transport always works in auto ack mode + } + + /** + * {@inheritdoc} + * + * @param RedisMessage $message + */ + public function reject(PsrMessage $message, $requeue = false) + { + InvalidMessageException::assertMessageInstanceOf($message, RedisMessage::class); + + // do nothing on reject. redis transport always works in auto ack mode + + if ($requeue) { + $this->context->createProducer()->send($this->queue, $message); + } + } + + /** + * @return Redis + */ + private function getRedis() + { + return $this->context->getRedis(); + } +} diff --git a/pkg/redis/RedisContext.php b/pkg/redis/RedisContext.php new file mode 100644 index 000000000..370398db8 --- /dev/null +++ b/pkg/redis/RedisContext.php @@ -0,0 +1,128 @@ +redis = $redis; + } elseif (is_callable($redis)) { + $this->redisFactory = $redis; + } else { + throw new \InvalidArgumentException(sprintf( + 'The $redis argument must be either %s or callable that returns $s once called.', + Redis::class, + Redis::class + )); + } + } + + /** + * {@inheritdoc} + * + * @return RedisMessage + */ + public function createMessage($body = '', array $properties = [], array $headers = []) + { + return new RedisMessage($body, $properties, $headers); + } + + /** + * {@inheritdoc} + * + * @return RedisDestination + */ + public function createTopic($topicName) + { + return new RedisDestination($topicName); + } + + /** + * {@inheritdoc} + * + * @return RedisDestination + */ + public function createQueue($queueName) + { + return new RedisDestination($queueName); + } + + /** + * {@inheritdoc} + */ + public function createTemporaryQueue() + { + throw new \LogicException('Not implemented'); + } + + /** + * {@inheritdoc} + * + * @return RedisProducer + */ + public function createProducer() + { + return new RedisProducer($this->getRedis()); + } + + /** + * {@inheritdoc} + * + * @param RedisDestination $destination + * + * @return RedisConsumer + */ + public function createConsumer(PsrDestination $destination) + { + InvalidDestinationException::assertDestinationInstanceOf($destination, RedisDestination::class); + + return new RedisConsumer($this, $destination); + } + + public function close() + { + $this->getRedis()->close(); + } + + /** + * @return Redis + */ + public function getRedis() + { + if (false == $this->redis) { + $redis = call_user_func($this->redisFactory); + if (false == $redis instanceof Redis) { + throw new \LogicException(sprintf( + 'The factory must return instance of %s. It returned %s', + Redis::class, + is_object($redis) ? get_class($redis) : gettype($redis) + )); + } + + $this->redis = $redis; + } + + return $this->redis; + } +} diff --git a/pkg/redis/RedisDestination.php b/pkg/redis/RedisDestination.php new file mode 100644 index 000000000..f89858863 --- /dev/null +++ b/pkg/redis/RedisDestination.php @@ -0,0 +1,46 @@ +name = $name; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * {@inheritdoc} + */ + public function getQueueName() + { + return $this->getName(); + } + + /** + * {@inheritdoc} + */ + public function getTopicName() + { + return $this->getName(); + } +} diff --git a/pkg/redis/RedisMessage.php b/pkg/redis/RedisMessage.php new file mode 100644 index 000000000..24fa3d04f --- /dev/null +++ b/pkg/redis/RedisMessage.php @@ -0,0 +1,233 @@ +body = $body; + $this->properties = $properties; + $this->headers = $headers; + + $this->redelivered = false; + } + + /** + * {@inheritdoc} + */ + public function getBody() + { + return $this->body; + } + + /** + * {@inheritdoc} + */ + public function setBody($body) + { + $this->body = $body; + } + + /** + * {@inheritdoc} + */ + public function setProperties(array $properties) + { + $this->properties = $properties; + } + + /** + * {@inheritdoc} + */ + public function getProperties() + { + return $this->properties; + } + + /** + * {@inheritdoc} + */ + public function setProperty($name, $value) + { + $this->properties[$name] = $value; + } + + /** + * {@inheritdoc} + */ + public function getProperty($name, $default = null) + { + return array_key_exists($name, $this->properties) ? $this->properties[$name] : $default; + } + + /** + * {@inheritdoc} + */ + public function setHeaders(array $headers) + { + $this->headers = $headers; + } + + /** + * {@inheritdoc} + */ + public function getHeaders() + { + return $this->headers; + } + + /** + * {@inheritdoc} + */ + public function setHeader($name, $value) + { + $this->headers[$name] = $value; + } + + /** + * {@inheritdoc} + */ + public function getHeader($name, $default = null) + { + return array_key_exists($name, $this->headers) ? $this->headers[$name] : $default; + } + + /** + * {@inheritdoc} + */ + public function setRedelivered($redelivered) + { + $this->redelivered = (bool) $redelivered; + } + + /** + * {@inheritdoc} + */ + public function isRedelivered() + { + return $this->redelivered; + } + + /** + * {@inheritdoc} + */ + public function setCorrelationId($correlationId) + { + $this->setHeader('correlation_id', $correlationId); + } + + /** + * {@inheritdoc} + */ + public function getCorrelationId() + { + return $this->getHeader('correlation_id'); + } + + /** + * {@inheritdoc} + */ + public function setMessageId($messageId) + { + $this->setHeader('message_id', $messageId); + } + + /** + * {@inheritdoc} + */ + public function getMessageId() + { + return $this->getHeader('message_id'); + } + + /** + * {@inheritdoc} + */ + public function getTimestamp() + { + return $this->getHeader('timestamp'); + } + + /** + * {@inheritdoc} + */ + public function setTimestamp($timestamp) + { + $this->setHeader('timestamp', $timestamp); + } + + /** + * {@inheritdoc} + */ + public function setReplyTo($replyTo) + { + $this->setHeader('reply_to', $replyTo); + } + + /** + * {@inheritdoc} + */ + public function getReplyTo() + { + return $this->getHeader('reply_to'); + } + + /** + * {@inheritdoc} + */ + public function jsonSerialize() + { + return [ + 'body' => $this->getBody(), + 'properties' => $this->getProperties(), + 'headers' => $this->getHeaders(), + ]; + } + + /** + * @param string $json + * + * @return RedisMessage + */ + public static function jsonUnserialize($json) + { + $data = json_decode($json, true); + if (JSON_ERROR_NONE !== json_last_error()) { + throw new \InvalidArgumentException(sprintf( + 'The malformed json given. Error %s and message %s', + json_last_error(), + json_last_error_msg() + )); + } + + return new self($data['body'], $data['properties'], $data['headers']); + } +} diff --git a/pkg/redis/RedisProducer.php b/pkg/redis/RedisProducer.php new file mode 100644 index 000000000..5e745fc05 --- /dev/null +++ b/pkg/redis/RedisProducer.php @@ -0,0 +1,39 @@ +redis = $redis; + } + + /** + * {@inheritdoc} + * + * @param RedisDestination $destination + * @param RedisMessage $message + */ + public function send(PsrDestination $destination, PsrMessage $message) + { + InvalidDestinationException::assertDestinationInstanceOf($destination, RedisDestination::class); + InvalidMessageException::assertMessageInstanceOf($message, RedisMessage::class); + + $this->redis->lpush($destination->getName(), json_encode($message)); + } +} diff --git a/pkg/redis/ServerException.php b/pkg/redis/ServerException.php new file mode 100644 index 000000000..d9bbe1a66 --- /dev/null +++ b/pkg/redis/ServerException.php @@ -0,0 +1,8 @@ +assertClassImplements(PsrConnectionFactory::class, RedisConnectionFactory::class); + } + + public function testCouldBeConstructedWithEmptyConfiguration() + { + $factory = new RedisConnectionFactory([]); + + $this->assertAttributeEquals([ + 'host' => null, + 'port' => null, + 'timeout' => null, + 'reserved' => null, + 'retry_interval' => null, + 'persisted' => false, + 'lazy' => true, + ], 'config', $factory); + } + + public function testCouldBeConstructedWithCustomConfiguration() + { + $factory = new RedisConnectionFactory(['host' => 'theCustomHost']); + + $this->assertAttributeEquals([ + 'host' => 'theCustomHost', + 'port' => null, + 'timeout' => null, + 'reserved' => null, + 'retry_interval' => null, + 'persisted' => false, + 'lazy' => true, + ], 'config', $factory); + } + + public function testShouldCreateLazyContext() + { + $factory = new RedisConnectionFactory(['lazy' => true]); + + $context = $factory->createContext(); + + $this->assertInstanceOf(RedisContext::class, $context); + + $this->assertAttributeEquals(null, 'redis', $context); + $this->assertInternalType('callable', $this->readAttribute($context, 'redisFactory')); + } +} diff --git a/pkg/redis/Tests/RedisContextTest.php b/pkg/redis/Tests/RedisContextTest.php new file mode 100644 index 000000000..945ab31df --- /dev/null +++ b/pkg/redis/Tests/RedisContextTest.php @@ -0,0 +1,244 @@ +assertClassImplements(PsrContext::class, RedisContext::class); + } + + public function testCouldBeConstructedWithExpectedArguments() + { + new RedisContext($this->createRedisMock()); + } + +// public function testShouldAllowCreateEmptyMessage() +// { +// $context = new RedisContext($this->createRedisMock()); +// +// $message = $context->createMessage(); +// +// $this->assertInstanceOf(RedisMessage::class, $message); +// +// $this->assertSame('', $message->getBody()); +// $this->assertSame([], $message->getProperties()); +// $this->assertSame([], $message->getHeaders()); +// } +// +// public function testShouldAllowCreateCustomMessage() +// { +// $context = new RedisContext($this->createRedisMock()); +// +// $message = $context->createMessage('theBody', ['aProp' => 'aPropVal'], ['aHeader' => 'aHeaderVal']); +// +// $this->assertInstanceOf(RedisMessage::class, $message); +// +// $this->assertSame('theBody', $message->getBody()); +// $this->assertSame(['aProp' => 'aPropVal'], $message->getProperties()); +// $this->assertSame(['aHeader' => 'aHeaderVal'], $message->getHeaders()); +// } +// +// public function testShouldCreateQueue() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $queue = $context->createQueue($tmpFile->getFilename()); +// +// $this->assertInstanceOf(RedisDestination::class, $queue); +// $this->assertInstanceOf(\SplFileInfo::class, $queue->getFileInfo()); +// $this->assertSame((string) $tmpFile, (string) $queue->getFileInfo()); +// +// $this->assertSame($tmpFile->getFilename(), $queue->getTopicName()); +// } +// +// public function testShouldAllowCreateTopic() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $topic = $context->createTopic($tmpFile->getFilename()); +// +// $this->assertInstanceOf(RedisDestination::class, $topic); +// $this->assertInstanceOf(\SplFileInfo::class, $topic->getFileInfo()); +// $this->assertSame((string) $tmpFile, (string) $topic->getFileInfo()); +// +// $this->assertSame($tmpFile->getFilename(), $topic->getTopicName()); +// } +// +// public function testShouldAllowCreateTmpQueue() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $queue = $context->createTemporaryQueue(); +// +// $this->assertInstanceOf(RedisDestination::class, $queue); +// $this->assertInstanceOf(TempFile::class, $queue->getFileInfo()); +// $this->assertNotEmpty($queue->getQueueName()); +// } +// +// public function testShouldCreateProducer() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $producer = $context->createProducer(); +// +// $this->assertInstanceOf(RedisProducer::class, $producer); +// } +// +// public function testShouldThrowIfNotRedisDestinationGivenOnCreateConsumer() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $this->expectException(InvalidDestinationException::class); +// $this->expectExceptionMessage('The destination must be an instance of Enqueue\Redis\RedisDestination but got Enqueue\Transport\Null\NullQueue.'); +// $consumer = $context->createConsumer(new NullQueue('aQueue')); +// +// $this->assertInstanceOf(RedisConsumer::class, $consumer); +// } +// +// public function testShouldCreateConsumer() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $queue = $context->createQueue($tmpFile->getFilename()); +// +// $context->createConsumer($queue); +// } +// +// public function testShouldPropagatePreFetchCountToCreatedConsumer() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $queue = $context->createQueue($tmpFile->getFilename()); +// +// $consumer = $context->createConsumer($queue); +// +// // guard +// $this->assertInstanceOf(RedisConsumer::class, $consumer); +// +// $this->assertAttributeSame(123, 'preFetchCount', $consumer); +// } +// +// public function testShouldAllowGetPreFetchCountSetInConstructor() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $this->assertSame(123, $context->getPreFetchCount()); +// } +// +// public function testShouldAllowGetPreviouslySetPreFetchCount() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $context->setPreFetchCount(456); +// +// $this->assertSame(456, $context->getPreFetchCount()); +// } +// +// public function testShouldAllowPurgeMessagesFromQueue() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); +// +// file_put_contents($tmpFile, 'foo'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $queue = $context->createQueue($tmpFile->getFilename()); +// +// $context->purge($queue); +// +// $this->assertEmpty(file_get_contents($tmpFile)); +// } +// +// public function testShouldReleaseAllLocksOnClose() +// { +// new TempFile(sys_get_temp_dir().'/foo'); +// new TempFile(sys_get_temp_dir().'/bar'); +// +// $context = new RedisContext($this->createRedisMock()); +// +// $fooQueue = $context->createQueue('foo'); +// $barQueue = $context->createTopic('bar'); +// +// $this->assertAttributeCount(0, 'lockHandlers', $context); +// +// $context->workWithFile($fooQueue, 'r+', function () { +// }); +// $context->workWithFile($barQueue, 'r+', function () { +// }); +// $context->workWithFile($fooQueue, 'c+', function () { +// }); +// $context->workWithFile($barQueue, 'c+', function () { +// }); +// +// $this->assertAttributeCount(2, 'lockHandlers', $context); +// +// $context->close(); +// +// $this->assertAttributeCount(0, 'lockHandlers', $context); +// } +// +// public function testShouldCreateFileOnFilesystemIfNotExistOnDeclareDestination() +// { +// $tmpFile = new TempFile(sys_get_temp_dir().'/'.uniqid()); +// +// $context = new RedisContext(sys_get_temp_dir(), 1, 0666); +// +// $queue = $context->createQueue($tmpFile->getFilename()); +// +// $this->assertFileNotExists((string) $tmpFile); +// +// $context->declareDestination($queue); +// +// $this->assertFileExists((string) $tmpFile); +// $this->assertTrue(is_readable($tmpFile)); +// $this->assertTrue(is_writable($tmpFile)); +// +// // do nothing if file already exists +// $context->declareDestination($queue); +// +// $this->assertFileExists((string) $tmpFile); +// +// unlink($tmpFile); +// } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|\Redis + */ + private function createRedisMock() + { + return $this->createMock(\Redis::class); + } +} diff --git a/pkg/redis/Tests/RedisDestinationTest.php b/pkg/redis/Tests/RedisDestinationTest.php new file mode 100644 index 000000000..0af02a6ab --- /dev/null +++ b/pkg/redis/Tests/RedisDestinationTest.php @@ -0,0 +1,28 @@ +assertClassImplements(PsrTopic::class, RedisDestination::class); + $this->assertClassImplements(PsrQueue::class, RedisDestination::class); + } + + public function testShouldReturnNameSetInConstructor() + { + $destination = new RedisDestination('aDestinationName'); + + $this->assertSame('aDestinationName', $destination->getName()); + $this->assertSame('aDestinationName', $destination->getQueueName()); + $this->assertSame('aDestinationName', $destination->getTopicName()); + } +} diff --git a/pkg/redis/Tests/RedisMessageTest.php b/pkg/redis/Tests/RedisMessageTest.php new file mode 100644 index 000000000..0e775d0c9 --- /dev/null +++ b/pkg/redis/Tests/RedisMessageTest.php @@ -0,0 +1,179 @@ +assertClassImplements(PsrMessage::class, RedisMessage::class); + } + + public function testShouldImplementJsonSerializableInterface() + { + $this->assertClassImplements(\JsonSerializable::class, RedisMessage::class); + } + + public function testCouldConstructMessageWithBody() + { + $message = new RedisMessage('body'); + + $this->assertSame('body', $message->getBody()); + } + + public function testCouldConstructMessageWithProperties() + { + $message = new RedisMessage('', ['key' => 'value']); + + $this->assertSame(['key' => 'value'], $message->getProperties()); + } + + public function testCouldConstructMessageWithHeaders() + { + $message = new RedisMessage('', [], ['key' => 'value']); + + $this->assertSame(['key' => 'value'], $message->getHeaders()); + } + + public function testCouldSetGetBody() + { + $message = new RedisMessage(); + $message->setBody('body'); + + $this->assertSame('body', $message->getBody()); + } + + public function testCouldSetGetProperties() + { + $message = new RedisMessage(); + $message->setProperties(['key' => 'value']); + + $this->assertSame(['key' => 'value'], $message->getProperties()); + } + + public function testCouldSetGetHeaders() + { + $message = new RedisMessage(); + $message->setHeaders(['key' => 'value']); + + $this->assertSame(['key' => 'value'], $message->getHeaders()); + } + + public function testCouldSetGetRedelivered() + { + $message = new RedisMessage(); + + $message->setRedelivered(true); + $this->assertTrue($message->isRedelivered()); + + $message->setRedelivered(false); + $this->assertFalse($message->isRedelivered()); + } + + public function testCouldSetGetCorrelationId() + { + $message = new RedisMessage(); + $message->setCorrelationId('the-correlation-id'); + + $this->assertSame('the-correlation-id', $message->getCorrelationId()); + } + + public function testShouldSetCorrelationIdAsHeader() + { + $message = new RedisMessage(); + $message->setCorrelationId('the-correlation-id'); + + $this->assertSame(['correlation_id' => 'the-correlation-id'], $message->getHeaders()); + } + + public function testCouldSetGetMessageId() + { + $message = new RedisMessage(); + $message->setMessageId('the-message-id'); + + $this->assertSame('the-message-id', $message->getMessageId()); + } + + public function testCouldSetMessageIdAsHeader() + { + $message = new RedisMessage(); + $message->setMessageId('the-message-id'); + + $this->assertSame(['message_id' => 'the-message-id'], $message->getHeaders()); + } + + public function testCouldSetGetTimestamp() + { + $message = new RedisMessage(); + $message->setTimestamp(12345); + + $this->assertSame(12345, $message->getTimestamp()); + } + + public function testCouldSetTimestampAsHeader() + { + $message = new RedisMessage(); + $message->setTimestamp(12345); + + $this->assertSame(['timestamp' => 12345], $message->getHeaders()); + } + + public function testShouldReturnNullAsDefaultReplyTo() + { + $message = new RedisMessage(); + + $this->assertSame(null, $message->getReplyTo()); + } + + public function testShouldAllowGetPreviouslySetReplyTo() + { + $message = new RedisMessage(); + $message->setReplyTo('theQueueName'); + + $this->assertSame('theQueueName', $message->getReplyTo()); + } + + public function testShouldAllowGetPreviouslySetReplyToAsHeader() + { + $message = new RedisMessage(); + $message->setReplyTo('theQueueName'); + + $this->assertSame(['reply_to' => 'theQueueName'], $message->getHeaders()); + } + + public function testColdBeSerializedToJson() + { + $message = new RedisMessage('theBody', ['thePropFoo' => 'thePropFooVal'], ['theHeaderFoo' => 'theHeaderFooVal']); + + $this->assertEquals('{"body":"theBody","properties":{"thePropFoo":"thePropFooVal"},"headers":{"theHeaderFoo":"theHeaderFooVal"}}', json_encode($message)); + } + + public function testCouldBeUnserializedFromJson() + { + $message = new RedisMessage('theBody', ['thePropFoo' => 'thePropFooVal'], ['theHeaderFoo' => 'theHeaderFooVal']); + + $json = json_encode($message); + + //guard + $this->assertNotEmpty($json); + + $unserializedMessage = RedisMessage::jsonUnserialize($json); + + $this->assertInstanceOf(RedisMessage::class, $unserializedMessage); + $this->assertEquals($message, $unserializedMessage); + } + + public function testThrowIfMalformedJsonGivenOnUnsterilizedFromJson() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The malformed json given.'); + + RedisMessage::jsonUnserialize('{]'); + } +} diff --git a/pkg/redis/composer.json b/pkg/redis/composer.json new file mode 100644 index 000000000..43cacc176 --- /dev/null +++ b/pkg/redis/composer.json @@ -0,0 +1,43 @@ +{ + "name": "enqueue/redis", + "type": "library", + "description": "Message Queue Redis Transport", + "keywords": ["messaging", "queue", "redis"], + "license": "MIT", + "repositories": [ + { + "type": "vcs", + "url": "git@github.com:php-enqueue/test.git" + } + ], + "require": { + "php": ">=5.6", + "enqueue/psr-queue": "^0.3", + "psr/log": "^1" + }, + "require-dev": { + "phpunit/phpunit": "~5.4.0", + "predis/predis": "^1.1", + "enqueue/test": "^0.3", + "enqueue/enqueue": "^0.3", + "symfony/dependency-injection": "^2.8|^3", + "symfony/config": "^2.8|^3" + }, + "autoload": { + "psr-4": { "Enqueue\\Redis\\": "" }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "suggest": { + "enqueue/enqueue": "If you'd like to use advanced features like Client abstract layer or Symfony integration features", + "predis/predis": "Either this PHP library or redis extension has to be installed.", + "ext-redis": "Either this PHP extension or predis/predis extension has to be installed." + }, + "minimum-stability": "dev", + "extra": { + "branch-alias": { + "dev-master": "0.3.x-dev" + } + } +} diff --git a/pkg/redis/phpunit.xml.dist b/pkg/redis/phpunit.xml.dist new file mode 100644 index 000000000..9c4467b56 --- /dev/null +++ b/pkg/redis/phpunit.xml.dist @@ -0,0 +1,30 @@ + + + + + + + ./Tests + + + + + + . + + ./vendor + ./Tests + + + + From 6e2a5125f0067b8cbef1db06dd99c916002fd887 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 20 Apr 2017 16:36:29 +0300 Subject: [PATCH 2/6] [redis] Add unit and func tests, fix bugs. --- bin/test | 1 + docker-compose.yml | 4 +- phpunit.xml.dist | 6 +- pkg/redis/PRedis.php | 20 +- pkg/redis/PhpRedis.php | 19 +- pkg/redis/Redis.php | 5 + pkg/redis/RedisConnectionFactory.php | 19 +- pkg/redis/RedisContext.php | 24 +- .../Tests/Functional/CommonUseCasesTrait.php | 127 ++++++ .../Functional/PRedisCommonUseCasesTest.php | 42 ++ .../Functional/PhpRedisCommonUseCasesTest.php | 42 ++ .../Tests/RedisConnectionFactoryTest.php | 7 +- pkg/redis/Tests/RedisConsumerTest.php | 202 +++++++++ pkg/redis/Tests/RedisContextTest.php | 390 ++++++++---------- pkg/redis/Tests/RedisDestinationTest.php | 3 +- pkg/redis/Tests/RedisMessageTest.php | 3 +- pkg/redis/Tests/RedisProducerTest.php | 73 ++++ pkg/test/RedisExtension.php | 47 +++ 18 files changed, 799 insertions(+), 235 deletions(-) create mode 100644 pkg/redis/Tests/Functional/CommonUseCasesTrait.php create mode 100644 pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php create mode 100644 pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php create mode 100644 pkg/redis/Tests/RedisConsumerTest.php create mode 100644 pkg/redis/Tests/RedisProducerTest.php create mode 100644 pkg/test/RedisExtension.php diff --git a/bin/test b/bin/test index ab293690f..e3e6c151c 100755 --- a/bin/test +++ b/bin/test @@ -22,6 +22,7 @@ function waitForService() waitForService rabbitmq 5672 50 waitForService mysql 3306 50 +waitForService redis 6379 50 php pkg/job-queue/Tests/Functional/app/console doctrine:database:create php pkg/job-queue/Tests/Functional/app/console doctrine:schema:update --force diff --git a/docker-compose.yml b/docker-compose.yml index 627f99a12..68c4b42b2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: - mysql - redis volumes: - - ./:/mqdev + - './:/mqdev:cached' environment: - SYMFONY__RABBITMQ__HOST=rabbitmq - SYMFONY__RABBITMQ__USER=guest @@ -22,6 +22,8 @@ services: - SYMFONY__DB__NAME=mqdev - SYMFONY__DB__USER=root - SYMFONY__DB__PASSWORD=rootpass + - SYMFONY__REDIS__HOST=redis + - SYMFONY__REDIS__PORT=6379 rabbitmq: image: enqueue/rabbitmq:latest diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 9e2be5363..37c8aa90d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -29,12 +29,12 @@ pkg/amqp-ext/Tests - + pkg/fs/Tests - - pkg/redis-ext/Tests + + pkg/redis/Tests diff --git a/pkg/redis/PRedis.php b/pkg/redis/PRedis.php index a36b05876..55a031669 100644 --- a/pkg/redis/PRedis.php +++ b/pkg/redis/PRedis.php @@ -37,7 +37,9 @@ public function lpush($key, $value) public function brpop($key, $timeout) { try { - return $this->brpop($key, (int) $timeout / 1000); + if ($result = $this->redis->brpop($key, $timeout)) { + return $result[1]; + } } catch (PRedisServerException $e) { throw new ServerException('brpop command has failed', null, $e); } @@ -48,19 +50,33 @@ public function brpop($key, $timeout) */ public function rpop($key) { try { - return $this->rpop($key); + return $this->redis->rpop($key); } catch (PRedisServerException $e) { throw new ServerException('rpop command has failed', null, $e); } } + /** + * {@inheritdoc} + */ public function connect() { $this->redis->connect(); } + /** + * {@inheritdoc} + */ public function disconnect() { $this->redis->disconnect(); } + + /** + * {@inheritdoc} + */ + public function del($key) + { + $this->redis->del([$key]); + } } diff --git a/pkg/redis/PhpRedis.php b/pkg/redis/PhpRedis.php index 1c767ffb5..94a0d89a9 100644 --- a/pkg/redis/PhpRedis.php +++ b/pkg/redis/PhpRedis.php @@ -14,13 +14,10 @@ class PhpRedis implements Redis private $config; /** - * @param \Redis $redis * @param array $config */ - public function __construct(\Redis $redis, array $config) + public function __construct(array $config) { - $this->redis = $redis; - $this->config = array_replace([ 'host' => null, 'port' => null, @@ -59,6 +56,9 @@ public function rpop($key) return $this->redis->rPop($key); } + /** + * {@inheritdoc} + */ public function connect() { if (false == $this->redis) { @@ -84,10 +84,21 @@ public function connect() return $this->redis; } + /** + * {@inheritdoc} + */ public function disconnect() { if ($this->redis) { $this->redis->close(); } } + + /** + * {@inheritdoc} + */ + public function del($key) + { + $this->redis->del($key); + } } diff --git a/pkg/redis/Redis.php b/pkg/redis/Redis.php index 8e69466fa..f14edc8d6 100644 --- a/pkg/redis/Redis.php +++ b/pkg/redis/Redis.php @@ -29,4 +29,9 @@ public function rpop($key); public function connect(); public function disconnect(); + + /** + * @param string $key + */ + public function del($key); } diff --git a/pkg/redis/RedisConnectionFactory.php b/pkg/redis/RedisConnectionFactory.php index 37d2bf5ed..28af72981 100644 --- a/pkg/redis/RedisConnectionFactory.php +++ b/pkg/redis/RedisConnectionFactory.php @@ -63,10 +63,7 @@ public function createContext() { if ($this->config['lazy']) { return new RedisContext(function () { - $redis = $this->createRedis(); - $redis->connect(); - - return $redis; + return $this->createRedis(); }); } @@ -78,12 +75,16 @@ public function createContext() */ private function createRedis() { - if ('phpredis' == $this->config['vendor'] && false == $this->redis) { - $this->redis = new PhpRedis(new \Redis(), $this->config); - } + if (false == $this->redis) { + if ('phpredis' == $this->config['vendor'] && false == $this->redis) { + $this->redis = new PhpRedis($this->config); + } + + if ('predis' == $this->config['vendor'] && false == $this->redis) { + $this->redis = new PRedis(new Client($this->config, ['exceptions' => true])); + } - if ('predis' == $this->config['vendor'] && false == $this->redis) { - $this->redis = new PRedis(new Client($this->config, ['exceptions' => true])); + $this->redis->connect(); } return $this->redis; diff --git a/pkg/redis/RedisContext.php b/pkg/redis/RedisContext.php index 370398db8..6dab888db 100644 --- a/pkg/redis/RedisContext.php +++ b/pkg/redis/RedisContext.php @@ -5,6 +5,8 @@ use Enqueue\Psr\InvalidDestinationException; use Enqueue\Psr\PsrContext; use Enqueue\Psr\PsrDestination; +use Enqueue\Psr\PsrQueue; +use Enqueue\Psr\PsrTopic; class RedisContext implements PsrContext { @@ -68,6 +70,26 @@ public function createQueue($queueName) return new RedisDestination($queueName); } + /** + * @param RedisDestination|PsrQueue $queue + */ + public function deleteQueue(PsrQueue $queue) + { + InvalidDestinationException::assertDestinationInstanceOf($queue, RedisDestination::class); + + $this->getRedis()->del($queue->getName()); + } + + /** + * @param RedisDestination|PsrTopic $topic + */ + public function deleteTopic(PsrTopic $topic) + { + InvalidDestinationException::assertDestinationInstanceOf($topic, RedisDestination::class); + + $this->getRedis()->del($topic->getName()); + } + /** * {@inheritdoc} */ @@ -102,7 +124,7 @@ public function createConsumer(PsrDestination $destination) public function close() { - $this->getRedis()->close(); + $this->getRedis()->disconnect(); } /** diff --git a/pkg/redis/Tests/Functional/CommonUseCasesTrait.php b/pkg/redis/Tests/Functional/CommonUseCasesTrait.php new file mode 100644 index 000000000..ac12adb09 --- /dev/null +++ b/pkg/redis/Tests/Functional/CommonUseCasesTrait.php @@ -0,0 +1,127 @@ +getContext()->createQueue('enqueue.test_queue'); + + $startAt = microtime(true); + + $consumer = $this->getContext()->createConsumer($queue); + $message = $consumer->receive(2000); + + $endAt = microtime(true); + + $this->assertNull($message); + + $this->assertGreaterThan(1.5, $endAt - $startAt); + $this->assertLessThan(2.5, $endAt - $startAt); + } + + public function testReturnNullImmediatelyOnReceiveNoWait() + { + $queue = $this->getContext()->createQueue('enqueue.test_queue'); + + $startAt = microtime(true); + + $consumer = $this->getContext()->createConsumer($queue); + $message = $consumer->receiveNoWait(); + + $endAt = microtime(true); + + $this->assertNull($message); + + $this->assertLessThan(0.5, $endAt - $startAt); + } + + public function testProduceAndReceiveOneMessageSentDirectlyToQueue() + { + $queue = $this->getContext()->createQueue('enqueue.test_queue'); + + $message = $this->getContext()->createMessage( + __METHOD__, + ['FooProperty' => 'FooVal'], + ['BarHeader' => 'BarVal'] + ); + + $producer = $this->getContext()->createProducer(); + $producer->send($queue, $message); + + $consumer = $this->getContext()->createConsumer($queue); + $message = $consumer->receive(1000); + + $this->assertInstanceOf(RedisMessage::class, $message); + $consumer->acknowledge($message); + + $this->assertEquals(__METHOD__, $message->getBody()); + $this->assertEquals(['FooProperty' => 'FooVal'], $message->getProperties()); + $this->assertEquals(['BarHeader' => 'BarVal'], $message->getHeaders()); + } + + public function testProduceAndReceiveOneMessageSentDirectlyToTopic() + { + $topic = $this->getContext()->createTopic('enqueue.test_topic'); + + $message = $this->getContext()->createMessage(__METHOD__); + + $producer = $this->getContext()->createProducer(); + $producer->send($topic, $message); + + $consumer = $this->getContext()->createConsumer($topic); + $message = $consumer->receive(1000); + + $this->assertInstanceOf(RedisMessage::class, $message); + $consumer->acknowledge($message); + + $this->assertEquals(__METHOD__, $message->getBody()); + } + + public function testConsumerReceiveMessageWithZeroTimeout() + { + $topic = $this->getContext()->createTopic('enqueue.test_topic'); + + $consumer = $this->getContext()->createConsumer($topic); + + //guard + $this->assertNull($consumer->receive(1000)); + + $message = $this->getContext()->createMessage(__METHOD__); + + $producer = $this->getContext()->createProducer(); + $producer->send($topic, $message); + usleep(100); + $actualMessage = $consumer->receive(0); + + $this->assertInstanceOf(RedisMessage::class, $actualMessage); + $consumer->acknowledge($message); + + $this->assertEquals(__METHOD__, $message->getBody()); + } + + public function testShouldReceiveMessagesInExpectedOrder() + { + $queue = $this->getContext()->createQueue('enqueue.test_queue'); + + $producer = $this->getContext()->createProducer(); + $producer->send($queue, $this->getContext()->createMessage(1)); + $producer->send($queue, $this->getContext()->createMessage(2)); + $producer->send($queue, $this->getContext()->createMessage(3)); + + $consumer = $this->getContext()->createConsumer($queue); + + $this->assertSame(1, $consumer->receiveNoWait()->getBody()); + $this->assertSame(2, $consumer->receiveNoWait()->getBody()); + $this->assertSame(3, $consumer->receiveNoWait()->getBody()); + } + + /** + * @return RedisContext + */ + abstract protected function getContext(); +} diff --git a/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php new file mode 100644 index 000000000..8c95e47de --- /dev/null +++ b/pkg/redis/Tests/Functional/PRedisCommonUseCasesTest.php @@ -0,0 +1,42 @@ +context = $this->buildPRedisContext(); + + $this->context->deleteQueue($this->context->createQueue('enqueue.test_queue')); + $this->context->deleteTopic($this->context->createTopic('enqueue.test_topic')); + } + + public function tearDown() + { + $this->context->close(); + } + + /** + * {@inheritdoc} + */ + protected function getContext() + { + return $this->context; + } +} diff --git a/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php new file mode 100644 index 000000000..2d5559d34 --- /dev/null +++ b/pkg/redis/Tests/Functional/PhpRedisCommonUseCasesTest.php @@ -0,0 +1,42 @@ +context = $this->buildPhpRedisContext(); + + $this->context->deleteQueue($this->context->createQueue('enqueue.test_queue')); + $this->context->deleteTopic($this->context->createTopic('enqueue.test_topic')); + } + + public function tearDown() + { + $this->context->close(); + } + + /** + * {@inheritdoc} + */ + protected function getContext() + { + return $this->context; + } +} diff --git a/pkg/redis/Tests/RedisConnectionFactoryTest.php b/pkg/redis/Tests/RedisConnectionFactoryTest.php index 8a8b1f9c7..7a19de494 100644 --- a/pkg/redis/Tests/RedisConnectionFactoryTest.php +++ b/pkg/redis/Tests/RedisConnectionFactoryTest.php @@ -1,13 +1,14 @@ null, 'persisted' => false, 'lazy' => true, + 'vendor' => 'phpredis' ], 'config', $factory); } @@ -43,6 +45,7 @@ public function testCouldBeConstructedWithCustomConfiguration() 'retry_interval' => null, 'persisted' => false, 'lazy' => true, + 'vendor' => 'phpredis' ], 'config', $factory); } diff --git a/pkg/redis/Tests/RedisConsumerTest.php b/pkg/redis/Tests/RedisConsumerTest.php new file mode 100644 index 000000000..555206e6a --- /dev/null +++ b/pkg/redis/Tests/RedisConsumerTest.php @@ -0,0 +1,202 @@ +assertClassImplements(PsrConsumer::class, RedisConsumer::class); + } + + public function testCouldBeConstructedWithContextAndDestinationAndPreFetchCountAsArguments() + { + new RedisConsumer($this->createContextMock(), new RedisDestination('aQueue')); + } + + public function testShouldReturnDestinationSetInConstructorOnGetQueue() + { + $destination = new RedisDestination('aQueue'); + + $consumer = new RedisConsumer($this->createContextMock(), $destination, 1); + + $this->assertSame($destination, $consumer->getQueue()); + } + + public function testShouldDoNothingOnAcknowledge() + { + $consumer = new RedisConsumer($this->createContextMock(), new RedisDestination('aQueue')); + + $consumer->acknowledge(new RedisMessage()); + } + + public function testShouldDoNothingOnReject() + { + $consumer = new RedisConsumer($this->createContextMock(), new RedisDestination('aQueue')); + + $consumer->reject(new RedisMessage()); + } + + public function testShouldSendSameMessageToDestinationOnReQueue() + { + $message = new RedisMessage(); + + $destination = new RedisDestination('aQueue'); + + $producerMock = $this->createProducerMock(); + $producerMock + ->expects($this->once()) + ->method('send') + ->with($this->identicalTo($destination), $this->identicalTo($message)) + ; + + $contextMock = $this->createContextMock(); + $contextMock + ->expects($this->once()) + ->method('createProducer') + ->willReturn($producerMock) + ; + + $consumer = new RedisConsumer($contextMock, $destination); + + $consumer->reject($message, true); + } + + public function testShouldCallRedisBRPopAndReturnNullIfNothingInQueueOnReceive() + { + $destination = new RedisDestination('aQueue'); + + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->once()) + ->method('brpop') + ->with('aQueue', 2) + ->willReturn(null) + ; + + $contextMock = $this->createContextMock(); + $contextMock + ->expects($this->once()) + ->method('getRedis') + ->willReturn($redisMock) + ; + + $consumer = new RedisConsumer($contextMock, $destination); + + $this->assertNull($consumer->receive(2000)); + } + + public function testShouldCallRedisBRPopAndReturnMessageIfOneInQueueOnReceive() + { + $destination = new RedisDestination('aQueue'); + + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->once()) + ->method('brpop') + ->with('aQueue', 2) + ->willReturn(json_encode(new RedisMessage('aBody'))) + ; + + $contextMock = $this->createContextMock(); + $contextMock + ->expects($this->once()) + ->method('getRedis') + ->willReturn($redisMock) + ; + + $consumer = new RedisConsumer($contextMock, $destination); + + $message = $consumer->receive(2000); + + $this->assertInstanceOf(RedisMessage::class, $message); + $this->assertSame('aBody', $message->getBody()); + } + + public function testShouldCallRedisRPopAndReturnNullIfNothingInQueueOnReceiveNoWait() + { + $destination = new RedisDestination('aQueue'); + + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->once()) + ->method('rpop') + ->with('aQueue') + ->willReturn(null) + ; + + $contextMock = $this->createContextMock(); + $contextMock + ->expects($this->once()) + ->method('getRedis') + ->willReturn($redisMock) + ; + + $consumer = new RedisConsumer($contextMock, $destination); + + $this->assertNull($consumer->receiveNoWait()); + } + + public function testShouldCallRedisRPopAndReturnMessageIfOneInQueueOnReceiveNoWait() + { + $destination = new RedisDestination('aQueue'); + + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->once()) + ->method('rpop') + ->with('aQueue') + ->willReturn(json_encode(new RedisMessage('aBody'))) + ; + + $contextMock = $this->createContextMock(); + $contextMock + ->expects($this->once()) + ->method('getRedis') + ->willReturn($redisMock) + ; + + $consumer = new RedisConsumer($contextMock, $destination); + + $message = $consumer->receiveNoWait(); + + $this->assertInstanceOf(RedisMessage::class, $message); + $this->assertSame('aBody', $message->getBody()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Redis + */ + private function createRedisMock() + { + return $this->createMock(Redis::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RedisProducer + */ + private function createProducerMock() + { + return $this->createMock(RedisProducer::class); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|RedisContext + */ + private function createContextMock() + { + return $this->createMock(RedisContext::class); + } +} diff --git a/pkg/redis/Tests/RedisContextTest.php b/pkg/redis/Tests/RedisContextTest.php index 945ab31df..dd6d02d90 100644 --- a/pkg/redis/Tests/RedisContextTest.php +++ b/pkg/redis/Tests/RedisContextTest.php @@ -2,6 +2,7 @@ namespace Enqueue\Redis\Tests; +use Enqueue\Redis\Redis; use Enqueue\Redis\RedisConsumer; use Enqueue\Redis\RedisContext; use Enqueue\Redis\RedisDestination; @@ -11,9 +12,10 @@ use Enqueue\Psr\PsrContext; use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullQueue; -use Makasim\File\TempFile; +use Enqueue\Transport\Null\NullTopic; +use PHPUnit\Framework\TestCase; -class RedisContextTest extends \PHPUnit_Framework_TestCase +class RedisContextTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; @@ -22,223 +24,189 @@ public function testShouldImplementContextInterface() $this->assertClassImplements(PsrContext::class, RedisContext::class); } - public function testCouldBeConstructedWithExpectedArguments() + public function testCouldBeConstructedWithRedisAsFirstArgument() { new RedisContext($this->createRedisMock()); } -// public function testShouldAllowCreateEmptyMessage() -// { -// $context = new RedisContext($this->createRedisMock()); -// -// $message = $context->createMessage(); -// -// $this->assertInstanceOf(RedisMessage::class, $message); -// -// $this->assertSame('', $message->getBody()); -// $this->assertSame([], $message->getProperties()); -// $this->assertSame([], $message->getHeaders()); -// } -// -// public function testShouldAllowCreateCustomMessage() -// { -// $context = new RedisContext($this->createRedisMock()); -// -// $message = $context->createMessage('theBody', ['aProp' => 'aPropVal'], ['aHeader' => 'aHeaderVal']); -// -// $this->assertInstanceOf(RedisMessage::class, $message); -// -// $this->assertSame('theBody', $message->getBody()); -// $this->assertSame(['aProp' => 'aPropVal'], $message->getProperties()); -// $this->assertSame(['aHeader' => 'aHeaderVal'], $message->getHeaders()); -// } -// -// public function testShouldCreateQueue() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $queue = $context->createQueue($tmpFile->getFilename()); -// -// $this->assertInstanceOf(RedisDestination::class, $queue); -// $this->assertInstanceOf(\SplFileInfo::class, $queue->getFileInfo()); -// $this->assertSame((string) $tmpFile, (string) $queue->getFileInfo()); -// -// $this->assertSame($tmpFile->getFilename(), $queue->getTopicName()); -// } -// -// public function testShouldAllowCreateTopic() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $topic = $context->createTopic($tmpFile->getFilename()); -// -// $this->assertInstanceOf(RedisDestination::class, $topic); -// $this->assertInstanceOf(\SplFileInfo::class, $topic->getFileInfo()); -// $this->assertSame((string) $tmpFile, (string) $topic->getFileInfo()); -// -// $this->assertSame($tmpFile->getFilename(), $topic->getTopicName()); -// } -// -// public function testShouldAllowCreateTmpQueue() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $queue = $context->createTemporaryQueue(); -// -// $this->assertInstanceOf(RedisDestination::class, $queue); -// $this->assertInstanceOf(TempFile::class, $queue->getFileInfo()); -// $this->assertNotEmpty($queue->getQueueName()); -// } -// -// public function testShouldCreateProducer() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $producer = $context->createProducer(); -// -// $this->assertInstanceOf(RedisProducer::class, $producer); -// } -// -// public function testShouldThrowIfNotRedisDestinationGivenOnCreateConsumer() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $this->expectException(InvalidDestinationException::class); -// $this->expectExceptionMessage('The destination must be an instance of Enqueue\Redis\RedisDestination but got Enqueue\Transport\Null\NullQueue.'); -// $consumer = $context->createConsumer(new NullQueue('aQueue')); -// -// $this->assertInstanceOf(RedisConsumer::class, $consumer); -// } -// -// public function testShouldCreateConsumer() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $queue = $context->createQueue($tmpFile->getFilename()); -// -// $context->createConsumer($queue); -// } -// -// public function testShouldPropagatePreFetchCountToCreatedConsumer() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $queue = $context->createQueue($tmpFile->getFilename()); -// -// $consumer = $context->createConsumer($queue); -// -// // guard -// $this->assertInstanceOf(RedisConsumer::class, $consumer); -// -// $this->assertAttributeSame(123, 'preFetchCount', $consumer); -// } -// -// public function testShouldAllowGetPreFetchCountSetInConstructor() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $this->assertSame(123, $context->getPreFetchCount()); -// } -// -// public function testShouldAllowGetPreviouslySetPreFetchCount() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $context->setPreFetchCount(456); -// -// $this->assertSame(456, $context->getPreFetchCount()); -// } -// -// public function testShouldAllowPurgeMessagesFromQueue() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/foo'); -// -// file_put_contents($tmpFile, 'foo'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $queue = $context->createQueue($tmpFile->getFilename()); -// -// $context->purge($queue); -// -// $this->assertEmpty(file_get_contents($tmpFile)); -// } -// -// public function testShouldReleaseAllLocksOnClose() -// { -// new TempFile(sys_get_temp_dir().'/foo'); -// new TempFile(sys_get_temp_dir().'/bar'); -// -// $context = new RedisContext($this->createRedisMock()); -// -// $fooQueue = $context->createQueue('foo'); -// $barQueue = $context->createTopic('bar'); -// -// $this->assertAttributeCount(0, 'lockHandlers', $context); -// -// $context->workWithFile($fooQueue, 'r+', function () { -// }); -// $context->workWithFile($barQueue, 'r+', function () { -// }); -// $context->workWithFile($fooQueue, 'c+', function () { -// }); -// $context->workWithFile($barQueue, 'c+', function () { -// }); -// -// $this->assertAttributeCount(2, 'lockHandlers', $context); -// -// $context->close(); -// -// $this->assertAttributeCount(0, 'lockHandlers', $context); -// } -// -// public function testShouldCreateFileOnFilesystemIfNotExistOnDeclareDestination() -// { -// $tmpFile = new TempFile(sys_get_temp_dir().'/'.uniqid()); -// -// $context = new RedisContext(sys_get_temp_dir(), 1, 0666); -// -// $queue = $context->createQueue($tmpFile->getFilename()); -// -// $this->assertFileNotExists((string) $tmpFile); -// -// $context->declareDestination($queue); -// -// $this->assertFileExists((string) $tmpFile); -// $this->assertTrue(is_readable($tmpFile)); -// $this->assertTrue(is_writable($tmpFile)); -// -// // do nothing if file already exists -// $context->declareDestination($queue); -// -// $this->assertFileExists((string) $tmpFile); -// -// unlink($tmpFile); -// } + public function testCouldBeConstructedWithRedisFactoryAsFirstArgument() + { + new RedisContext(function() { + return $this->createRedisMock(); + }); + } + + public function testThrowIfNeitherRedisNorFactoryGiven() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('The $redis argument must be either Enqueue\Redis\Redis or callable that returns $s once called.'); + new RedisContext(new \stdClass()); + } + + public function testShouldAllowCreateEmptyMessage() + { + $context = new RedisContext($this->createRedisMock()); + + $message = $context->createMessage(); + + $this->assertInstanceOf(RedisMessage::class, $message); + + $this->assertSame('', $message->getBody()); + $this->assertSame([], $message->getProperties()); + $this->assertSame([], $message->getHeaders()); + } + + public function testShouldAllowCreateCustomMessage() + { + $context = new RedisContext($this->createRedisMock()); + + $message = $context->createMessage('theBody', ['aProp' => 'aPropVal'], ['aHeader' => 'aHeaderVal']); + + $this->assertInstanceOf(RedisMessage::class, $message); + + $this->assertSame('theBody', $message->getBody()); + $this->assertSame(['aProp' => 'aPropVal'], $message->getProperties()); + $this->assertSame(['aHeader' => 'aHeaderVal'], $message->getHeaders()); + } + + public function testShouldCreateQueue() + { + $context = new RedisContext($this->createRedisMock()); + + $queue = $context->createQueue('aQueue'); + + $this->assertInstanceOf(RedisDestination::class, $queue); + $this->assertSame('aQueue', $queue->getQueueName()); + } + + public function testShouldAllowCreateTopic() + { + $context = new RedisContext($this->createRedisMock()); + + $topic = $context->createTopic('aTopic'); + + $this->assertInstanceOf(RedisDestination::class, $topic); + $this->assertSame('aTopic', $topic->getTopicName()); + } + + public function testThrowNotImplementedOnCreateTmpQueueCall() + { + $context = new RedisContext($this->createRedisMock()); + + $this->expectException(\LogicException::class); + $this->expectExceptionMessage('Not implemented'); + $context->createTemporaryQueue(); + } + + public function testShouldCreateProducer() + { + $context = new RedisContext($this->createRedisMock()); + + $producer = $context->createProducer(); + + $this->assertInstanceOf(RedisProducer::class, $producer); + } + + public function testShouldThrowIfNotRedisDestinationGivenOnCreateConsumer() + { + $context = new RedisContext($this->createRedisMock()); + + $this->expectException(InvalidDestinationException::class); + $this->expectExceptionMessage('The destination must be an instance of Enqueue\Redis\RedisDestination but got Enqueue\Transport\Null\NullQueue.'); + $consumer = $context->createConsumer(new NullQueue('aQueue')); + + $this->assertInstanceOf(RedisConsumer::class, $consumer); + } + + public function testShouldCreateConsumer() + { + $context = new RedisContext($this->createRedisMock()); + + $queue = $context->createQueue('aQueue'); + + $consumer = $context->createConsumer($queue); + + $this->assertInstanceOf(RedisConsumer::class, $consumer); + } + + public function testShouldCallRedisDisconnectOnClose() + { + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->once()) + ->method('disconnect') + ; + + $context = new RedisContext($redisMock); + + $context->close(); + } + + public function testThrowIfNotRedisDestinationGivenOnDeleteQueue() + { + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->never()) + ->method('del') + ; + + $context = new RedisContext($redisMock); + + $this->expectException(InvalidDestinationException::class); + $context->deleteQueue(new NullQueue('aQueue')); + } + + public function testShouldAllowDeleteQueue() + { + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->once()) + ->method('del') + ->with('aQueueName') + ; + + $context = new RedisContext($redisMock); + + $queue = $context->createQueue('aQueueName'); + + $context->deleteQueue($queue); + } + + public function testThrowIfNotRedisDestinationGivenOnDeleteTopic() + { + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->never()) + ->method('del') + ; + + $context = new RedisContext($redisMock); + + $this->expectException(InvalidDestinationException::class); + $context->deleteTopic(new NullTopic('aTopic')); + } + + public function testShouldAllowDeleteTopic() + { + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->once()) + ->method('del') + ->with('aTopicName') + ; + + $context = new RedisContext($redisMock); + + $topic = $context->createTopic('aTopicName'); + + $context->deleteQueue($topic); + } /** - * @return \PHPUnit_Framework_MockObject_MockObject|\Redis + * @return \PHPUnit_Framework_MockObject_MockObject|Redis */ private function createRedisMock() { - return $this->createMock(\Redis::class); + return $this->createMock(Redis::class); } } diff --git a/pkg/redis/Tests/RedisDestinationTest.php b/pkg/redis/Tests/RedisDestinationTest.php index 0af02a6ab..8ee065fc5 100644 --- a/pkg/redis/Tests/RedisDestinationTest.php +++ b/pkg/redis/Tests/RedisDestinationTest.php @@ -6,8 +6,9 @@ use Enqueue\Psr\PsrTopic; use Enqueue\Redis\RedisDestination; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class RedisDestinationTest extends \PHPUnit_Framework_TestCase +class RedisDestinationTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/redis/Tests/RedisMessageTest.php b/pkg/redis/Tests/RedisMessageTest.php index 0e775d0c9..d9bab0eb5 100644 --- a/pkg/redis/Tests/RedisMessageTest.php +++ b/pkg/redis/Tests/RedisMessageTest.php @@ -5,8 +5,9 @@ use Enqueue\Psr\PsrMessage; use Enqueue\Redis\RedisMessage; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class RedisMessageTest extends \PHPUnit_Framework_TestCase +class RedisMessageTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/redis/Tests/RedisProducerTest.php b/pkg/redis/Tests/RedisProducerTest.php new file mode 100644 index 000000000..ef796b4d9 --- /dev/null +++ b/pkg/redis/Tests/RedisProducerTest.php @@ -0,0 +1,73 @@ +assertClassImplements(PsrProducer::class, RedisProducer::class); + } + + public function testCouldBeConstructedWithRedisAsFirstArgument() + { + new RedisProducer($this->createRedisMock()); + } + + public function testThrowIfDestinationNotRedisDestinationOnSend() + { + $producer = new RedisProducer($this->createRedisMock()); + + $this->expectException(InvalidDestinationException::class); + $this->expectExceptionMessage('The destination must be an instance of Enqueue\Redis\RedisDestination but got Enqueue\Transport\Null\NullQueue.'); + $producer->send(new NullQueue('aQueue'), new RedisMessage()); + } + + public function testThrowIfMessageNotRedisMessageOnSend() + { + $producer = new RedisProducer($this->createRedisMock()); + + $this->expectException(InvalidMessageException::class); + $this->expectExceptionMessage('The message must be an instance of Enqueue\Redis\RedisMessage but it is Enqueue\Transport\Null\NullMessage.'); + $producer->send(new RedisDestination(TempFile::generate()), new NullMessage()); + } + + public function testShouldCallLPushOnSend() + { + $destination = new RedisDestination('aDestination'); + + $redisMock = $this->createRedisMock(); + $redisMock + ->expects($this->once()) + ->method('lpush') + ->with('aDestination', '{"body":null,"properties":[],"headers":[]}') + ; + + $producer = new RedisProducer($redisMock); + + $producer->send($destination, new RedisMessage()); + } + + /** + * @return \PHPUnit_Framework_MockObject_MockObject|Redis + */ + private function createRedisMock() + { + return $this->createMock(Redis::class); + } +} diff --git a/pkg/test/RedisExtension.php b/pkg/test/RedisExtension.php new file mode 100644 index 000000000..9b98c5443 --- /dev/null +++ b/pkg/test/RedisExtension.php @@ -0,0 +1,47 @@ + getenv('SYMFONY__REDIS__HOST'), + 'port' => getenv('SYMFONY__REDIS__PORT'), + 'vendor' => 'phpredis', + 'lazy' => false, + ]; + + return (new RedisConnectionFactory($config))->createContext(); + } + + /** + * @return RedisContext + */ + private function buildPRedisContext() + { + if (false == getenv('SYMFONY__REDIS__HOST')) { + throw new \PHPUnit_Framework_SkippedTestError('Functional tests are not allowed in this environment'); + } + + $config = [ + 'host' => getenv('SYMFONY__REDIS__HOST'), + 'port' => getenv('SYMFONY__REDIS__PORT'), + 'vendor' => 'predis', + 'lazy' => false, + ]; + + return (new RedisConnectionFactory($config))->createContext(); + } +} From b6d3304ddf16c27ee354392b1913493de3f0c386 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 20 Apr 2017 16:37:27 +0300 Subject: [PATCH 3/6] Use namesapcesed Phpunit TestCase --- pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php | 3 ++- pkg/amqp-ext/Tests/AmqpConsumerTest.php | 3 ++- pkg/amqp-ext/Tests/AmqpContextTest.php | 3 ++- pkg/amqp-ext/Tests/AmqpMessageTest.php | 3 ++- pkg/amqp-ext/Tests/AmqpProducerTest.php | 3 ++- pkg/amqp-ext/Tests/AmqpQueueTest.php | 3 ++- pkg/amqp-ext/Tests/AmqpTopicTest.php | 3 ++- pkg/amqp-ext/Tests/BufferTest.php | 3 ++- pkg/amqp-ext/Tests/Client/AmqpDriverTest.php | 3 ++- pkg/amqp-ext/Tests/Client/RabbitMqDriverTest.php | 3 ++- pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php | 3 ++- pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php | 3 ++- pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php | 3 ++- pkg/amqp-ext/Tests/Symfony/AmqpTransportFactoryTest.php | 3 ++- .../Tests/Symfony/RabbitMqAmqpTransportFactoryTest.php | 3 ++- .../Extension/DoctrineClearIdentityMapExtensionTest.php | 3 ++- .../Extension/DoctrinePingConnectionExtensionTest.php | 3 ++- .../DependencyInjection/Compiler/AddTopicMetaPassTest.php | 3 ++- .../Compiler/BuildClientRoutingPassTest.php | 3 ++- .../DependencyInjection/Compiler/BuildExtensionsPassTest.php | 3 ++- .../Compiler/BuildProcessorRegistryPassTest.php | 3 ++- .../Compiler/BuildQueueMetaRegistryPassTest.php | 3 ++- .../Compiler/BuildTopicMetaSubscribersPassTest.php | 3 ++- .../Tests/Unit/DependencyInjection/ConfigurationTest.php | 3 ++- .../Tests/Unit/DependencyInjection/EnqueueExtensionTest.php | 3 ++- pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php | 3 ++- .../Tests/Unit/Profiler/MessageQueueCollectorTest.php | 3 ++- pkg/enqueue/Tests/Client/ArrayProcessorRegistryTest.php | 3 ++- pkg/enqueue/Tests/Client/ConfigTest.php | 3 ++- .../DelayRedeliveredMessageExtensionTest.php | 3 ++- .../ConsumptionExtension/SetRouterPropertiesExtensionTest.php | 3 ++- .../Client/ConsumptionExtension/SetupBrokerExtensionTest.php | 3 ++- pkg/enqueue/Tests/Client/DelegateProcessorTest.php | 3 ++- pkg/enqueue/Tests/Client/MessagePriorityTest.php | 3 ++- pkg/enqueue/Tests/Client/MessageTest.php | 3 ++- pkg/enqueue/Tests/Client/Meta/QueueMetaRegistryTest.php | 3 ++- pkg/enqueue/Tests/Client/Meta/QueueMetaTest.php | 3 ++- pkg/enqueue/Tests/Client/Meta/TopicMetaRegistryTest.php | 3 ++- pkg/enqueue/Tests/Client/Meta/TopicMetaTest.php | 3 ++- pkg/enqueue/Tests/Client/NullDriverTest.php | 3 ++- pkg/enqueue/Tests/Client/ProducerTest.php | 3 ++- pkg/enqueue/Tests/Client/RouterProcessorTest.php | 3 ++- pkg/enqueue/Tests/Client/RpcClientTest.php | 3 ++- pkg/enqueue/Tests/Client/TraceableProducerTest.php | 3 ++- pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php | 3 ++- pkg/enqueue/Tests/Consumption/ChainExtensionTest.php | 3 ++- pkg/enqueue/Tests/Consumption/ContextTest.php | 3 ++- .../Exception/ConsumptionInterruptedExceptionTest.php | 3 ++- .../Exception/IllegalContextModificationExceptionTest.php | 3 ++- .../Consumption/Exception/InvalidArgumentExceptionTest.php | 3 ++- .../Tests/Consumption/Exception/LogicExceptionTest.php | 3 ++- .../Extension/LimitConsumedMessagesExtensionTest.php | 3 ++- .../Extension/LimitConsumerMemoryExtensionTest.php | 3 ++- .../Extension/LimitConsumptionTimeExtensionTest.php | 3 ++- .../Tests/Consumption/Extension/LoggerExtensionTest.php | 3 ++- .../Tests/Consumption/Extension/ReplyExtensionTest.php | 4 ++-- pkg/enqueue/Tests/Consumption/QueueConsumerTest.php | 3 ++- pkg/enqueue/Tests/Consumption/ResultTest.php | 3 ++- pkg/enqueue/Tests/Functional/Client/RpcClientTest.php | 4 ++-- pkg/enqueue/Tests/Functional/Client/SimpleClientTest.php | 3 ++- pkg/enqueue/Tests/Router/RecipientTest.php | 3 ++- pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php | 3 ++- pkg/enqueue/Tests/Rpc/PromiseTest.php | 3 ++- pkg/enqueue/Tests/Rpc/RpcClientTest.php | 3 ++- pkg/enqueue/Tests/Rpc/TimeoutExceptionTest.php | 3 ++- .../Tests/Symfony/Client/ConsumeMessagesCommandTest.php | 3 ++- .../Symfony/Client/ContainerAwareProcessorRegistryTest.php | 3 ++- pkg/enqueue/Tests/Symfony/Client/Meta/QueuesCommandTest.php | 3 ++- pkg/enqueue/Tests/Symfony/Client/Meta/TopicsCommandTest.php | 3 ++- .../Tests/Symfony/Client/ProduceMessageCommandTest.php | 3 ++- pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php | 3 ++- .../Symfony/Client/SetupBrokerExtensionCommandTraitTest.php | 3 ++- .../Tests/Symfony/Consumption/ConsumeMessagesCommandTest.php | 3 ++- .../Consumption/ContainerAwareConsumeMessagesCommandTest.php | 3 ++- .../Symfony/Consumption/LimitsExtensionsCommandTraitTest.php | 3 ++- pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php | 3 ++- pkg/enqueue/Tests/Symfony/NullTransportFactoryTest.php | 3 ++- .../Tests/Transport/Null/NullConnectionFactoryTest.php | 3 ++- pkg/enqueue/Tests/Transport/Null/NullConsumerTest.php | 3 ++- pkg/enqueue/Tests/Transport/Null/NullContextTest.php | 3 ++- pkg/enqueue/Tests/Transport/Null/NullMessageTest.php | 3 ++- pkg/enqueue/Tests/Transport/Null/NullProducerTest.php | 3 ++- pkg/enqueue/Tests/Transport/Null/NullQueueTest.php | 3 ++- pkg/enqueue/Tests/Transport/Null/NullTopicTest.php | 3 ++- pkg/enqueue/Tests/Util/JSONTest.php | 3 ++- pkg/enqueue/Tests/Util/UUIDTest.php | 3 ++- pkg/enqueue/Tests/Util/VarExportTest.php | 3 ++- pkg/fs/Tests/Driver/FsDriverTest.php | 2 +- pkg/fs/Tests/FsConnectionFactoryTest.php | 2 +- pkg/fs/Tests/FsConsumerTest.php | 2 +- pkg/fs/Tests/FsContextTest.php | 2 +- pkg/fs/Tests/FsDestinationTest.php | 2 +- pkg/fs/Tests/FsMessageTest.php | 2 +- pkg/fs/Tests/FsProducerTest.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/fs/Tests/Symfony/FsTransportFactoryTest.php | 2 +- pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php | 2 +- pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php | 2 +- pkg/job-queue/Tests/DependentJobContextTest.php | 2 +- pkg/job-queue/Tests/DependentJobProcessorTest.php | 2 +- pkg/job-queue/Tests/DependentJobServiceTest.php | 2 +- pkg/job-queue/Tests/JobProcessorTest.php | 2 +- pkg/job-queue/Tests/JobRunnerTest.php | 2 +- pkg/job-queue/Tests/JobStorageTest.php | 2 +- pkg/psr-queue/Tests/ExceptionTest.php | 2 +- pkg/psr-queue/Tests/InvalidDestinationExceptionTest.php | 2 +- pkg/psr-queue/Tests/InvalidMessageExceptionTest.php | 2 +- pkg/stomp/Tests/BufferedStompClientTest.php | 2 +- pkg/stomp/Tests/Client/ManagementClientTest.php | 2 +- pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php | 2 +- pkg/stomp/Tests/Client/StompDriverTest.php | 2 +- pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php | 2 +- pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php | 2 +- pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php | 2 +- pkg/stomp/Tests/StompConnectionFactoryTest.php | 2 +- pkg/stomp/Tests/StompConsumerTest.php | 2 +- pkg/stomp/Tests/StompContextTest.php | 2 +- pkg/stomp/Tests/StompDestinationTest.php | 2 +- pkg/stomp/Tests/StompHeadersEncoderTest.php | 2 +- pkg/stomp/Tests/StompMessageTest.php | 2 +- pkg/stomp/Tests/StompProducerTest.php | 2 +- pkg/stomp/Tests/Symfony/RabbitMqStompTransportFactoryTest.php | 2 +- pkg/stomp/Tests/Symfony/StompTransportFactoryTest.php | 2 +- 127 files changed, 214 insertions(+), 129 deletions(-) diff --git a/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php b/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php index 17017090e..1826b537c 100644 --- a/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php +++ b/pkg/amqp-ext/Tests/AmqpConnectionFactoryTest.php @@ -6,8 +6,9 @@ use Enqueue\AmqpExt\AmqpContext; use Enqueue\Psr\PsrConnectionFactory; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class AmqpConnectionFactoryTest extends \PHPUnit_Framework_TestCase +class AmqpConnectionFactoryTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/AmqpConsumerTest.php b/pkg/amqp-ext/Tests/AmqpConsumerTest.php index 7615dc6c6..c05a2832a 100644 --- a/pkg/amqp-ext/Tests/AmqpConsumerTest.php +++ b/pkg/amqp-ext/Tests/AmqpConsumerTest.php @@ -8,8 +8,9 @@ use Enqueue\AmqpExt\Buffer; use Enqueue\Psr\PsrConsumer; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class AmqpConsumerTest extends \PHPUnit_Framework_TestCase +class AmqpConsumerTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/AmqpContextTest.php b/pkg/amqp-ext/Tests/AmqpContextTest.php index 0ee05d06c..c06384500 100644 --- a/pkg/amqp-ext/Tests/AmqpContextTest.php +++ b/pkg/amqp-ext/Tests/AmqpContextTest.php @@ -14,8 +14,9 @@ use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullQueue; use Enqueue\Transport\Null\NullTopic; +use PHPUnit\Framework\TestCase; -class AmqpContextTest extends \PHPUnit_Framework_TestCase +class AmqpContextTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/AmqpMessageTest.php b/pkg/amqp-ext/Tests/AmqpMessageTest.php index 0754d9199..495fdf192 100644 --- a/pkg/amqp-ext/Tests/AmqpMessageTest.php +++ b/pkg/amqp-ext/Tests/AmqpMessageTest.php @@ -5,8 +5,9 @@ use Enqueue\AmqpExt\AmqpMessage; use Enqueue\Psr\PsrMessage; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class AmqpMessageTest extends \PHPUnit_Framework_TestCase +class AmqpMessageTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/AmqpProducerTest.php b/pkg/amqp-ext/Tests/AmqpProducerTest.php index 1871bf444..ba789ab18 100644 --- a/pkg/amqp-ext/Tests/AmqpProducerTest.php +++ b/pkg/amqp-ext/Tests/AmqpProducerTest.php @@ -5,8 +5,9 @@ use Enqueue\AmqpExt\AmqpProducer; use Enqueue\Psr\PsrProducer; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class AmqpProducerTest extends \PHPUnit_Framework_TestCase +class AmqpProducerTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/AmqpQueueTest.php b/pkg/amqp-ext/Tests/AmqpQueueTest.php index 33c2ee31e..673bb3fe2 100644 --- a/pkg/amqp-ext/Tests/AmqpQueueTest.php +++ b/pkg/amqp-ext/Tests/AmqpQueueTest.php @@ -5,8 +5,9 @@ use Enqueue\AmqpExt\AmqpQueue; use Enqueue\Psr\PsrQueue; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class AmqpQueueTest extends \PHPUnit_Framework_TestCase +class AmqpQueueTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/AmqpTopicTest.php b/pkg/amqp-ext/Tests/AmqpTopicTest.php index fb730e511..13656d792 100644 --- a/pkg/amqp-ext/Tests/AmqpTopicTest.php +++ b/pkg/amqp-ext/Tests/AmqpTopicTest.php @@ -5,8 +5,9 @@ use Enqueue\AmqpExt\AmqpTopic; use Enqueue\Psr\PsrTopic; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class AmqpTopicTest extends \PHPUnit_Framework_TestCase +class AmqpTopicTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/BufferTest.php b/pkg/amqp-ext/Tests/BufferTest.php index a5be47829..151481f91 100644 --- a/pkg/amqp-ext/Tests/BufferTest.php +++ b/pkg/amqp-ext/Tests/BufferTest.php @@ -4,8 +4,9 @@ use Enqueue\AmqpExt\AmqpMessage; use Enqueue\AmqpExt\Buffer; +use PHPUnit\Framework\TestCase; -class BufferTest extends \PHPUnit_Framework_TestCase +class BufferTest extends TestCase { public function testCouldBeConstructedWithoutAnyArguments() { diff --git a/pkg/amqp-ext/Tests/Client/AmqpDriverTest.php b/pkg/amqp-ext/Tests/Client/AmqpDriverTest.php index 3b6165d5a..68aa2ceaa 100644 --- a/pkg/amqp-ext/Tests/Client/AmqpDriverTest.php +++ b/pkg/amqp-ext/Tests/Client/AmqpDriverTest.php @@ -13,8 +13,9 @@ use Enqueue\Client\Meta\QueueMetaRegistry; use Enqueue\Psr\PsrProducer; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class AmqpDriverTest extends \PHPUnit_Framework_TestCase +class AmqpDriverTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/Client/RabbitMqDriverTest.php b/pkg/amqp-ext/Tests/Client/RabbitMqDriverTest.php index 54c023c1f..bc2a47c18 100644 --- a/pkg/amqp-ext/Tests/Client/RabbitMqDriverTest.php +++ b/pkg/amqp-ext/Tests/Client/RabbitMqDriverTest.php @@ -15,8 +15,9 @@ use Enqueue\Client\Meta\QueueMetaRegistry; use Enqueue\Psr\PsrProducer; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class RabbitMqDriverTest extends \PHPUnit_Framework_TestCase +class RabbitMqDriverTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php index d92480d63..70a2c2605 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpCommonUseCasesTest.php @@ -6,11 +6,12 @@ use Enqueue\AmqpExt\AmqpMessage; use Enqueue\Test\RabbitmqAmqpExtension; use Enqueue\Test\RabbitmqManagmentExtensionTrait; +use PHPUnit\Framework\TestCase; /** * @group functional */ -class AmqpCommonUseCasesTest extends \PHPUnit_Framework_TestCase +class AmqpCommonUseCasesTest extends TestCase { use RabbitmqAmqpExtension; use RabbitmqManagmentExtensionTrait; diff --git a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php index 463e05b4b..68129d60f 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpConsumptionUseCasesTest.php @@ -14,11 +14,12 @@ use Enqueue\Psr\PsrProcessor; use Enqueue\Test\RabbitmqAmqpExtension; use Enqueue\Test\RabbitmqManagmentExtensionTrait; +use PHPUnit\Framework\TestCase; /** * @group functional */ -class AmqpConsumptionUseCasesTest extends \PHPUnit_Framework_TestCase +class AmqpConsumptionUseCasesTest extends TestCase { use RabbitmqAmqpExtension; use RabbitmqManagmentExtensionTrait; diff --git a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php index 3085e858f..149663add 100644 --- a/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php +++ b/pkg/amqp-ext/Tests/Functional/AmqpRpcUseCasesTest.php @@ -8,11 +8,12 @@ use Enqueue\Rpc\RpcClient; use Enqueue\Test\RabbitmqAmqpExtension; use Enqueue\Test\RabbitmqManagmentExtensionTrait; +use PHPUnit\Framework\TestCase; /** * @group functional */ -class AmqpRpcUseCasesTest extends \PHPUnit_Framework_TestCase +class AmqpRpcUseCasesTest extends TestCase { use RabbitmqAmqpExtension; use RabbitmqManagmentExtensionTrait; diff --git a/pkg/amqp-ext/Tests/Symfony/AmqpTransportFactoryTest.php b/pkg/amqp-ext/Tests/Symfony/AmqpTransportFactoryTest.php index ba4dee55c..15b83354f 100644 --- a/pkg/amqp-ext/Tests/Symfony/AmqpTransportFactoryTest.php +++ b/pkg/amqp-ext/Tests/Symfony/AmqpTransportFactoryTest.php @@ -11,8 +11,9 @@ use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; +use PHPUnit\Framework\TestCase; -class AmqpTransportFactoryTest extends \PHPUnit_Framework_TestCase +class AmqpTransportFactoryTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/amqp-ext/Tests/Symfony/RabbitMqAmqpTransportFactoryTest.php b/pkg/amqp-ext/Tests/Symfony/RabbitMqAmqpTransportFactoryTest.php index 425ef7197..fda404f67 100644 --- a/pkg/amqp-ext/Tests/Symfony/RabbitMqAmqpTransportFactoryTest.php +++ b/pkg/amqp-ext/Tests/Symfony/RabbitMqAmqpTransportFactoryTest.php @@ -12,8 +12,9 @@ use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; +use PHPUnit\Framework\TestCase; -class RabbitMqAmqpTransportFactoryTest extends \PHPUnit_Framework_TestCase +class RabbitMqAmqpTransportFactoryTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php index a05a1203a..2ebda8859 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrineClearIdentityMapExtensionTest.php @@ -10,8 +10,9 @@ use Enqueue\Psr\PsrProcessor; use Psr\Log\LoggerInterface; use Symfony\Bridge\Doctrine\RegistryInterface; +use PHPUnit\Framework\TestCase; -class DoctrineClearIdentityMapExtensionTest extends \PHPUnit_Framework_TestCase +class DoctrineClearIdentityMapExtensionTest extends TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php index d6d621df0..85d739ae5 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Consumption/Extension/DoctrinePingConnectionExtensionTest.php @@ -10,8 +10,9 @@ use Enqueue\Psr\PsrProcessor; use Psr\Log\LoggerInterface; use Symfony\Bridge\Doctrine\RegistryInterface; +use PHPUnit\Framework\TestCase; -class DoctrinePingConnectionExtensionTest extends \PHPUnit_Framework_TestCase +class DoctrinePingConnectionExtensionTest extends TestCase { public function testCouldBeConstructedWithRequiredAttributes() { diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php index b7efc8551..0a5756f9f 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/AddTopicMetaPassTest.php @@ -7,8 +7,9 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use PHPUnit\Framework\TestCase; -class AddTopicMetaPassTest extends \PHPUnit_Framework_TestCase +class AddTopicMetaPassTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildClientRoutingPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildClientRoutingPassTest.php index 6c8472fb3..7a9837cf1 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildClientRoutingPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildClientRoutingPassTest.php @@ -9,8 +9,9 @@ use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\QueueNameTopicSubscriber; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use PHPUnit\Framework\TestCase; -class BuildClientRoutingPassTest extends \PHPUnit_Framework_TestCase +class BuildClientRoutingPassTest extends TestCase { public function testCouldBeConstructedWithoutAnyArguments() { diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildExtensionsPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildExtensionsPassTest.php index 0d57167dd..8f02a365b 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildExtensionsPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildExtensionsPassTest.php @@ -8,8 +8,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Reference; +use PHPUnit\Framework\TestCase; -class BuildExtensionsPassTest extends \PHPUnit_Framework_TestCase +class BuildExtensionsPassTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildProcessorRegistryPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildProcessorRegistryPassTest.php index b210ff51d..c4abda68d 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildProcessorRegistryPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildProcessorRegistryPassTest.php @@ -8,8 +8,9 @@ use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameTopicSubscriber; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use PHPUnit\Framework\TestCase; -class BuildProcessorRegistryPassTest extends \PHPUnit_Framework_TestCase +class BuildProcessorRegistryPassTest extends TestCase { public function testCouldBeConstructedWithoutAnyArguments() { diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildQueueMetaRegistryPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildQueueMetaRegistryPassTest.php index 79665080e..721e375a4 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildQueueMetaRegistryPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildQueueMetaRegistryPassTest.php @@ -8,8 +8,9 @@ use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\QueueNameTopicSubscriber; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use PHPUnit\Framework\TestCase; -class BuildQueueMetaRegistryPassTest extends \PHPUnit_Framework_TestCase +class BuildQueueMetaRegistryPassTest extends TestCase { public function testCouldBeConstructedWithoutAnyArguments() { diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildTopicMetaSubscribersPassTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildTopicMetaSubscribersPassTest.php index affac5854..853c4cb13 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildTopicMetaSubscribersPassTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/Compiler/BuildTopicMetaSubscribersPassTest.php @@ -8,8 +8,9 @@ use Enqueue\Bundle\Tests\Unit\DependencyInjection\Compiler\Mock\ProcessorNameTopicSubscriber; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Definition; +use PHPUnit\Framework\TestCase; -class BuildTopicMetaSubscribersPassTest extends \PHPUnit_Framework_TestCase +class BuildTopicMetaSubscribersPassTest extends TestCase { public function testCouldBeConstructedWithoutAnyArguments() { diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php index 535f6051b..5f3f64827 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/ConfigurationTest.php @@ -10,8 +10,9 @@ use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; use Symfony\Component\Config\Definition\Processor; +use PHPUnit\Framework\TestCase; -class ConfigurationTest extends \PHPUnit_Framework_TestCase +class ConfigurationTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php index ea852a353..5a1a46b47 100644 --- a/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/DependencyInjection/EnqueueExtensionTest.php @@ -14,8 +14,9 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use PHPUnit\Framework\TestCase; -class EnqueueExtensionTest extends \PHPUnit_Framework_TestCase +class EnqueueExtensionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php b/pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php index 3f390fa78..585d59057 100644 --- a/pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/EnqueueBundleTest.php @@ -19,8 +19,9 @@ use Enqueue\Test\ClassExtensionTrait; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; +use PHPUnit\Framework\TestCase; -class EnqueueBundleTest extends \PHPUnit_Framework_TestCase +class EnqueueBundleTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php b/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php index b40823292..451d606ee 100644 --- a/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php +++ b/pkg/enqueue-bundle/Tests/Unit/Profiler/MessageQueueCollectorTest.php @@ -10,8 +10,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; +use PHPUnit\Framework\TestCase; -class MessageQueueCollectorTest extends \PHPUnit_Framework_TestCase +class MessageQueueCollectorTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Client/ArrayProcessorRegistryTest.php b/pkg/enqueue/Tests/Client/ArrayProcessorRegistryTest.php index f11e34012..1d651e538 100644 --- a/pkg/enqueue/Tests/Client/ArrayProcessorRegistryTest.php +++ b/pkg/enqueue/Tests/Client/ArrayProcessorRegistryTest.php @@ -6,8 +6,9 @@ use Enqueue\Client\ProcessorRegistryInterface; use Enqueue\Psr\PsrProcessor; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class ArrayProcessorRegistryTest extends \PHPUnit_Framework_TestCase +class ArrayProcessorRegistryTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Client/ConfigTest.php b/pkg/enqueue/Tests/Client/ConfigTest.php index 7d2c0a499..73d69754e 100644 --- a/pkg/enqueue/Tests/Client/ConfigTest.php +++ b/pkg/enqueue/Tests/Client/ConfigTest.php @@ -3,8 +3,9 @@ namespace Enqueue\Tests\Client; use Enqueue\Client\Config; +use PHPUnit\Framework\TestCase; -class ConfigTest extends \PHPUnit_Framework_TestCase +class ConfigTest extends TestCase { public function testShouldReturnRouterProcessorNameSetInConstructor() { diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php index e9f6450fc..e3afb4cfc 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/DelayRedeliveredMessageExtensionTest.php @@ -11,8 +11,9 @@ use Enqueue\Transport\Null\NullMessage; use Enqueue\Transport\Null\NullQueue; use Psr\Log\LoggerInterface; +use PHPUnit\Framework\TestCase; -class DelayRedeliveredMessageExtensionTest extends \PHPUnit_Framework_TestCase +class DelayRedeliveredMessageExtensionTest extends TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php index 0bfbf41e9..19a5d18a1 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetRouterPropertiesExtensionTest.php @@ -10,8 +10,9 @@ use Enqueue\Psr\PsrContext; use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullMessage; +use PHPUnit\Framework\TestCase; -class SetRouterPropertiesExtensionTest extends \PHPUnit_Framework_TestCase +class SetRouterPropertiesExtensionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php index 8ae1fbd71..85a7e26e1 100644 --- a/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php +++ b/pkg/enqueue/Tests/Client/ConsumptionExtension/SetupBrokerExtensionTest.php @@ -9,8 +9,9 @@ use Enqueue\Psr\PsrContext; use Enqueue\Test\ClassExtensionTrait; use Psr\Log\NullLogger; +use PHPUnit\Framework\TestCase; -class SetupBrokerExtensionTest extends \PHPUnit_Framework_TestCase +class SetupBrokerExtensionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Client/DelegateProcessorTest.php b/pkg/enqueue/Tests/Client/DelegateProcessorTest.php index 11b374a78..83c2dea89 100644 --- a/pkg/enqueue/Tests/Client/DelegateProcessorTest.php +++ b/pkg/enqueue/Tests/Client/DelegateProcessorTest.php @@ -8,8 +8,9 @@ use Enqueue\Psr\PsrContext; use Enqueue\Psr\PsrProcessor; use Enqueue\Transport\Null\NullMessage; +use PHPUnit\Framework\TestCase; -class DelegateProcessorTest extends \PHPUnit_Framework_TestCase +class DelegateProcessorTest extends TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/enqueue/Tests/Client/MessagePriorityTest.php b/pkg/enqueue/Tests/Client/MessagePriorityTest.php index 5778e0299..a677884d2 100644 --- a/pkg/enqueue/Tests/Client/MessagePriorityTest.php +++ b/pkg/enqueue/Tests/Client/MessagePriorityTest.php @@ -3,8 +3,9 @@ namespace Enqueue\Tests\Client; use Enqueue\Client\MessagePriority; +use PHPUnit\Framework\TestCase; -class MessagePriorityTest extends \PHPUnit_Framework_TestCase +class MessagePriorityTest extends TestCase { public function testShouldVeryLowPriorityHasExpectedValue() { diff --git a/pkg/enqueue/Tests/Client/MessageTest.php b/pkg/enqueue/Tests/Client/MessageTest.php index 694d818a0..1558792ae 100644 --- a/pkg/enqueue/Tests/Client/MessageTest.php +++ b/pkg/enqueue/Tests/Client/MessageTest.php @@ -3,8 +3,9 @@ namespace Enqueue\Tests\Client; use Enqueue\Client\Message; +use PHPUnit\Framework\TestCase; -class MessageTest extends \PHPUnit_Framework_TestCase +class MessageTest extends TestCase { public function testCouldBeConstructedWithoutAnyArguments() { diff --git a/pkg/enqueue/Tests/Client/Meta/QueueMetaRegistryTest.php b/pkg/enqueue/Tests/Client/Meta/QueueMetaRegistryTest.php index 028ab941e..a759390fa 100644 --- a/pkg/enqueue/Tests/Client/Meta/QueueMetaRegistryTest.php +++ b/pkg/enqueue/Tests/Client/Meta/QueueMetaRegistryTest.php @@ -5,8 +5,9 @@ use Enqueue\Client\Config; use Enqueue\Client\Meta\QueueMeta; use Enqueue\Client\Meta\QueueMetaRegistry; +use PHPUnit\Framework\TestCase; -class QueueMetaRegistryTest extends \PHPUnit_Framework_TestCase +class QueueMetaRegistryTest extends TestCase { public function testCouldBeConstructedWithQueues() { diff --git a/pkg/enqueue/Tests/Client/Meta/QueueMetaTest.php b/pkg/enqueue/Tests/Client/Meta/QueueMetaTest.php index b184c06a6..e98a163dc 100644 --- a/pkg/enqueue/Tests/Client/Meta/QueueMetaTest.php +++ b/pkg/enqueue/Tests/Client/Meta/QueueMetaTest.php @@ -3,8 +3,9 @@ namespace Enqueue\Tests\Client\Meta; use Enqueue\Client\Meta\QueueMeta; +use PHPUnit\Framework\TestCase; -class QueueMetaTest extends \PHPUnit_Framework_TestCase +class QueueMetaTest extends TestCase { public function testCouldBeConstructedWithExpectedArguments() { diff --git a/pkg/enqueue/Tests/Client/Meta/TopicMetaRegistryTest.php b/pkg/enqueue/Tests/Client/Meta/TopicMetaRegistryTest.php index 9f41e4dca..ce074b6b1 100644 --- a/pkg/enqueue/Tests/Client/Meta/TopicMetaRegistryTest.php +++ b/pkg/enqueue/Tests/Client/Meta/TopicMetaRegistryTest.php @@ -4,8 +4,9 @@ use Enqueue\Client\Meta\TopicMeta; use Enqueue\Client\Meta\TopicMetaRegistry; +use PHPUnit\Framework\TestCase; -class TopicMetaRegistryTest extends \PHPUnit_Framework_TestCase +class TopicMetaRegistryTest extends TestCase { public function testCouldBeConstructedWithTopics() { diff --git a/pkg/enqueue/Tests/Client/Meta/TopicMetaTest.php b/pkg/enqueue/Tests/Client/Meta/TopicMetaTest.php index ac5c2992d..565a8f821 100644 --- a/pkg/enqueue/Tests/Client/Meta/TopicMetaTest.php +++ b/pkg/enqueue/Tests/Client/Meta/TopicMetaTest.php @@ -3,8 +3,9 @@ namespace Enqueue\Tests\Client\Meta; use Enqueue\Client\Meta\TopicMeta; +use PHPUnit\Framework\TestCase; -class TopicMetaTest extends \PHPUnit_Framework_TestCase +class TopicMetaTest extends TestCase { public function testCouldBeConstructedWithNameOnly() { diff --git a/pkg/enqueue/Tests/Client/NullDriverTest.php b/pkg/enqueue/Tests/Client/NullDriverTest.php index aeed69a22..d81298fc1 100644 --- a/pkg/enqueue/Tests/Client/NullDriverTest.php +++ b/pkg/enqueue/Tests/Client/NullDriverTest.php @@ -11,8 +11,9 @@ use Enqueue\Transport\Null\NullProducer; use Enqueue\Transport\Null\NullQueue; use Enqueue\Transport\Null\NullTopic; +use PHPUnit\Framework\TestCase; -class NullDriverTest extends \PHPUnit_Framework_TestCase +class NullDriverTest extends TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/enqueue/Tests/Client/ProducerTest.php b/pkg/enqueue/Tests/Client/ProducerTest.php index 9c2c99274..107736593 100644 --- a/pkg/enqueue/Tests/Client/ProducerTest.php +++ b/pkg/enqueue/Tests/Client/ProducerTest.php @@ -10,8 +10,9 @@ use Enqueue\Client\ProducerInterface; use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullQueue; +use PHPUnit\Framework\TestCase; -class ProducerTest extends \PHPUnit_Framework_TestCase +class ProducerTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Client/RouterProcessorTest.php b/pkg/enqueue/Tests/Client/RouterProcessorTest.php index 498e31fb5..20d0d547e 100644 --- a/pkg/enqueue/Tests/Client/RouterProcessorTest.php +++ b/pkg/enqueue/Tests/Client/RouterProcessorTest.php @@ -9,8 +9,9 @@ use Enqueue\Consumption\Result; use Enqueue\Transport\Null\NullContext; use Enqueue\Transport\Null\NullMessage; +use PHPUnit\Framework\TestCase; -class RouterProcessorTest extends \PHPUnit_Framework_TestCase +class RouterProcessorTest extends TestCase { public function testCouldBeConstructedWithDriverAsFirstArgument() { diff --git a/pkg/enqueue/Tests/Client/RpcClientTest.php b/pkg/enqueue/Tests/Client/RpcClientTest.php index e32cacfe6..7fc9042f0 100644 --- a/pkg/enqueue/Tests/Client/RpcClientTest.php +++ b/pkg/enqueue/Tests/Client/RpcClientTest.php @@ -10,8 +10,9 @@ use Enqueue\Rpc\Promise; use Enqueue\Transport\Null\NullContext; use Enqueue\Transport\Null\NullMessage; +use PHPUnit\Framework\TestCase; -class RpcClientTest extends \PHPUnit_Framework_TestCase +class RpcClientTest extends TestCase { public function testCouldBeConstructedWithPsrContextDriverAndProducerAsArguments() { diff --git a/pkg/enqueue/Tests/Client/TraceableProducerTest.php b/pkg/enqueue/Tests/Client/TraceableProducerTest.php index d290888b4..0912a549b 100644 --- a/pkg/enqueue/Tests/Client/TraceableProducerTest.php +++ b/pkg/enqueue/Tests/Client/TraceableProducerTest.php @@ -6,8 +6,9 @@ use Enqueue\Client\ProducerInterface; use Enqueue\Client\TraceableProducer; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class TraceableProducerTest extends \PHPUnit_Framework_TestCase +class TraceableProducerTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php b/pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php index 91e5c49c7..3a48b1e27 100644 --- a/pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php +++ b/pkg/enqueue/Tests/Consumption/CallbackProcessorTest.php @@ -7,8 +7,9 @@ use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullContext; use Enqueue\Transport\Null\NullMessage; +use PHPUnit\Framework\TestCase; -class CallbackProcessorTest extends \PHPUnit_Framework_TestCase +class CallbackProcessorTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/ChainExtensionTest.php b/pkg/enqueue/Tests/Consumption/ChainExtensionTest.php index eaca06858..4c412c661 100644 --- a/pkg/enqueue/Tests/Consumption/ChainExtensionTest.php +++ b/pkg/enqueue/Tests/Consumption/ChainExtensionTest.php @@ -6,8 +6,9 @@ use Enqueue\Consumption\Context; use Enqueue\Consumption\ExtensionInterface; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class ChainExtensionTest extends \PHPUnit_Framework_TestCase +class ChainExtensionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/ContextTest.php b/pkg/enqueue/Tests/Consumption/ContextTest.php index cdbc5e443..1773bbeb2 100644 --- a/pkg/enqueue/Tests/Consumption/ContextTest.php +++ b/pkg/enqueue/Tests/Consumption/ContextTest.php @@ -11,8 +11,9 @@ use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullQueue; use Psr\Log\NullLogger; +use PHPUnit\Framework\TestCase; -class ContextTest extends \PHPUnit_Framework_TestCase +class ContextTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/Exception/ConsumptionInterruptedExceptionTest.php b/pkg/enqueue/Tests/Consumption/Exception/ConsumptionInterruptedExceptionTest.php index f4fa0678d..100f68e61 100644 --- a/pkg/enqueue/Tests/Consumption/Exception/ConsumptionInterruptedExceptionTest.php +++ b/pkg/enqueue/Tests/Consumption/Exception/ConsumptionInterruptedExceptionTest.php @@ -5,8 +5,9 @@ use Enqueue\Consumption\Exception\ConsumptionInterruptedException; use Enqueue\Consumption\Exception\ExceptionInterface; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class ConsumptionInterruptedExceptionTest extends \PHPUnit_Framework_TestCase +class ConsumptionInterruptedExceptionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/Exception/IllegalContextModificationExceptionTest.php b/pkg/enqueue/Tests/Consumption/Exception/IllegalContextModificationExceptionTest.php index 436e594d7..3a91b3111 100644 --- a/pkg/enqueue/Tests/Consumption/Exception/IllegalContextModificationExceptionTest.php +++ b/pkg/enqueue/Tests/Consumption/Exception/IllegalContextModificationExceptionTest.php @@ -5,8 +5,9 @@ use Enqueue\Consumption\Exception\ExceptionInterface; use Enqueue\Consumption\Exception\IllegalContextModificationException; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class IllegalContextModificationExceptionTest extends \PHPUnit_Framework_TestCase +class IllegalContextModificationExceptionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/Exception/InvalidArgumentExceptionTest.php b/pkg/enqueue/Tests/Consumption/Exception/InvalidArgumentExceptionTest.php index 16c3b3c6f..652363658 100644 --- a/pkg/enqueue/Tests/Consumption/Exception/InvalidArgumentExceptionTest.php +++ b/pkg/enqueue/Tests/Consumption/Exception/InvalidArgumentExceptionTest.php @@ -5,8 +5,9 @@ use Enqueue\Consumption\Exception\ExceptionInterface; use Enqueue\Consumption\Exception\InvalidArgumentException; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class InvalidArgumentExceptionTest extends \PHPUnit_Framework_TestCase +class InvalidArgumentExceptionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/Exception/LogicExceptionTest.php b/pkg/enqueue/Tests/Consumption/Exception/LogicExceptionTest.php index d81975d3c..0e072bd1f 100644 --- a/pkg/enqueue/Tests/Consumption/Exception/LogicExceptionTest.php +++ b/pkg/enqueue/Tests/Consumption/Exception/LogicExceptionTest.php @@ -5,8 +5,9 @@ use Enqueue\Consumption\Exception\ExceptionInterface; use Enqueue\Consumption\Exception\LogicException; use Enqueue\Test\ClassExtensionTrait; +use PHPUnit\Framework\TestCase; -class LogicExceptionTest extends \PHPUnit_Framework_TestCase +class LogicExceptionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumedMessagesExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumedMessagesExtensionTest.php index f01cbc2f1..8ff1fce81 100644 --- a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumedMessagesExtensionTest.php +++ b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumedMessagesExtensionTest.php @@ -8,8 +8,9 @@ use Enqueue\Psr\PsrContext; use Enqueue\Psr\PsrProcessor; use Psr\Log\LoggerInterface; +use PHPUnit\Framework\TestCase; -class LimitConsumedMessagesExtensionTest extends \PHPUnit_Framework_TestCase +class LimitConsumedMessagesExtensionTest extends TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php index 3b8c7af4e..eeff7cdf7 100644 --- a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php +++ b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumerMemoryExtensionTest.php @@ -8,8 +8,9 @@ use Enqueue\Psr\PsrContext; use Enqueue\Psr\PsrProcessor; use Psr\Log\LoggerInterface; +use PHPUnit\Framework\TestCase; -class LimitConsumerMemoryExtensionTest extends \PHPUnit_Framework_TestCase +class LimitConsumerMemoryExtensionTest extends TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumptionTimeExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumptionTimeExtensionTest.php index ba0e01d63..afe5ae790 100644 --- a/pkg/enqueue/Tests/Consumption/Extension/LimitConsumptionTimeExtensionTest.php +++ b/pkg/enqueue/Tests/Consumption/Extension/LimitConsumptionTimeExtensionTest.php @@ -8,8 +8,9 @@ use Enqueue\Psr\PsrContext; use Enqueue\Psr\PsrProcessor; use Psr\Log\LoggerInterface; +use PHPUnit\Framework\TestCase; -class LimitConsumptionTimeExtensionTest extends \PHPUnit_Framework_TestCase +class LimitConsumptionTimeExtensionTest extends TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php index 63ff58861..9f2cf6ce9 100644 --- a/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php +++ b/pkg/enqueue/Tests/Consumption/Extension/LoggerExtensionTest.php @@ -11,8 +11,9 @@ use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullMessage; use Psr\Log\LoggerInterface; +use PHPUnit\Framework\TestCase; -class LoggerExtensionTest extends \PHPUnit_Framework_TestCase +class LoggerExtensionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/Extension/ReplyExtensionTest.php b/pkg/enqueue/Tests/Consumption/Extension/ReplyExtensionTest.php index f676ca1e6..4efaec3db 100644 --- a/pkg/enqueue/Tests/Consumption/Extension/ReplyExtensionTest.php +++ b/pkg/enqueue/Tests/Consumption/Extension/ReplyExtensionTest.php @@ -9,11 +9,11 @@ use Enqueue\Psr\PsrContext; use Enqueue\Psr\PsrProducer; use Enqueue\Test\ClassExtensionTrait; -use Enqueue\Transport\Null\NullContext; use Enqueue\Transport\Null\NullMessage; use Enqueue\Transport\Null\NullQueue; +use PHPUnit\Framework\TestCase; -class ReplyExtensionTest extends \PHPUnit_Framework_TestCase +class ReplyExtensionTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php index 972321175..d72ae372b 100644 --- a/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php +++ b/pkg/enqueue/Tests/Consumption/QueueConsumerTest.php @@ -17,8 +17,9 @@ use Enqueue\Tests\Consumption\Mock\BreakCycleExtension; use Enqueue\Transport\Null\NullQueue; use Psr\Log\NullLogger; +use PHPUnit\Framework\TestCase; -class QueueConsumerTest extends \PHPUnit_Framework_TestCase +class QueueConsumerTest extends TestCase { public function testCouldBeConstructedWithConnectionAndExtensionsAsArguments() { diff --git a/pkg/enqueue/Tests/Consumption/ResultTest.php b/pkg/enqueue/Tests/Consumption/ResultTest.php index 20b675593..e26311813 100644 --- a/pkg/enqueue/Tests/Consumption/ResultTest.php +++ b/pkg/enqueue/Tests/Consumption/ResultTest.php @@ -4,8 +4,9 @@ use Enqueue\Consumption\Result; use Enqueue\Transport\Null\NullMessage; +use PHPUnit\Framework\TestCase; -class ResultTest extends \PHPUnit_Framework_TestCase +class ResultTest extends TestCase { public function testCouldBeConstructedWithExpectedArguments() { diff --git a/pkg/enqueue/Tests/Functional/Client/RpcClientTest.php b/pkg/enqueue/Tests/Functional/Client/RpcClientTest.php index 23530281d..ee409a156 100644 --- a/pkg/enqueue/Tests/Functional/Client/RpcClientTest.php +++ b/pkg/enqueue/Tests/Functional/Client/RpcClientTest.php @@ -12,11 +12,11 @@ use Enqueue\Consumption\Result; use Enqueue\Psr\PsrContext; use Enqueue\Psr\PsrMessage; -use Enqueue\Symfony\Client\SetupBrokerCommand; use Enqueue\Test\RabbitmqAmqpExtension; use Enqueue\Test\RabbitmqManagmentExtensionTrait; +use PHPUnit\Framework\TestCase; -class RpcClientTest extends \PHPUnit_Framework_TestCase +class RpcClientTest extends TestCase { use RabbitmqAmqpExtension; use RabbitmqManagmentExtensionTrait; diff --git a/pkg/enqueue/Tests/Functional/Client/SimpleClientTest.php b/pkg/enqueue/Tests/Functional/Client/SimpleClientTest.php index 1c4b1a2b5..c62b5903b 100644 --- a/pkg/enqueue/Tests/Functional/Client/SimpleClientTest.php +++ b/pkg/enqueue/Tests/Functional/Client/SimpleClientTest.php @@ -11,8 +11,9 @@ use Enqueue\Psr\PsrMessage; use Enqueue\Test\RabbitmqAmqpExtension; use Enqueue\Test\RabbitmqManagmentExtensionTrait; +use PHPUnit\Framework\TestCase; -class SimpleClientTest extends \PHPUnit_Framework_TestCase +class SimpleClientTest extends TestCase { use RabbitmqAmqpExtension; use RabbitmqManagmentExtensionTrait; diff --git a/pkg/enqueue/Tests/Router/RecipientTest.php b/pkg/enqueue/Tests/Router/RecipientTest.php index edb2a78a2..0662c7f12 100644 --- a/pkg/enqueue/Tests/Router/RecipientTest.php +++ b/pkg/enqueue/Tests/Router/RecipientTest.php @@ -5,8 +5,9 @@ use Enqueue\Psr\PsrDestination; use Enqueue\Psr\PsrMessage; use Enqueue\Router\Recipient; +use PHPUnit\Framework\TestCase; -class RecipientTest extends \PHPUnit_Framework_TestCase +class RecipientTest extends TestCase { public function testShouldAllowGetMessageSetInConstructor() { diff --git a/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php b/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php index 807ca35d2..25cc5bf0e 100644 --- a/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php +++ b/pkg/enqueue/Tests/Router/RouteRecipientListProcessorTest.php @@ -12,8 +12,9 @@ use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullMessage; use Enqueue\Transport\Null\NullQueue; +use PHPUnit\Framework\TestCase; -class RouteRecipientListProcessorTest extends \PHPUnit_Framework_TestCase +class RouteRecipientListProcessorTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Rpc/PromiseTest.php b/pkg/enqueue/Tests/Rpc/PromiseTest.php index 90d2cc3cd..11b49a3a9 100644 --- a/pkg/enqueue/Tests/Rpc/PromiseTest.php +++ b/pkg/enqueue/Tests/Rpc/PromiseTest.php @@ -6,8 +6,9 @@ use Enqueue\Rpc\Promise; use Enqueue\Rpc\TimeoutException; use Enqueue\Transport\Null\NullMessage; +use PHPUnit\Framework\TestCase; -class PromiseTest extends \PHPUnit_Framework_TestCase +class PromiseTest extends TestCase { public function testCouldBeConstructedWithExpectedSetOfArguments() { diff --git a/pkg/enqueue/Tests/Rpc/RpcClientTest.php b/pkg/enqueue/Tests/Rpc/RpcClientTest.php index 814b214e0..c64dc44dc 100644 --- a/pkg/enqueue/Tests/Rpc/RpcClientTest.php +++ b/pkg/enqueue/Tests/Rpc/RpcClientTest.php @@ -10,8 +10,9 @@ use Enqueue\Transport\Null\NullContext; use Enqueue\Transport\Null\NullMessage; use Enqueue\Transport\Null\NullQueue; +use PHPUnit\Framework\TestCase; -class RpcClientTest extends \PHPUnit_Framework_TestCase +class RpcClientTest extends TestCase { public function testCouldBeConstructedWithPsrContextAsFirstArgument() { diff --git a/pkg/enqueue/Tests/Rpc/TimeoutExceptionTest.php b/pkg/enqueue/Tests/Rpc/TimeoutExceptionTest.php index 0b5c732fc..1c5b9a57a 100644 --- a/pkg/enqueue/Tests/Rpc/TimeoutExceptionTest.php +++ b/pkg/enqueue/Tests/Rpc/TimeoutExceptionTest.php @@ -2,8 +2,9 @@ namespace Enqueue\Tests\Rpc; use Enqueue\Rpc\TimeoutException; +use PHPUnit\Framework\TestCase; -class TimeoutExceptionTest extends \PHPUnit_Framework_TestCase +class TimeoutExceptionTest extends TestCase { public function testShouldBeSubClassOfLogicException() { diff --git a/pkg/enqueue/Tests/Symfony/Client/ConsumeMessagesCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ConsumeMessagesCommandTest.php index 2d57316bc..603f0c15e 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ConsumeMessagesCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ConsumeMessagesCommandTest.php @@ -12,8 +12,9 @@ use Enqueue\Symfony\Client\ConsumeMessagesCommand; use Enqueue\Transport\Null\NullQueue; use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit\Framework\TestCase; -class ConsumeMessagesCommandTest extends \PHPUnit_Framework_TestCase +class ConsumeMessagesCommandTest extends TestCase { public function testCouldBeConstructedWithRequiredAttributes() { diff --git a/pkg/enqueue/Tests/Symfony/Client/ContainerAwareProcessorRegistryTest.php b/pkg/enqueue/Tests/Symfony/Client/ContainerAwareProcessorRegistryTest.php index 42f8fb7cb..645f50f05 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ContainerAwareProcessorRegistryTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ContainerAwareProcessorRegistryTest.php @@ -7,8 +7,9 @@ use Enqueue\Symfony\Client\ContainerAwareProcessorRegistry; use Enqueue\Test\ClassExtensionTrait; use Symfony\Component\DependencyInjection\Container; +use PHPUnit\Framework\TestCase; -class ContainerAwareProcessorRegistryTest extends \PHPUnit_Framework_TestCase +class ContainerAwareProcessorRegistryTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Symfony/Client/Meta/QueuesCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/Meta/QueuesCommandTest.php index 0f36d806a..052b6cbb2 100644 --- a/pkg/enqueue/Tests/Symfony/Client/Meta/QueuesCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/Meta/QueuesCommandTest.php @@ -8,8 +8,9 @@ use Enqueue\Test\ClassExtensionTrait; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit\Framework\TestCase; -class QueuesCommandTest extends \PHPUnit_Framework_TestCase +class QueuesCommandTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Symfony/Client/Meta/TopicsCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/Meta/TopicsCommandTest.php index 3cf4c5efb..c39d82c0f 100644 --- a/pkg/enqueue/Tests/Symfony/Client/Meta/TopicsCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/Meta/TopicsCommandTest.php @@ -7,8 +7,9 @@ use Enqueue\Test\ClassExtensionTrait; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit\Framework\TestCase; -class TopicsCommandTest extends \PHPUnit_Framework_TestCase +class TopicsCommandTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Symfony/Client/ProduceMessageCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/ProduceMessageCommandTest.php index 501736e74..8e1105d5d 100644 --- a/pkg/enqueue/Tests/Symfony/Client/ProduceMessageCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/ProduceMessageCommandTest.php @@ -5,8 +5,9 @@ use Enqueue\Client\ProducerInterface; use Enqueue\Symfony\Client\ProduceMessageCommand; use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit\Framework\TestCase; -class ProduceMessageCommandTest extends \PHPUnit_Framework_TestCase +class ProduceMessageCommandTest extends TestCase { public function testCouldBeConstructedWithMessageProducerAsFirstArgument() { diff --git a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php index 5a7a4ab61..08b278505 100644 --- a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerCommandTest.php @@ -5,8 +5,9 @@ use Enqueue\Client\DriverInterface; use Enqueue\Symfony\Client\SetupBrokerCommand; use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit\Framework\TestCase; -class SetupBrokerCommandTest extends \PHPUnit_Framework_TestCase +class SetupBrokerCommandTest extends TestCase { public function testCouldBeConstructedWithRequiredAttributes() { diff --git a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerExtensionCommandTraitTest.php b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerExtensionCommandTraitTest.php index 3491b4101..c250244b9 100644 --- a/pkg/enqueue/Tests/Symfony/Client/SetupBrokerExtensionCommandTraitTest.php +++ b/pkg/enqueue/Tests/Symfony/Client/SetupBrokerExtensionCommandTraitTest.php @@ -5,8 +5,9 @@ use Enqueue\Client\ConsumptionExtension\SetupBrokerExtension; use Enqueue\Tests\Symfony\Client\Mock\SetupBrokerExtensionCommand; use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit\Framework\TestCase; -class SetupBrokerExtensionCommandTraitTest extends \PHPUnit_Framework_TestCase +class SetupBrokerExtensionCommandTraitTest extends TestCase { public function testShouldAddExtensionOptions() { diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeMessagesCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeMessagesCommandTest.php index 23ab12049..55cb1ff33 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/ConsumeMessagesCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/ConsumeMessagesCommandTest.php @@ -7,8 +7,9 @@ use Enqueue\Psr\PsrContext; use Enqueue\Symfony\Consumption\ConsumeMessagesCommand; use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit\Framework\TestCase; -class ConsumeMessagesCommandTest extends \PHPUnit_Framework_TestCase +class ConsumeMessagesCommandTest extends TestCase { public function testCouldBeConstructedWithRequiredAttributes() { diff --git a/pkg/enqueue/Tests/Symfony/Consumption/ContainerAwareConsumeMessagesCommandTest.php b/pkg/enqueue/Tests/Symfony/Consumption/ContainerAwareConsumeMessagesCommandTest.php index 8a7649c8f..0a4b5a5f1 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/ContainerAwareConsumeMessagesCommandTest.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/ContainerAwareConsumeMessagesCommandTest.php @@ -10,8 +10,9 @@ use Enqueue\Symfony\Consumption\ContainerAwareConsumeMessagesCommand; use Symfony\Component\Console\Tester\CommandTester; use Symfony\Component\DependencyInjection\Container; +use PHPUnit\Framework\TestCase; -class ContainerAwareConsumeMessagesCommandTest extends \PHPUnit_Framework_TestCase +class ContainerAwareConsumeMessagesCommandTest extends TestCase { public function testCouldBeConstructedWithRequiredAttributes() { diff --git a/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php b/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php index 90293d094..52f35c133 100644 --- a/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php +++ b/pkg/enqueue/Tests/Symfony/Consumption/LimitsExtensionsCommandTraitTest.php @@ -7,8 +7,9 @@ use Enqueue\Consumption\Extension\LimitConsumptionTimeExtension; use Enqueue\Tests\Symfony\Consumption\Mock\LimitsExtensionsCommand; use Symfony\Component\Console\Tester\CommandTester; +use PHPUnit\Framework\TestCase; -class LimitsExtensionsCommandTraitTest extends \PHPUnit_Framework_TestCase +class LimitsExtensionsCommandTraitTest extends TestCase { public function testShouldAddExtensionsOptions() { diff --git a/pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php b/pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php index 917ad5d2b..39cdca9c2 100644 --- a/pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php +++ b/pkg/enqueue/Tests/Symfony/DefaultTransportFactoryTest.php @@ -8,8 +8,9 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; +use PHPUnit\Framework\TestCase; -class DefaultTransportFactoryTest extends \PHPUnit_Framework_TestCase +class DefaultTransportFactoryTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Symfony/NullTransportFactoryTest.php b/pkg/enqueue/Tests/Symfony/NullTransportFactoryTest.php index 623bbec26..d63d8c4f8 100644 --- a/pkg/enqueue/Tests/Symfony/NullTransportFactoryTest.php +++ b/pkg/enqueue/Tests/Symfony/NullTransportFactoryTest.php @@ -12,8 +12,9 @@ use Symfony\Component\Config\Definition\Processor; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; +use PHPUnit\Framework\TestCase; -class NullTransportFactoryTest extends \PHPUnit_Framework_TestCase +class NullTransportFactoryTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Transport/Null/NullConnectionFactoryTest.php b/pkg/enqueue/Tests/Transport/Null/NullConnectionFactoryTest.php index 6b7235c1a..088812016 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullConnectionFactoryTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullConnectionFactoryTest.php @@ -6,8 +6,9 @@ use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullConnectionFactory; use Enqueue\Transport\Null\NullContext; +use PHPUnit\Framework\TestCase; -class NullConnectionFactoryTest extends \PHPUnit_Framework_TestCase +class NullConnectionFactoryTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Transport/Null/NullConsumerTest.php b/pkg/enqueue/Tests/Transport/Null/NullConsumerTest.php index e5c66fc34..a8774463a 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullConsumerTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullConsumerTest.php @@ -7,8 +7,9 @@ use Enqueue\Transport\Null\NullConsumer; use Enqueue\Transport\Null\NullMessage; use Enqueue\Transport\Null\NullQueue; +use PHPUnit\Framework\TestCase; -class NullConsumerTest extends \PHPUnit_Framework_TestCase +class NullConsumerTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Transport/Null/NullContextTest.php b/pkg/enqueue/Tests/Transport/Null/NullContextTest.php index 9e7531653..334f2c8c0 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullContextTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullContextTest.php @@ -10,8 +10,9 @@ use Enqueue\Transport\Null\NullProducer; use Enqueue\Transport\Null\NullQueue; use Enqueue\Transport\Null\NullTopic; +use PHPUnit\Framework\TestCase; -class NullContextTest extends \PHPUnit_Framework_TestCase +class NullContextTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Transport/Null/NullMessageTest.php b/pkg/enqueue/Tests/Transport/Null/NullMessageTest.php index f124d6dd8..5936f1137 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullMessageTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullMessageTest.php @@ -5,8 +5,9 @@ use Enqueue\Psr\PsrMessage; use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullMessage; +use PHPUnit\Framework\TestCase; -class NullMessageTest extends \PHPUnit_Framework_TestCase +class NullMessageTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Transport/Null/NullProducerTest.php b/pkg/enqueue/Tests/Transport/Null/NullProducerTest.php index 5551b5468..d528a7e73 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullProducerTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullProducerTest.php @@ -7,8 +7,9 @@ use Enqueue\Transport\Null\NullMessage; use Enqueue\Transport\Null\NullProducer; use Enqueue\Transport\Null\NullTopic; +use PHPUnit\Framework\TestCase; -class NullProducerTest extends \PHPUnit_Framework_TestCase +class NullProducerTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Transport/Null/NullQueueTest.php b/pkg/enqueue/Tests/Transport/Null/NullQueueTest.php index b4ae85c58..391788ff3 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullQueueTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullQueueTest.php @@ -5,8 +5,9 @@ use Enqueue\Psr\PsrQueue; use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullQueue; +use PHPUnit\Framework\TestCase; -class NullQueueTest extends \PHPUnit_Framework_TestCase +class NullQueueTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Transport/Null/NullTopicTest.php b/pkg/enqueue/Tests/Transport/Null/NullTopicTest.php index e8972af07..55357dd56 100644 --- a/pkg/enqueue/Tests/Transport/Null/NullTopicTest.php +++ b/pkg/enqueue/Tests/Transport/Null/NullTopicTest.php @@ -5,8 +5,9 @@ use Enqueue\Psr\PsrTopic; use Enqueue\Test\ClassExtensionTrait; use Enqueue\Transport\Null\NullTopic; +use PHPUnit\Framework\TestCase; -class NullTopicTest extends \PHPUnit_Framework_TestCase +class NullTopicTest extends TestCase { use ClassExtensionTrait; diff --git a/pkg/enqueue/Tests/Util/JSONTest.php b/pkg/enqueue/Tests/Util/JSONTest.php index 995f2ea61..c37862eb0 100644 --- a/pkg/enqueue/Tests/Util/JSONTest.php +++ b/pkg/enqueue/Tests/Util/JSONTest.php @@ -5,8 +5,9 @@ use Enqueue\Tests\Util\Fixtures\JsonSerializableClass; use Enqueue\Tests\Util\Fixtures\SimpleClass; use Enqueue\Util\JSON; +use PHPUnit\Framework\TestCase; -class JSONTest extends \PHPUnit_Framework_TestCase +class JSONTest extends TestCase { public function testShouldDecodeString() { diff --git a/pkg/enqueue/Tests/Util/UUIDTest.php b/pkg/enqueue/Tests/Util/UUIDTest.php index 97028b361..ac3090315 100644 --- a/pkg/enqueue/Tests/Util/UUIDTest.php +++ b/pkg/enqueue/Tests/Util/UUIDTest.php @@ -3,8 +3,9 @@ namespace Enqueue\Tests\Util; use Enqueue\Util\UUID; +use PHPUnit\Framework\TestCase; -class UUIDTest extends \PHPUnit_Framework_TestCase +class UUIDTest extends TestCase { public function testShouldGenerateUniqueId() { diff --git a/pkg/enqueue/Tests/Util/VarExportTest.php b/pkg/enqueue/Tests/Util/VarExportTest.php index fc1e1a805..1d2384ac9 100644 --- a/pkg/enqueue/Tests/Util/VarExportTest.php +++ b/pkg/enqueue/Tests/Util/VarExportTest.php @@ -3,8 +3,9 @@ namespace Enqueue\Tests\Util; use Enqueue\Util\VarExport; +use PHPUnit\Framework\TestCase; -class VarExportTest extends \PHPUnit_Framework_TestCase +class VarExportTest extends TestCase { public function testCouldBeConstructedWithValueAsArgument() { diff --git a/pkg/fs/Tests/Driver/FsDriverTest.php b/pkg/fs/Tests/Driver/FsDriverTest.php index cd4237a85..567a4ba27 100644 --- a/pkg/fs/Tests/Driver/FsDriverTest.php +++ b/pkg/fs/Tests/Driver/FsDriverTest.php @@ -15,7 +15,7 @@ use Enqueue\Test\ClassExtensionTrait; use Makasim\File\TempFile; -class FsDriverTest extends \PHPUnit_Framework_TestCase +class FsDriverTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/fs/Tests/FsConnectionFactoryTest.php b/pkg/fs/Tests/FsConnectionFactoryTest.php index 02910952e..f1cc047da 100644 --- a/pkg/fs/Tests/FsConnectionFactoryTest.php +++ b/pkg/fs/Tests/FsConnectionFactoryTest.php @@ -7,7 +7,7 @@ use Enqueue\Psr\PsrConnectionFactory; use Enqueue\Test\ClassExtensionTrait; -class FsConnectionFactoryTest extends \PHPUnit_Framework_TestCase +class FsConnectionFactoryTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/fs/Tests/FsConsumerTest.php b/pkg/fs/Tests/FsConsumerTest.php index b1a48d9fc..3348e0588 100644 --- a/pkg/fs/Tests/FsConsumerTest.php +++ b/pkg/fs/Tests/FsConsumerTest.php @@ -11,7 +11,7 @@ use Enqueue\Test\ClassExtensionTrait; use Makasim\File\TempFile; -class FsConsumerTest extends \PHPUnit_Framework_TestCase +class FsConsumerTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/fs/Tests/FsContextTest.php b/pkg/fs/Tests/FsContextTest.php index 467cbe631..7c22ebc93 100644 --- a/pkg/fs/Tests/FsContextTest.php +++ b/pkg/fs/Tests/FsContextTest.php @@ -13,7 +13,7 @@ use Enqueue\Transport\Null\NullQueue; use Makasim\File\TempFile; -class FsContextTest extends \PHPUnit_Framework_TestCase +class FsContextTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/fs/Tests/FsDestinationTest.php b/pkg/fs/Tests/FsDestinationTest.php index f04d1030b..75f9ba586 100644 --- a/pkg/fs/Tests/FsDestinationTest.php +++ b/pkg/fs/Tests/FsDestinationTest.php @@ -8,7 +8,7 @@ use Enqueue\Test\ClassExtensionTrait; use Makasim\File\TempFile; -class FsDestinationTest extends \PHPUnit_Framework_TestCase +class FsDestinationTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/fs/Tests/FsMessageTest.php b/pkg/fs/Tests/FsMessageTest.php index 2e1ab30ce..d4fc6b0d8 100644 --- a/pkg/fs/Tests/FsMessageTest.php +++ b/pkg/fs/Tests/FsMessageTest.php @@ -6,7 +6,7 @@ use Enqueue\Psr\PsrMessage; use Enqueue\Test\ClassExtensionTrait; -class FsMessageTest extends \PHPUnit_Framework_TestCase +class FsMessageTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/fs/Tests/FsProducerTest.php b/pkg/fs/Tests/FsProducerTest.php index be2c764cf..36fe6a6db 100644 --- a/pkg/fs/Tests/FsProducerTest.php +++ b/pkg/fs/Tests/FsProducerTest.php @@ -14,7 +14,7 @@ use Enqueue\Transport\Null\NullQueue; use Makasim\File\TempFile; -class FsProducerTest extends \PHPUnit_Framework_TestCase +class FsProducerTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php index 0636aff67..c034da5cf 100644 --- a/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsCommonUseCasesTest.php @@ -10,7 +10,7 @@ /** * @group functional */ -class FsCommonUseCasesTest extends \PHPUnit_Framework_TestCase +class FsCommonUseCasesTest extends \PHPUnit\Framework\TestCase { /** * @var FsContext diff --git a/pkg/fs/Tests/Functional/FsConsumerTest.php b/pkg/fs/Tests/Functional/FsConsumerTest.php index dbdb09f93..74fc13785 100644 --- a/pkg/fs/Tests/Functional/FsConsumerTest.php +++ b/pkg/fs/Tests/Functional/FsConsumerTest.php @@ -7,7 +7,7 @@ use Enqueue\Fs\FsMessage; use Makasim\File\TempFile; -class FsConsumerTest extends \PHPUnit_Framework_TestCase +class FsConsumerTest extends \PHPUnit\Framework\TestCase { /** * @var FsContext diff --git a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php index a55718151..15208bbb7 100644 --- a/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsConsumptionUseCasesTest.php @@ -18,7 +18,7 @@ /** * @group functional */ -class FsConsumptionUseCasesTest extends \PHPUnit_Framework_TestCase +class FsConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase { /** * @var FsContext diff --git a/pkg/fs/Tests/Functional/FsProducerTest.php b/pkg/fs/Tests/Functional/FsProducerTest.php index 519eefc87..0762065ec 100644 --- a/pkg/fs/Tests/Functional/FsProducerTest.php +++ b/pkg/fs/Tests/Functional/FsProducerTest.php @@ -6,7 +6,7 @@ use Enqueue\Fs\FsContext; use Makasim\File\TempFile; -class FsProducerTest extends \PHPUnit_Framework_TestCase +class FsProducerTest extends \PHPUnit\Framework\TestCase { /** * @var FsContext diff --git a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php index dc394a4cc..feed01f19 100644 --- a/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php +++ b/pkg/fs/Tests/Functional/FsRpcUseCasesTest.php @@ -12,7 +12,7 @@ /** * @group functional */ -class FsRpcUseCasesTest extends \PHPUnit_Framework_TestCase +class FsRpcUseCasesTest extends \PHPUnit\Framework\TestCase { /** * @var FsContext diff --git a/pkg/fs/Tests/Symfony/FsTransportFactoryTest.php b/pkg/fs/Tests/Symfony/FsTransportFactoryTest.php index 316a5326b..e543dd468 100644 --- a/pkg/fs/Tests/Symfony/FsTransportFactoryTest.php +++ b/pkg/fs/Tests/Symfony/FsTransportFactoryTest.php @@ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -class FsTransportFactoryTest extends \PHPUnit_Framework_TestCase +class FsTransportFactoryTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php b/pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php index 3c520ede2..de653b072 100644 --- a/pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php +++ b/pkg/job-queue/Tests/CalculateRootJobStatusProcessorTest.php @@ -13,7 +13,7 @@ use Enqueue\Transport\Null\NullMessage; use Psr\Log\LoggerInterface; -class CalculateRootJobStatusProcessorTest extends \PHPUnit_Framework_TestCase +class CalculateRootJobStatusProcessorTest extends \PHPUnit\Framework\TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php b/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php index fdae19fbb..47e2c6e21 100644 --- a/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php +++ b/pkg/job-queue/Tests/CalculateRootJobStatusServiceTest.php @@ -6,7 +6,7 @@ use Enqueue\JobQueue\Job; use Enqueue\JobQueue\JobStorage; -class CalculateRootJobStatusServiceTest extends \PHPUnit_Framework_TestCase +class CalculateRootJobStatusServiceTest extends \PHPUnit\Framework\TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/job-queue/Tests/DependentJobContextTest.php b/pkg/job-queue/Tests/DependentJobContextTest.php index ec95ec9e0..32340d687 100644 --- a/pkg/job-queue/Tests/DependentJobContextTest.php +++ b/pkg/job-queue/Tests/DependentJobContextTest.php @@ -5,7 +5,7 @@ use Enqueue\JobQueue\DependentJobContext; use Enqueue\JobQueue\Job; -class DependentJobContextTest extends \PHPUnit_Framework_TestCase +class DependentJobContextTest extends \PHPUnit\Framework\TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/job-queue/Tests/DependentJobProcessorTest.php b/pkg/job-queue/Tests/DependentJobProcessorTest.php index baf8a3ac6..1728fef54 100644 --- a/pkg/job-queue/Tests/DependentJobProcessorTest.php +++ b/pkg/job-queue/Tests/DependentJobProcessorTest.php @@ -13,7 +13,7 @@ use Enqueue\Transport\Null\NullMessage; use Psr\Log\LoggerInterface; -class DependentJobProcessorTest extends \PHPUnit_Framework_TestCase +class DependentJobProcessorTest extends \PHPUnit\Framework\TestCase { public function testShouldReturnSubscribedTopicNames() { diff --git a/pkg/job-queue/Tests/DependentJobServiceTest.php b/pkg/job-queue/Tests/DependentJobServiceTest.php index 581c463b6..1f6f5796d 100644 --- a/pkg/job-queue/Tests/DependentJobServiceTest.php +++ b/pkg/job-queue/Tests/DependentJobServiceTest.php @@ -7,7 +7,7 @@ use Enqueue\JobQueue\Job; use Enqueue\JobQueue\JobStorage; -class DependentJobServiceTest extends \PHPUnit_Framework_TestCase +class DependentJobServiceTest extends \PHPUnit\Framework\TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/job-queue/Tests/JobProcessorTest.php b/pkg/job-queue/Tests/JobProcessorTest.php index 2d6df9a17..e1a7fd559 100644 --- a/pkg/job-queue/Tests/JobProcessorTest.php +++ b/pkg/job-queue/Tests/JobProcessorTest.php @@ -9,7 +9,7 @@ use Enqueue\JobQueue\JobStorage; use Enqueue\JobQueue\Topics; -class JobProcessorTest extends \PHPUnit_Framework_TestCase +class JobProcessorTest extends \PHPUnit\Framework\TestCase { public function testCouldBeCreatedWithRequiredArguments() { diff --git a/pkg/job-queue/Tests/JobRunnerTest.php b/pkg/job-queue/Tests/JobRunnerTest.php index 3d1eb3064..b88502c82 100644 --- a/pkg/job-queue/Tests/JobRunnerTest.php +++ b/pkg/job-queue/Tests/JobRunnerTest.php @@ -6,7 +6,7 @@ use Enqueue\JobQueue\JobProcessor; use Enqueue\JobQueue\JobRunner; -class JobRunnerTest extends \PHPUnit_Framework_TestCase +class JobRunnerTest extends \PHPUnit\Framework\TestCase { public function testRunUniqueShouldCreateRootAndChildJobAndCallCallback() { diff --git a/pkg/job-queue/Tests/JobStorageTest.php b/pkg/job-queue/Tests/JobStorageTest.php index 0ab3bfc84..ec1fc25ef 100644 --- a/pkg/job-queue/Tests/JobStorageTest.php +++ b/pkg/job-queue/Tests/JobStorageTest.php @@ -12,7 +12,7 @@ use Enqueue\JobQueue\Job; use Enqueue\JobQueue\JobStorage; -class JobStorageTest extends \PHPUnit_Framework_TestCase +class JobStorageTest extends \PHPUnit\Framework\TestCase { public function testCouldBeConstructedWithRequiredArguments() { diff --git a/pkg/psr-queue/Tests/ExceptionTest.php b/pkg/psr-queue/Tests/ExceptionTest.php index 04d0f3a23..3a9049866 100644 --- a/pkg/psr-queue/Tests/ExceptionTest.php +++ b/pkg/psr-queue/Tests/ExceptionTest.php @@ -6,7 +6,7 @@ use Enqueue\Psr\ExceptionInterface; use Enqueue\Test\ClassExtensionTrait; -class ExceptionTest extends \PHPUnit_Framework_TestCase +class ExceptionTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/psr-queue/Tests/InvalidDestinationExceptionTest.php b/pkg/psr-queue/Tests/InvalidDestinationExceptionTest.php index a3c965fd5..5fb58242a 100644 --- a/pkg/psr-queue/Tests/InvalidDestinationExceptionTest.php +++ b/pkg/psr-queue/Tests/InvalidDestinationExceptionTest.php @@ -7,7 +7,7 @@ use Enqueue\Psr\PsrDestination; use Enqueue\Test\ClassExtensionTrait; -class InvalidDestinationExceptionTest extends \PHPUnit_Framework_TestCase +class InvalidDestinationExceptionTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/psr-queue/Tests/InvalidMessageExceptionTest.php b/pkg/psr-queue/Tests/InvalidMessageExceptionTest.php index 82f44571b..db33b3c12 100644 --- a/pkg/psr-queue/Tests/InvalidMessageExceptionTest.php +++ b/pkg/psr-queue/Tests/InvalidMessageExceptionTest.php @@ -6,7 +6,7 @@ use Enqueue\Psr\InvalidMessageException; use Enqueue\Test\ClassExtensionTrait; -class InvalidMessageExceptionTest extends \PHPUnit_Framework_TestCase +class InvalidMessageExceptionTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/BufferedStompClientTest.php b/pkg/stomp/Tests/BufferedStompClientTest.php index 11d4cc3cf..9e7bfa8df 100644 --- a/pkg/stomp/Tests/BufferedStompClientTest.php +++ b/pkg/stomp/Tests/BufferedStompClientTest.php @@ -9,7 +9,7 @@ use Stomp\Network\Connection; use Stomp\Transport\Frame; -class BufferedStompClientTest extends \PHPUnit_Framework_TestCase +class BufferedStompClientTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; use WriteAttributeTrait; diff --git a/pkg/stomp/Tests/Client/ManagementClientTest.php b/pkg/stomp/Tests/Client/ManagementClientTest.php index 598f5d051..cc11007c9 100644 --- a/pkg/stomp/Tests/Client/ManagementClientTest.php +++ b/pkg/stomp/Tests/Client/ManagementClientTest.php @@ -8,7 +8,7 @@ use RabbitMq\ManagementApi\Api\Queue; use RabbitMq\ManagementApi\Client; -class ManagementClientTest extends \PHPUnit_Framework_TestCase +class ManagementClientTest extends \PHPUnit\Framework\TestCase { public function testCouldDeclareExchange() { diff --git a/pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php b/pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php index 935be4863..8675dd890 100644 --- a/pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php +++ b/pkg/stomp/Tests/Client/RabbitMqStompDriverTest.php @@ -17,7 +17,7 @@ use Enqueue\Test\ClassExtensionTrait; use Psr\Log\LoggerInterface; -class RabbitMqStompDriverTest extends \PHPUnit_Framework_TestCase +class RabbitMqStompDriverTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/Client/StompDriverTest.php b/pkg/stomp/Tests/Client/StompDriverTest.php index 49d710c1c..45ed57895 100644 --- a/pkg/stomp/Tests/Client/StompDriverTest.php +++ b/pkg/stomp/Tests/Client/StompDriverTest.php @@ -13,7 +13,7 @@ use Enqueue\Test\ClassExtensionTrait; use Psr\Log\LoggerInterface; -class StompDriverTest extends \PHPUnit_Framework_TestCase +class StompDriverTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php index 18061d297..eae85f4a8 100644 --- a/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompCommonUseCasesTest.php @@ -10,7 +10,7 @@ /** * @group functional */ -class StompCommonUseCasesTest extends \PHPUnit_Framework_TestCase +class StompCommonUseCasesTest extends \PHPUnit\Framework\TestCase { use RabbitmqStompExtension; use RabbitmqManagmentExtensionTrait; diff --git a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php index 0feb404c9..d48dbf522 100644 --- a/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompConsumptionUseCasesTest.php @@ -18,7 +18,7 @@ /** * @group functional */ -class StompConsumptionUseCasesTest extends \PHPUnit_Framework_TestCase +class StompConsumptionUseCasesTest extends \PHPUnit\Framework\TestCase { use RabbitmqStompExtension; use RabbitmqManagmentExtensionTrait; diff --git a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php index ec1ad55a5..5a3e979c8 100644 --- a/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php +++ b/pkg/stomp/Tests/Functional/StompRpcUseCasesTest.php @@ -12,7 +12,7 @@ /** * @group functional */ -class StompRpcUseCasesTest extends \PHPUnit_Framework_TestCase +class StompRpcUseCasesTest extends \PHPUnit\Framework\TestCase { use RabbitmqStompExtension; use RabbitmqManagmentExtensionTrait; diff --git a/pkg/stomp/Tests/StompConnectionFactoryTest.php b/pkg/stomp/Tests/StompConnectionFactoryTest.php index 80421f300..522aa5efd 100644 --- a/pkg/stomp/Tests/StompConnectionFactoryTest.php +++ b/pkg/stomp/Tests/StompConnectionFactoryTest.php @@ -7,7 +7,7 @@ use Enqueue\Stomp\StompContext; use Enqueue\Test\ClassExtensionTrait; -class StompConnectionFactoryTest extends \PHPUnit_Framework_TestCase +class StompConnectionFactoryTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/StompConsumerTest.php b/pkg/stomp/Tests/StompConsumerTest.php index 2e46bab41..e75669559 100644 --- a/pkg/stomp/Tests/StompConsumerTest.php +++ b/pkg/stomp/Tests/StompConsumerTest.php @@ -13,7 +13,7 @@ use Stomp\Protocol\Protocol; use Stomp\Transport\Frame; -class StompConsumerTest extends \PHPUnit_Framework_TestCase +class StompConsumerTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/StompContextTest.php b/pkg/stomp/Tests/StompContextTest.php index d57337570..87ae54d25 100644 --- a/pkg/stomp/Tests/StompContextTest.php +++ b/pkg/stomp/Tests/StompContextTest.php @@ -13,7 +13,7 @@ use Enqueue\Stomp\StompProducer; use Enqueue\Test\ClassExtensionTrait; -class StompContextTest extends \PHPUnit_Framework_TestCase +class StompContextTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/StompDestinationTest.php b/pkg/stomp/Tests/StompDestinationTest.php index 660e68f25..cf8dfd74a 100644 --- a/pkg/stomp/Tests/StompDestinationTest.php +++ b/pkg/stomp/Tests/StompDestinationTest.php @@ -7,7 +7,7 @@ use Enqueue\Stomp\StompDestination; use Enqueue\Test\ClassExtensionTrait; -class StompDestinationTest extends \PHPUnit_Framework_TestCase +class StompDestinationTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/StompHeadersEncoderTest.php b/pkg/stomp/Tests/StompHeadersEncoderTest.php index 28d29b944..7997e05a4 100644 --- a/pkg/stomp/Tests/StompHeadersEncoderTest.php +++ b/pkg/stomp/Tests/StompHeadersEncoderTest.php @@ -4,7 +4,7 @@ use Enqueue\Stomp\StompHeadersEncoder; -class StompHeadersEncoderTest extends \PHPUnit_Framework_TestCase +class StompHeadersEncoderTest extends \PHPUnit\Framework\TestCase { public function headerValuesDataProvider() { diff --git a/pkg/stomp/Tests/StompMessageTest.php b/pkg/stomp/Tests/StompMessageTest.php index c39f4a084..e4b816a55 100644 --- a/pkg/stomp/Tests/StompMessageTest.php +++ b/pkg/stomp/Tests/StompMessageTest.php @@ -7,7 +7,7 @@ use Enqueue\Test\ClassExtensionTrait; use Stomp\Transport\Frame; -class StompMessageTest extends \PHPUnit_Framework_TestCase +class StompMessageTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/StompProducerTest.php b/pkg/stomp/Tests/StompProducerTest.php index 4019238a5..2df9037dd 100644 --- a/pkg/stomp/Tests/StompProducerTest.php +++ b/pkg/stomp/Tests/StompProducerTest.php @@ -14,7 +14,7 @@ use Stomp\Client; use Stomp\Transport\Message; -class StompProducerTest extends \PHPUnit_Framework_TestCase +class StompProducerTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/Symfony/RabbitMqStompTransportFactoryTest.php b/pkg/stomp/Tests/Symfony/RabbitMqStompTransportFactoryTest.php index 6e0007fb1..d45a291e9 100644 --- a/pkg/stomp/Tests/Symfony/RabbitMqStompTransportFactoryTest.php +++ b/pkg/stomp/Tests/Symfony/RabbitMqStompTransportFactoryTest.php @@ -13,7 +13,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -class RabbitMqStompTransportFactoryTest extends \PHPUnit_Framework_TestCase +class RabbitMqStompTransportFactoryTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; diff --git a/pkg/stomp/Tests/Symfony/StompTransportFactoryTest.php b/pkg/stomp/Tests/Symfony/StompTransportFactoryTest.php index d4a0ebc3c..fb4c1bb85 100644 --- a/pkg/stomp/Tests/Symfony/StompTransportFactoryTest.php +++ b/pkg/stomp/Tests/Symfony/StompTransportFactoryTest.php @@ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; -class StompTransportFactoryTest extends \PHPUnit_Framework_TestCase +class StompTransportFactoryTest extends \PHPUnit\Framework\TestCase { use ClassExtensionTrait; From c49c9163ce9df7b8a2a835aa2cbcc0fb78329cf5 Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 20 Apr 2017 16:51:07 +0300 Subject: [PATCH 4/6] [doc][redis] Add transport docs. --- docs/filesystem_transport.md | 5 +- docs/redis_transport.md | 125 +++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 docs/redis_transport.md diff --git a/docs/filesystem_transport.md b/docs/filesystem_transport.md index d49886078..9df4b5106 100644 --- a/docs/filesystem_transport.md +++ b/docs/filesystem_transport.md @@ -3,13 +3,10 @@ Use files on local filesystem as queues. It creates a file per queue\topic. A message is a line inside the file. -**Limitations** It works only in auto ack mode. Local by nature therefor messages are not visible on other servers. +**Limitations** It works only in auto ack mode hence If consumer crashes the message is lost. Local by nature therefor messages are not visible on other servers. * [Installation](#installation) * [Create context](#create-context) -* [Declare topic](#declare-topic) -* [Declare queue](#decalre-queue) -* [Bind queue to topic](#bind-queue-to-topic) * [Send message to topic](#send-message-to-topic) * [Send message to queue](#send-message-to-queue) * [Consume message](#consume-message) diff --git a/docs/redis_transport.md b/docs/redis_transport.md new file mode 100644 index 000000000..2e363e895 --- /dev/null +++ b/docs/redis_transport.md @@ -0,0 +1,125 @@ +# Redis transport + +The transport uses [Redis](https://redis.io/) as a message broker. +It creates a collection (a queue or topic) there. Pushes messages to the tail of the collection and pops from the head. +The transport works with [phpredis](https://github.com/phpredis/phpredis) php extension or [predis](https://github.com/nrk/predis) library. +Make sure you installed either of them + +**Limitations** It works only in auto ack mode hence If consumer crashes the message is lost. + +* [Installation](#installation) +* [Create context](#create-context) +* [Send message to topic](#send-message-to-topic) +* [Send message to queue](#send-message-to-queue) +* [Consume message](#consume-message) +* [Delete queue (purge messages)](#delete-queue-purge-messages) +* [Delete topic (purge messages)](#delete-topic-purge-messages) + +## Installation + +* With php redis extension: + +```bash +$ apt-get install php-redis +$ composer require enqueue/redis +``` + +* With predis library: + +```bash +$ composer require enqueue/redis predis/predis:^1 +``` + +## Create context + +* With php redis extension: + +```php + 'localhost', + 'port' => 6379, + 'vendor' => 'phpredis', +]); + +$psrContext = $connectionFactory->createContext(); +``` + +* With predis library: + +```php + 'localhost', + 'port' => 6379, + 'vendor' => 'predis', +]); + +$psrContext = $connectionFactory->createContext(); +``` + +## Send message to topic + +```php +createTopic('aTopic'); +$message = $psrContext->createMessage('Hello world!'); + +$psrContext->createProducer()->send($fooTopic, $message); +``` + +## Send message to queue + +```php +createQueue('aQueue'); +$message = $psrContext->createMessage('Hello world!'); + +$psrContext->createProducer()->send($fooQueue, $message); +``` + +## Consume message: + +```php +createQueue('aQueue'); +$consumer = $psrContext->createConsumer($fooQueue); + +$message = $consumer->receive(); + +// process a message +``` + +## Delete queue (purge messages): + +```php +createQueue('aQueue'); + +$psrContext->deleteQueue($fooQueue); +``` + +## Delete topic (purge messages): + +```php +createTopic('aTopic'); + +$psrContext->deleteTopic($fooTopic); +``` + +[back to index](index.md) \ No newline at end of file From 785833b637f9b9f88790afb5b52c4186c9fa1c7d Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 20 Apr 2017 16:54:27 +0300 Subject: [PATCH 5/6] [doc] add redis to doc index --- docs/index.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index a57167e5e..b16daff02 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,8 +2,9 @@ * [Quick tour](quick_tour.md) * Transports - - [Amqp](amqp_transport.md) - - [Stomp](stomp_transport.md) + - [Amqp (RabbitMQ, ActiveMQ)](amqp_transport.md) + - [Stomp (RabbitMQ, ActiveMQ)](stomp_transport.md) + - [Redis](redis_transport.md) - [Filesystem](filesystem_transport.md) - [Null](null_transport.md) * Consumption From d53e0520baba4223feeb31343b38c395ae7c1fea Mon Sep 17 00:00:00 2001 From: Maksim Kotlyar Date: Thu, 20 Apr 2017 16:56:52 +0300 Subject: [PATCH 6/6] remove cached --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 68c4b42b2..a892eafe8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,7 @@ services: - mysql - redis volumes: - - './:/mqdev:cached' + - './:/mqdev' environment: - SYMFONY__RABBITMQ__HOST=rabbitmq - SYMFONY__RABBITMQ__USER=guest