From 158d85477c951939f750ea84a54f594a1aa65861 Mon Sep 17 00:00:00 2001 From: Jeroen Thora Date: Sun, 9 Jul 2017 13:13:54 +0200 Subject: [PATCH 1/3] Upgrade phpunit dependency to supported versions --- composer.json | 2 +- tests/Command/ConsumeCommandTest.php | 2 +- tests/Command/Doctrine/AbstractCommandTest.php | 2 +- tests/Command/Doctrine/BaseCommandTest.php | 2 +- tests/Command/ProduceCommandTest.php | 2 +- tests/ConsumerTest.php | 2 +- tests/Doctrine/ConnectionListenerTest.php | 2 +- tests/Driver/AbstractDoctrineDriverTest.php | 2 +- tests/Driver/AppEngineDriverTest.php | 2 +- tests/Driver/FlatFileDriverTest.php | 2 +- tests/Driver/IronMqDriverTest.php | 2 +- tests/Driver/MongoDBDriverFunctionalTest.php | 2 +- tests/Driver/MongoDBDriverTest.php | 2 +- tests/Driver/PheanstalkDriverTest.php | 2 +- tests/Driver/PhpAmqpDriverTest.php | 2 +- tests/Driver/PhpRedisDriverTest.php | 2 +- tests/Driver/PrefetchMessageCacheTest.php | 2 +- tests/Driver/SqsDriverTest.php | 2 +- tests/EnvelopeTest.php | 2 +- tests/Event/EnvelopeEventTest.php | 2 +- tests/Event/RejectEnvelopeEventTest.php | 2 +- tests/EventListener/FailureSubscriberTest.php | 2 +- tests/Message/AbstractMessageTest.php | 2 +- tests/Message/PlainMessageTest.php | 2 +- tests/ProducerTest.php | 2 +- tests/Queue/AbstractQueueTest.php | 2 +- tests/Queue/RoundRobinQueueTest.php | 2 +- tests/QueueFactory/InMemoryFactoryTest.php | 2 +- tests/QueueFactory/PersistentFactoryTest.php | 2 +- tests/Router/ContainerAwareRouterTest.php | 2 +- tests/Router/LeagueContainerAwareRouterTest.php | 2 +- tests/Router/PimpleAwareRouterTest.php | 2 +- tests/Router/SimpleRouterTest.php | 2 +- 33 files changed, 33 insertions(+), 33 deletions(-) diff --git a/composer.json b/composer.json index 455cdef4..4b828ddd 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "pda/pheanstalk": "~3.0", "php-amqplib/php-amqplib": "~2.5", "phpspec/phpspec": "^2.4", - "phpunit/phpunit": "^4.8", + "phpunit/phpunit": "^5.5|^6.0", "iron-io/iron_mq": "~4.0", "league/container": "~2.3" }, diff --git a/tests/Command/ConsumeCommandTest.php b/tests/Command/ConsumeCommandTest.php index 7e0ec150..2d1037d1 100644 --- a/tests/Command/ConsumeCommandTest.php +++ b/tests/Command/ConsumeCommandTest.php @@ -6,7 +6,7 @@ use Bernard\QueueFactory\InMemoryFactory; use Symfony\Component\Console\Tester\CommandTester; -class ConsumeCommandTest extends \PHPUnit_Framework_TestCase +class ConsumeCommandTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Command/Doctrine/AbstractCommandTest.php b/tests/Command/Doctrine/AbstractCommandTest.php index c451dcfe..570e9733 100644 --- a/tests/Command/Doctrine/AbstractCommandTest.php +++ b/tests/Command/Doctrine/AbstractCommandTest.php @@ -5,7 +5,7 @@ use Bernard\Command\Doctrine\AbstractCommand; use Symfony\Component\Console\Tester\CommandTester; -class AbstractCommandTest extends \PHPUnit_Framework_TestCase +class AbstractCommandTest extends \PHPUnit\Framework\TestCase { protected $command; diff --git a/tests/Command/Doctrine/BaseCommandTest.php b/tests/Command/Doctrine/BaseCommandTest.php index 332ded99..f8441a1f 100644 --- a/tests/Command/Doctrine/BaseCommandTest.php +++ b/tests/Command/Doctrine/BaseCommandTest.php @@ -4,7 +4,7 @@ use Symfony\Component\Console\Tester\CommandTester; -abstract class BaseCommandTest extends \PHPUnit_Framework_TestCase +abstract class BaseCommandTest extends \PHPUnit\Framework\TestCase { protected $command; diff --git a/tests/Command/ProduceCommandTest.php b/tests/Command/ProduceCommandTest.php index 66d8920e..e33bfdcb 100644 --- a/tests/Command/ProduceCommandTest.php +++ b/tests/Command/ProduceCommandTest.php @@ -6,7 +6,7 @@ use Bernard\Command\ProduceCommand; use Symfony\Component\Console\Tester\CommandTester; -class ProduceCommandTest extends \PHPUnit_Framework_TestCase +class ProduceCommandTest extends \PHPUnit\Framework\TestCase { protected $producer; diff --git a/tests/ConsumerTest.php b/tests/ConsumerTest.php index cfcb36e8..a65af860 100644 --- a/tests/ConsumerTest.php +++ b/tests/ConsumerTest.php @@ -11,7 +11,7 @@ use Bernard\Event\EnvelopeEvent; use Bernard\Event\PingEvent; -class ConsumerTest extends \PHPUnit_Framework_TestCase +class ConsumerTest extends \PHPUnit\Framework\TestCase { /** * @var SimpleRouter diff --git a/tests/Doctrine/ConnectionListenerTest.php b/tests/Doctrine/ConnectionListenerTest.php index 72f4d2f4..2f7ed7de 100644 --- a/tests/Doctrine/ConnectionListenerTest.php +++ b/tests/Doctrine/ConnectionListenerTest.php @@ -7,7 +7,7 @@ use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\DBALException; -class ConnectionListenerTest extends \PHPUnit_Framework_TestCase +class ConnectionListenerTest extends \PHPUnit\Framework\TestCase { protected function setUp() { diff --git a/tests/Driver/AbstractDoctrineDriverTest.php b/tests/Driver/AbstractDoctrineDriverTest.php index 9746c254..1ec32747 100644 --- a/tests/Driver/AbstractDoctrineDriverTest.php +++ b/tests/Driver/AbstractDoctrineDriverTest.php @@ -7,7 +7,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\Schema; -abstract class AbstractDoctrineDriverTest extends \PHPUnit_Framework_TestCase +abstract class AbstractDoctrineDriverTest extends \PHPUnit\Framework\TestCase { /** * @var \Doctrine\DBAL\Connection diff --git a/tests/Driver/AppEngineDriverTest.php b/tests/Driver/AppEngineDriverTest.php index 866510c9..40342295 100644 --- a/tests/Driver/AppEngineDriverTest.php +++ b/tests/Driver/AppEngineDriverTest.php @@ -5,7 +5,7 @@ use Bernard\Driver\AppEngineDriver; use google\appengine\api\taskqueue\PushTask; -class AppEngineDriverTest extends \PHPUnit_Framework_TestCase +class AppEngineDriverTest extends \PHPUnit\Framework\TestCase { public static function setUpBeforeClass() { diff --git a/tests/Driver/FlatFileDriverTest.php b/tests/Driver/FlatFileDriverTest.php index 52976765..f1125334 100644 --- a/tests/Driver/FlatFileDriverTest.php +++ b/tests/Driver/FlatFileDriverTest.php @@ -7,7 +7,7 @@ /** * @author Markus Bachmann */ -class FlatFileDriverTest extends \PHPUnit_Framework_TestCase +class FlatFileDriverTest extends \PHPUnit\Framework\TestCase { /** * @var FlatFileDriver diff --git a/tests/Driver/IronMqDriverTest.php b/tests/Driver/IronMqDriverTest.php index 29225f1c..6b9a9fb5 100644 --- a/tests/Driver/IronMqDriverTest.php +++ b/tests/Driver/IronMqDriverTest.php @@ -4,7 +4,7 @@ use Bernard\Driver\IronMqDriver; -class IronMqDriverTest extends \PHPUnit_Framework_TestCase +class IronMqDriverTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Driver/MongoDBDriverFunctionalTest.php b/tests/Driver/MongoDBDriverFunctionalTest.php index 5a006b25..e1e8cd2e 100644 --- a/tests/Driver/MongoDBDriverFunctionalTest.php +++ b/tests/Driver/MongoDBDriverFunctionalTest.php @@ -11,7 +11,7 @@ * @coversDefaultClass Bernard\Driver\MongoDBDriver * @group functional */ -class MongoDBDriverFunctionalTest extends \PHPUnit_Framework_TestCase +class MongoDBDriverFunctionalTest extends \PHPUnit\Framework\TestCase { const DATABASE = 'bernardQueueTest'; const MESSAGES = 'bernardMessages'; diff --git a/tests/Driver/MongoDBDriverTest.php b/tests/Driver/MongoDBDriverTest.php index a0e3798b..3ce34143 100644 --- a/tests/Driver/MongoDBDriverTest.php +++ b/tests/Driver/MongoDBDriverTest.php @@ -7,7 +7,7 @@ use MongoDate; use MongoId; -class MongoDBDriverTest extends \PHPUnit_Framework_TestCase +class MongoDBDriverTest extends \PHPUnit\Framework\TestCase { private $messages; private $queues; diff --git a/tests/Driver/PheanstalkDriverTest.php b/tests/Driver/PheanstalkDriverTest.php index 0bdfcd0d..3545f9c0 100644 --- a/tests/Driver/PheanstalkDriverTest.php +++ b/tests/Driver/PheanstalkDriverTest.php @@ -5,7 +5,7 @@ use Bernard\Driver\PheanstalkDriver; use Pheanstalk\Job; -class PheanstalkDriverTest extends \PHPUnit_Framework_TestCase +class PheanstalkDriverTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Driver/PhpAmqpDriverTest.php b/tests/Driver/PhpAmqpDriverTest.php index a04cb51b..08fa6858 100644 --- a/tests/Driver/PhpAmqpDriverTest.php +++ b/tests/Driver/PhpAmqpDriverTest.php @@ -7,7 +7,7 @@ use PhpAmqpLib\Connection\AMQPStreamConnection; use PhpAmqpLib\Message\AMQPMessage; -class PhpAmqpDriverTest extends \PHPUnit_Framework_TestCase +class PhpAmqpDriverTest extends \PHPUnit\Framework\TestCase { /** * @var AMQPStreamConnection diff --git a/tests/Driver/PhpRedisDriverTest.php b/tests/Driver/PhpRedisDriverTest.php index 61b21774..a3cf6849 100644 --- a/tests/Driver/PhpRedisDriverTest.php +++ b/tests/Driver/PhpRedisDriverTest.php @@ -4,7 +4,7 @@ use Bernard\Driver\PhpRedisDriver; -class PhpRedisDriverTest extends \PHPUnit_Framework_TestCase +class PhpRedisDriverTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Driver/PrefetchMessageCacheTest.php b/tests/Driver/PrefetchMessageCacheTest.php index 2b7b6144..eb329ad0 100644 --- a/tests/Driver/PrefetchMessageCacheTest.php +++ b/tests/Driver/PrefetchMessageCacheTest.php @@ -4,7 +4,7 @@ use Bernard\Driver\PrefetchMessageCache; -class PrefetchMessageCacheTest extends \PHPUnit_Framework_TestCase +class PrefetchMessageCacheTest extends \PHPUnit\Framework\TestCase { public function testPushesAndPop() { diff --git a/tests/Driver/SqsDriverTest.php b/tests/Driver/SqsDriverTest.php index 61e5ab4f..6d9e568a 100644 --- a/tests/Driver/SqsDriverTest.php +++ b/tests/Driver/SqsDriverTest.php @@ -7,7 +7,7 @@ use Bernard\Driver\SqsDriver; use Guzzle\Service\Resource\Model; -class SqsDriverTest extends \PHPUnit_Framework_TestCase +class SqsDriverTest extends \PHPUnit\Framework\TestCase { const DUMMY_QUEUE_NAME = 'my-queue'; const DUMMY_QUEUE_URL_PREFIX = 'https://sqs.eu-west-1.amazonaws.com/123123'; diff --git a/tests/EnvelopeTest.php b/tests/EnvelopeTest.php index dfd259e3..cee73572 100644 --- a/tests/EnvelopeTest.php +++ b/tests/EnvelopeTest.php @@ -5,7 +5,7 @@ use Bernard\Message\PlainMessage; use Bernard\Envelope; -class EnvelopeTest extends \PHPUnit_Framework_TestCase +class EnvelopeTest extends \PHPUnit\Framework\TestCase { public function testItWrapsAMessageWithMetadata() { diff --git a/tests/Event/EnvelopeEventTest.php b/tests/Event/EnvelopeEventTest.php index 5af8eb1b..14fcd768 100644 --- a/tests/Event/EnvelopeEventTest.php +++ b/tests/Event/EnvelopeEventTest.php @@ -4,7 +4,7 @@ use Bernard\Event\EnvelopeEvent; -class EnvelopeEventTest extends \PHPUnit_Framework_TestCase +class EnvelopeEventTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Event/RejectEnvelopeEventTest.php b/tests/Event/RejectEnvelopeEventTest.php index 7dbf8f6b..8d273efb 100644 --- a/tests/Event/RejectEnvelopeEventTest.php +++ b/tests/Event/RejectEnvelopeEventTest.php @@ -4,7 +4,7 @@ use Bernard\Event\RejectEnvelopeEvent; -class RejectEnvelopeEventTest extends \PHPUnit_Framework_TestCase +class RejectEnvelopeEventTest extends \PHPUnit\Framework\TestCase { /** * @var \Bernard\Envelope|\PHPUnit_Framework_MockObject_MockObject diff --git a/tests/EventListener/FailureSubscriberTest.php b/tests/EventListener/FailureSubscriberTest.php index f62ef30d..b69a2814 100644 --- a/tests/EventListener/FailureSubscriberTest.php +++ b/tests/EventListener/FailureSubscriberTest.php @@ -8,7 +8,7 @@ use Bernard\Message\DefaultMessage; use Bernard\Queue\InMemoryQueue; -class FailureSubscriberTest extends \PHPUnit_Framework_TestCase +class FailureSubscriberTest extends \PHPUnit\Framework\TestCase { private $producer; private $subscriber; diff --git a/tests/Message/AbstractMessageTest.php b/tests/Message/AbstractMessageTest.php index d0c8bef2..164366e7 100644 --- a/tests/Message/AbstractMessageTest.php +++ b/tests/Message/AbstractMessageTest.php @@ -4,7 +4,7 @@ use Bernard\Tests\Fixtures; -class AbstractMessageTest extends \PHPUnit_Framework_TestCase +class AbstractMessageTest extends \PHPUnit\Framework\TestCase { public function testImplementsMessage() { diff --git a/tests/Message/PlainMessageTest.php b/tests/Message/PlainMessageTest.php index 38ec5f92..3f462bc2 100644 --- a/tests/Message/PlainMessageTest.php +++ b/tests/Message/PlainMessageTest.php @@ -4,7 +4,7 @@ use Bernard\Message\PlainMessage; -class PlainMessageTest extends \PHPUnit_Framework_TestCase +class PlainMessageTest extends \PHPUnit\Framework\TestCase { public function testItHaveAName() { diff --git a/tests/ProducerTest.php b/tests/ProducerTest.php index 041d2000..157bc29b 100644 --- a/tests/ProducerTest.php +++ b/tests/ProducerTest.php @@ -7,7 +7,7 @@ use Bernard\QueueFactory\InMemoryFactory; use Symfony\Component\EventDispatcher\EventDispatcher; -class ProducerTest extends \PHPUnit_Framework_TestCase +class ProducerTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Queue/AbstractQueueTest.php b/tests/Queue/AbstractQueueTest.php index e98b5e2f..76d8cf6b 100644 --- a/tests/Queue/AbstractQueueTest.php +++ b/tests/Queue/AbstractQueueTest.php @@ -4,7 +4,7 @@ use Bernard\Envelope; -abstract class AbstractQueueTest extends \PHPUnit_Framework_TestCase +abstract class AbstractQueueTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider dataClosedMethods diff --git a/tests/Queue/RoundRobinQueueTest.php b/tests/Queue/RoundRobinQueueTest.php index 21e38112..d310add9 100644 --- a/tests/Queue/RoundRobinQueueTest.php +++ b/tests/Queue/RoundRobinQueueTest.php @@ -7,7 +7,7 @@ use Bernard\Queue\InMemoryQueue; use Bernard\Queue\RoundRobinQueue; -class RoundRobinQueueTest extends \PHPUnit_Framework_TestCase +class RoundRobinQueueTest extends \PHPUnit\Framework\TestCase { /** * @var InMemoryQueue[] diff --git a/tests/QueueFactory/InMemoryFactoryTest.php b/tests/QueueFactory/InMemoryFactoryTest.php index 971b9018..3e82e4fe 100644 --- a/tests/QueueFactory/InMemoryFactoryTest.php +++ b/tests/QueueFactory/InMemoryFactoryTest.php @@ -4,7 +4,7 @@ use Bernard\QueueFactory\InMemoryFactory; -class InMemoryFactoryTest extends \PHPUnit_Framework_TestCase +class InMemoryFactoryTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/QueueFactory/PersistentFactoryTest.php b/tests/QueueFactory/PersistentFactoryTest.php index d8c9ea0b..d7a345e6 100644 --- a/tests/QueueFactory/PersistentFactoryTest.php +++ b/tests/QueueFactory/PersistentFactoryTest.php @@ -4,7 +4,7 @@ use Bernard\QueueFactory\PersistentFactory; -class PersistentFactoryTest extends \PHPUnit_Framework_TestCase +class PersistentFactoryTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Router/ContainerAwareRouterTest.php b/tests/Router/ContainerAwareRouterTest.php index 6eb69a59..4c78a4c4 100644 --- a/tests/Router/ContainerAwareRouterTest.php +++ b/tests/Router/ContainerAwareRouterTest.php @@ -7,7 +7,7 @@ use Bernard\Router\ContainerAwareRouter; use Symfony\Component\DependencyInjection\Container; -class ContainerAwareRouterTest extends \PHPUnit_Framework_TestCase +class ContainerAwareRouterTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Router/LeagueContainerAwareRouterTest.php b/tests/Router/LeagueContainerAwareRouterTest.php index 05fd526c..5ce509a4 100644 --- a/tests/Router/LeagueContainerAwareRouterTest.php +++ b/tests/Router/LeagueContainerAwareRouterTest.php @@ -7,7 +7,7 @@ use Bernard\Router\LeagueContainerAwareRouter; use League\Container\Container; -class LeagueContainerAwareRouterTest extends \PHPUnit_Framework_TestCase +class LeagueContainerAwareRouterTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Router/PimpleAwareRouterTest.php b/tests/Router/PimpleAwareRouterTest.php index 9ff2fc75..2756fa7b 100644 --- a/tests/Router/PimpleAwareRouterTest.php +++ b/tests/Router/PimpleAwareRouterTest.php @@ -7,7 +7,7 @@ use Bernard\Router\PimpleAwareRouter; use Pimple; -class PimpleAwareRouterTest extends \PHPUnit_Framework_TestCase +class PimpleAwareRouterTest extends \PHPUnit\Framework\TestCase { public function setUp() { diff --git a/tests/Router/SimpleRouterTest.php b/tests/Router/SimpleRouterTest.php index 4942eeaa..853a3c4d 100644 --- a/tests/Router/SimpleRouterTest.php +++ b/tests/Router/SimpleRouterTest.php @@ -6,7 +6,7 @@ use Bernard\Envelope; use Bernard\Message\PlainMessage; -class SimpleRouterTest extends \PHPUnit_Framework_TestCase +class SimpleRouterTest extends \PHPUnit\Framework\TestCase { public function setUp() { From aad897451cc62a854dccbd53268aa94219688bf1 Mon Sep 17 00:00:00 2001 From: Jeroen Thora Date: Sun, 9 Jul 2017 13:24:41 +0200 Subject: [PATCH 2/3] Travis build config tweaks (make tests more reliable) --- .travis.yml | 9 ++++++--- tests/EventListener/ErrorLogSubscriberTest.php | 3 +-- tests/Exception/ExceptionTest.php | 4 +--- tests/Normalizer/PlainMessageNormalizerTest.php | 3 +-- tests/travis.sh | 9 ++++++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 786382ac..153ea7ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,12 +16,15 @@ cache: directories: - $HOME/.composer/cache/files -services: mongodb +services: + - mongodb + - mysql + - postgresql before_script: - tests/travis.sh script: - - php vendor/bin/phpunit - - php vendor/bin/phpunit --group functional + - php vendor/bin/phpunit -v + - php vendor/bin/phpunit --group functional -v - php vendor/bin/phpspec run diff --git a/tests/EventListener/ErrorLogSubscriberTest.php b/tests/EventListener/ErrorLogSubscriberTest.php index 4f2fc02e..608d6b57 100644 --- a/tests/EventListener/ErrorLogSubscriberTest.php +++ b/tests/EventListener/ErrorLogSubscriberTest.php @@ -4,9 +4,8 @@ use Bernard\Event\RejectEnvelopeEvent; use Bernard\EventListener\ErrorLogSubscriber; -use PHPUnit_Framework_TestCase as TestCase; -class ErrorLogSubscriberTest extends TestCase +class ErrorLogSubscriberTest extends \PHPUnit\Framework\TestCase { private $envelope; private $queue; diff --git a/tests/Exception/ExceptionTest.php b/tests/Exception/ExceptionTest.php index 656d7feb..3b136ae0 100644 --- a/tests/Exception/ExceptionTest.php +++ b/tests/Exception/ExceptionTest.php @@ -2,9 +2,7 @@ namespace Bernard\Tests\Exception; -use PHPUnit_Framework_TestCase as TestCase; - -class ExceptionTest extends TestCase +class ExceptionTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider exceptionProvider diff --git a/tests/Normalizer/PlainMessageNormalizerTest.php b/tests/Normalizer/PlainMessageNormalizerTest.php index 898fcfb5..30993af0 100644 --- a/tests/Normalizer/PlainMessageNormalizerTest.php +++ b/tests/Normalizer/PlainMessageNormalizerTest.php @@ -4,9 +4,8 @@ use Bernard\Message\PlainMessage; use Bernard\Normalizer\PlainMessageNormalizer; -use PHPUnit_Framework_TestCase; -class PlainMessageNormalizerTest extends PHPUnit_Framework_TestCase +class PlainMessageNormalizerTest extends \PHPUnit\Framework\TestCase { public function testDenormalize() { diff --git a/tests/travis.sh b/tests/travis.sh index 1dd551a4..81fcb231 100755 --- a/tests/travis.sh +++ b/tests/travis.sh @@ -1,9 +1,11 @@ #!/bin/bash if [ $TRAVIS_PHP_VERSION != "hhvm" ] && [ $TRAVIS_PHP_VERSION != "7.0" ]; then - pyrus install pecl/redis; - pyrus build pecl/redis; - echo "extension=redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; + echo "extension=mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; +fi + +if [ $TRAVIS_PHP_VERSION != "hhvm" ] && [ $TRAVIS_PHP_VERSION != "5.6" ]; then + echo "extension=mongodb.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi if [ $TRAVIS_PHP_VERSION = "hhvm" ]; then @@ -12,6 +14,7 @@ if [ $TRAVIS_PHP_VERSION = "hhvm" ]; then else phpenv config-rm xdebug.ini; composer update --no-progress --no-plugins $COMPOSER_OPTS; + echo "extension=redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi mysql -e "CREATE DATABASE bernard_test;" From 3c889ca712db36ab7d6f2a70d1a7e3b1cfb59911 Mon Sep 17 00:00:00 2001 From: Jeroen Thora Date: Sun, 9 Jul 2017 15:11:53 +0200 Subject: [PATCH 3/3] Replace deprecated functions --- tests/Command/ProduceCommandTest.php | 5 ++-- tests/ConsumerTest.php | 11 ++++---- tests/Driver/PhpAmqpDriverTest.php | 28 ++++++++----------- tests/Driver/PhpRedisDriverTest.php | 4 +-- tests/Driver/PredisDriverTest.php | 4 +-- tests/Driver/SqsDriverTest.php | 6 ++-- tests/Event/EnvelopeEventTest.php | 2 +- tests/Event/RejectEnvelopeEventTest.php | 2 +- .../EventListener/ErrorLogSubscriberTest.php | 2 +- tests/Queue/AbstractQueueTest.php | 8 +++--- tests/Queue/InMemoryQueueTest.php | 4 +-- tests/Queue/PersistentQueueTest.php | 12 ++++---- tests/Queue/RoundRobinQueueTest.php | 18 ++++++------ tests/QueueFactory/InMemoryFactoryTest.php | 5 ++-- tests/QueueFactory/PersistentFactoryTest.php | 7 +++-- tests/Router/ContainerAwareRouterTest.php | 5 ++-- .../Router/LeagueContainerAwareRouterTest.php | 5 ++-- tests/Router/PimpleAwareRouterTest.php | 5 ++-- tests/Router/SimpleRouterTest.php | 10 ++++--- 19 files changed, 73 insertions(+), 70 deletions(-) diff --git a/tests/Command/ProduceCommandTest.php b/tests/Command/ProduceCommandTest.php index e33bfdcb..4f45c1c7 100644 --- a/tests/Command/ProduceCommandTest.php +++ b/tests/Command/ProduceCommandTest.php @@ -29,10 +29,11 @@ public function testProduceMessageWithNoArguments() )); } + /** + * @expectedException \RuntimeException + */ public function testInvalidJsonThrowsException() { - $this->setExpectedException('RuntimeException'); - $command = new ProduceCommand($this->producer); $tester = new CommandTester($command); diff --git a/tests/ConsumerTest.php b/tests/ConsumerTest.php index a65af860..d0e06268 100644 --- a/tests/ConsumerTest.php +++ b/tests/ConsumerTest.php @@ -33,16 +33,16 @@ public function setUp() $this->router = new SimpleRouter; $this->router->add('ImportUsers', new Fixtures\Service); - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); + $this->dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); $this->consumer = new Consumer($this->router, $this->dispatcher); } public function testEmitsConsumeEvent() { $envelope = new Envelope(new PlainMessage('ImportUsers')); - $queue = $this->getMock('Bernard\Queue\InMemoryQueue', [ + $queue = $this->getMockBuilder('Bernard\Queue\InMemoryQueue')->setMethods([ 'dequeue' - ], ['queue']); + ])->setConstructorArgs(['queue'])->getMock(); $queue->expects($this->once()) ->method('dequeue') @@ -128,7 +128,7 @@ public function testEnvelopeIsAcknowledged() $this->router->add('ImportUsers', $service); - $queue = $this->getMock('Bernard\Queue'); + $queue = $this->createMock('Bernard\Queue'); $queue->expects($this->once())->method('dequeue')->will($this->returnValue($envelope)); $queue->expects($this->once())->method('acknowledge')->with($this->equalTo($envelope)); @@ -198,6 +198,7 @@ public function testEnvelopeWillBeInvoked() /** * @requires PHP 7.0 + * @expectedException \TypeError */ public function testWillRejectDispatchOnThrowableError() { @@ -222,8 +223,6 @@ public function testWillRejectDispatchOnThrowableError() }) ); - $this->setExpectedException('TypeError'); - $this->consumer->tick($queue, ['stop-on-error' => true]); } } diff --git a/tests/Driver/PhpAmqpDriverTest.php b/tests/Driver/PhpAmqpDriverTest.php index 08fa6858..ee899067 100644 --- a/tests/Driver/PhpAmqpDriverTest.php +++ b/tests/Driver/PhpAmqpDriverTest.php @@ -28,28 +28,24 @@ class PhpAmqpDriverTest extends \PHPUnit\Framework\TestCase protected function setUp() { - $this->phpAmqpChannel = $this->getMock( - '\PhpAmqpLib\Channel\AMQPChannel', - array( + $this->phpAmqpChannel = $this->getMockBuilder('\PhpAmqpLib\Channel\AMQPChannel') + ->setMethods(array( 'basic_publish', 'basic_get', 'basic_ack', 'exchange_declare', 'queue_declare', 'queue_bind' - ), - array(), - '', - false - ); - - $this->phpAmqpConnection = $this->getMock( - '\PhpAmqpLib\Connection\AMQPStreamConnection', - array('channel'), - array(), - '', - false - ); + )) + ->disableOriginalConstructor() + ->getMock(); + + $this->phpAmqpConnection = $this->getMockBuilder('\PhpAmqpLib\Connection\AMQPStreamConnection') + ->setMethods(array( + 'channel', + )) + ->disableOriginalConstructor() + ->getMock(); $this->phpAmqpConnection ->expects($this->any()) diff --git a/tests/Driver/PhpRedisDriverTest.php b/tests/Driver/PhpRedisDriverTest.php index a3cf6849..d0c7efc4 100644 --- a/tests/Driver/PhpRedisDriverTest.php +++ b/tests/Driver/PhpRedisDriverTest.php @@ -12,7 +12,7 @@ public function setUp() $this->markTestSkipped('"redis" extension is not loaded.'); } - $this->redis = $this->getMock('Redis', array( + $this->redis = $this->getMockBuilder('Redis')->setMethods(array( 'lLen', 'sMembers', 'lRange', @@ -23,7 +23,7 @@ public function setUp() 'sContains', 'rPush', 'sRem', - )); + ))->getMock(); $this->connection = new PhpRedisDriver($this->redis); } diff --git a/tests/Driver/PredisDriverTest.php b/tests/Driver/PredisDriverTest.php index 1c9541dc..b8330edf 100644 --- a/tests/Driver/PredisDriverTest.php +++ b/tests/Driver/PredisDriverTest.php @@ -10,7 +10,7 @@ public function setUp() { // Because predis uses __call all methods that needs mocking must be // explicitly defined. - $this->redis = $this->getMock('Predis\Client', array( + $this->redis = $this->getMockBuilder('Predis\Client')->setMethods(array( 'lLen', 'sMembers', 'lRange', @@ -21,7 +21,7 @@ public function setUp() 'sContains', 'rPush', 'sRem', - )); + ))->getMock(); $this->connection = new PredisDriver($this->redis); } diff --git a/tests/Driver/SqsDriverTest.php b/tests/Driver/SqsDriverTest.php index 6d9e568a..f8036eb8 100644 --- a/tests/Driver/SqsDriverTest.php +++ b/tests/Driver/SqsDriverTest.php @@ -92,10 +92,12 @@ public function testItCountsNumberOfMessagesInQueue() $this->assertEquals(4, $this->driver->countMessages(self::DUMMY_QUEUE_NAME)); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage Queue "unknown" cannot be resolved to an url. + */ public function testUnresolveableQueueNameThrowsException() { - $this->setExpectedException('InvalidArgumentException', 'Queue "unknown" cannot be resolved to an url.'); - $this->driver->popMessage('unknown'); } diff --git a/tests/Event/EnvelopeEventTest.php b/tests/Event/EnvelopeEventTest.php index 14fcd768..898a69c6 100644 --- a/tests/Event/EnvelopeEventTest.php +++ b/tests/Event/EnvelopeEventTest.php @@ -10,7 +10,7 @@ public function setUp() { $this->envelope = $this->getMockBuilder('Bernard\Envelope')->disableOriginalConstructor() ->getMock(); - $this->queue = $this->getMock('Bernard\Queue'); + $this->queue = $this->createMock('Bernard\Queue'); } public function testIsEvent() diff --git a/tests/Event/RejectEnvelopeEventTest.php b/tests/Event/RejectEnvelopeEventTest.php index 8d273efb..52241b08 100644 --- a/tests/Event/RejectEnvelopeEventTest.php +++ b/tests/Event/RejectEnvelopeEventTest.php @@ -20,7 +20,7 @@ public function setUp() { $this->envelope = $this->getMockBuilder('Bernard\Envelope') ->disableOriginalConstructor()->getMock(); - $this->queue = $this->getMock('Bernard\Queue'); + $this->queue = $this->createMock('Bernard\Queue'); } public function testExtendsEnvelopeEvent() diff --git a/tests/EventListener/ErrorLogSubscriberTest.php b/tests/EventListener/ErrorLogSubscriberTest.php index 608d6b57..2c9a7df4 100644 --- a/tests/EventListener/ErrorLogSubscriberTest.php +++ b/tests/EventListener/ErrorLogSubscriberTest.php @@ -22,7 +22,7 @@ public function setUp() $this->envelope = $this->getMockBuilder('Bernard\Envelope') ->disableOriginalConstructor()->getMock(); - $this->queue = $this->getMock('Bernard\Queue'); + $this->queue = $this->createMock('Bernard\Queue'); $this->producer = $this->getMockBuilder('Bernard\Producer')->disableOriginalConstructor()->getMock(); $this->subscriber = new ErrorLogSubscriber($this->producer, 'failures'); $this->iniErrorLog = ini_get('error_log'); diff --git a/tests/Queue/AbstractQueueTest.php b/tests/Queue/AbstractQueueTest.php index 76d8cf6b..b9f0afaa 100644 --- a/tests/Queue/AbstractQueueTest.php +++ b/tests/Queue/AbstractQueueTest.php @@ -8,11 +8,11 @@ abstract class AbstractQueueTest extends \PHPUnit\Framework\TestCase { /** * @dataProvider dataClosedMethods + * @expectedException \Bernard\Exception\InvalidOperationexception + * @expectedExceptionMessage Queue "send-newsletter" is closed. */ public function testNotAllowedWhenClosed($method, array $arguments = array()) { - $this->setExpectedException('Bernard\Exception\InvalidOperationexception', 'Queue "send-newsletter" is closed.'); - $queue = $this->createQueue('send-newsletter'); $queue->close(); @@ -34,10 +34,10 @@ public function dataClosedMethods() array('count'), array('dequeue'), array('enqueue', array( - new Envelope($this->getMock('Bernard\Message')) + new Envelope($this->createMock('Bernard\Message')) )), array('acknowledge', array( - new Envelope($this->getMock('Bernard\Message')) + new Envelope($this->createMock('Bernard\Message')) )), ); } diff --git a/tests/Queue/InMemoryQueueTest.php b/tests/Queue/InMemoryQueueTest.php index 9f114a96..fe8eda59 100644 --- a/tests/Queue/InMemoryQueueTest.php +++ b/tests/Queue/InMemoryQueueTest.php @@ -9,7 +9,7 @@ class InMemoryQueueTest extends AbstractQueueTest { public function testDequeue() { - $envelope = new Envelope($this->getMock('Bernard\Message')); + $envelope = new Envelope($this->createMock('Bernard\Message')); $queue = $this->createQueue('send-newsletter'); $queue->enqueue($envelope); @@ -41,7 +41,7 @@ public function testPeek() protected function getEnvelope() { - return new Envelope($this->getMock('Bernard\Message')); + return new Envelope($this->createMock('Bernard\Message')); } protected function createQueue($name) diff --git a/tests/Queue/PersistentQueueTest.php b/tests/Queue/PersistentQueueTest.php index 6534a8b8..877f2455 100644 --- a/tests/Queue/PersistentQueueTest.php +++ b/tests/Queue/PersistentQueueTest.php @@ -9,13 +9,13 @@ class PersistentQueueTest extends AbstractQueueTest { public function setUp() { - $this->driver = $this->getMock('Bernard\Driver'); - $this->serializer = $this->getMock('Bernard\Serializer'); + $this->driver = $this->createMock('Bernard\Driver'); + $this->serializer = $this->createMock('Bernard\Serializer'); } public function testEnqueue() { - $envelope = new Envelope($this->getMock('Bernard\Message')); + $envelope = new Envelope($this->createMock('Bernard\Message')); $this->serializer->expects($this->once())->method('serialize')->with($this->equalTo($envelope)) ->will($this->returnValue('serialized message')); @@ -28,7 +28,7 @@ public function testEnqueue() public function testAcknowledge() { - $envelope = new Envelope($this->getMock('Bernard\Message')); + $envelope = new Envelope($this->createMock('Bernard\Message')); $this->driver->expects($this->once())->method('acknowledgeMessage') ->with($this->equalTo('send-newsletter'), $this->equalTo('receipt')); @@ -46,7 +46,7 @@ public function testAcknowledge() public function testAcknowledgeOnlyIfReceipt() { - $envelope = new Envelope($this->getMock('Bernard\Message')); + $envelope = new Envelope($this->createMock('Bernard\Message')); $this->driver->expects($this->never())->method('acknowledgeMessage'); @@ -66,7 +66,7 @@ public function testCount() public function testDequeue() { - $messageWrapper = new Envelope($this->getMock('Bernard\Message')); + $messageWrapper = new Envelope($this->createMock('Bernard\Message')); $this->driver->expects($this->at(1))->method('popMessage')->with($this->equalTo('send-newsletter')) ->will($this->returnValue(array('serialized', null))); diff --git a/tests/Queue/RoundRobinQueueTest.php b/tests/Queue/RoundRobinQueueTest.php index d310add9..c2bb6eff 100644 --- a/tests/Queue/RoundRobinQueueTest.php +++ b/tests/Queue/RoundRobinQueueTest.php @@ -30,13 +30,12 @@ public function setUp() $this->round = new RoundRobinQueue($this->queues); } + /** + * @expectedException \DomainException + * @expectedExceptionMessage Unrecognized queue specified: foo + */ public function testEnqueueWithUnrecognizedQueue() { - $this->setExpectedException( - 'DomainException', - 'Unrecognized queue specified: foo' - ); - $this->round->enqueue($this->getEnvelope('foo')); } @@ -94,13 +93,12 @@ public function testPeek() $this->assertSame([$envelope_3_1], $this->round->peek(1, 1)); } + /** + * @expectedException \DomainException + * @expectedExceptionMessage Unrecognized queue specified: foo + */ public function testAcknowledgeWithUnrecognizedQueue() { - $this->setExpectedException( - 'DomainException', - 'Unrecognized queue specified: foo' - ); - $envelope = $this->getEnvelope('foo'); $this->round->enqueue($envelope); $dequeued = $this->round->dequeue($envelope); diff --git a/tests/QueueFactory/InMemoryFactoryTest.php b/tests/QueueFactory/InMemoryFactoryTest.php index 3e82e4fe..cc0762d3 100644 --- a/tests/QueueFactory/InMemoryFactoryTest.php +++ b/tests/QueueFactory/InMemoryFactoryTest.php @@ -16,10 +16,11 @@ public function testImplementsQueueFactory() $this->assertInstanceOf('Bernard\QueueFactory', $this->factory); } + /** + * @expectedException \Bernard\Exception\InvalidOperationException + */ public function testRemoveClosesQueue() { - $this->setExpectedException('Bernard\Exception\InvalidOperationException'); - $queue = $this->factory->create('queue'); $this->assertTrue($this->factory->exists('queue')); diff --git a/tests/QueueFactory/PersistentFactoryTest.php b/tests/QueueFactory/PersistentFactoryTest.php index d7a345e6..4b3fb9fc 100644 --- a/tests/QueueFactory/PersistentFactoryTest.php +++ b/tests/QueueFactory/PersistentFactoryTest.php @@ -11,7 +11,7 @@ public function setUp() $this->connection = $this->getMockBuilder('Bernard\Driver') ->disableOriginalConstructor()->getMock(); - $this->factory = new PersistentFactory($this->connection, $this->getMock('Bernard\Serializer')); + $this->factory = new PersistentFactory($this->connection, $this->createMock('Bernard\Serializer')); } public function testImplementsQueueFactory() @@ -29,10 +29,11 @@ public function testItSavesQueueObjects() $this->assertSame($queue, $this->factory->create('send-newsletter')); } + /** + * @expectedException \Bernard\Exception\InvalidOperationException + */ public function testRemoveClosesQueue() { - $this->setExpectedException('Bernard\Exception\InvalidOperationException'); - $queue = $this->factory->create('send-newsletter'); $this->assertTrue($this->factory->exists('send-newsletter')); diff --git a/tests/Router/ContainerAwareRouterTest.php b/tests/Router/ContainerAwareRouterTest.php index 4c78a4c4..3a6243fb 100644 --- a/tests/Router/ContainerAwareRouterTest.php +++ b/tests/Router/ContainerAwareRouterTest.php @@ -17,10 +17,11 @@ public function setUp() }); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException + */ public function testUndefinedServicesAreNotAccepted() { - $this->setExpectedException('Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException'); - $envelope = new Envelope(new PlainMessage('SendNewsletter')); $router = new ContainerAwareRouter($this->container); diff --git a/tests/Router/LeagueContainerAwareRouterTest.php b/tests/Router/LeagueContainerAwareRouterTest.php index 5ce509a4..30ad101d 100644 --- a/tests/Router/LeagueContainerAwareRouterTest.php +++ b/tests/Router/LeagueContainerAwareRouterTest.php @@ -17,10 +17,11 @@ public function setUp() }); } + /** + * @expectedException \League\Container\Exception\NotFoundException + */ public function testUndefinedServicesAreNotAccepted() { - $this->setExpectedException('League\Container\Exception\NotFoundException'); - $envelope = new Envelope(new PlainMessage('SendNewsletter')); $router = new LeagueContainerAwareRouter($this->container); diff --git a/tests/Router/PimpleAwareRouterTest.php b/tests/Router/PimpleAwareRouterTest.php index 2756fa7b..889d24ea 100644 --- a/tests/Router/PimpleAwareRouterTest.php +++ b/tests/Router/PimpleAwareRouterTest.php @@ -19,10 +19,11 @@ public function setUp() $this->router = new PimpleAwareRouter($this->pimple); } + /** + * @expectedException \InvalidArgumentException + */ public function testUndefinedServicesAreNotAccepted() { - $this->setExpectedException('InvalidArgumentException'); - $envelope = new Envelope(new PlainMessage('SendNewsletter')); $this->router->map($envelope); diff --git a/tests/Router/SimpleRouterTest.php b/tests/Router/SimpleRouterTest.php index 853a3c4d..04e677d9 100644 --- a/tests/Router/SimpleRouterTest.php +++ b/tests/Router/SimpleRouterTest.php @@ -13,17 +13,19 @@ public function setUp() $this->router = new SimpleRouter(); } + /** + * @expectedException \InvalidArgumentException + */ public function testThrowsExceptionWhenReceiverIsNotSupported() { - $this->setExpectedException('InvalidArgumentException'); - $this->router->add('SendNewsletter', 1); } + /** + * @expectedException \Bernard\Exception\ReceiverNotFoundException + */ public function testThrowsExceptionWhenNothingMatches() { - $this->setExpectedException('Bernard\Exception\ReceiverNotFoundException'); - $envelope = new Envelope(new PlainMessage('SendNewsletter')); $this->router->map($envelope);