Skip to content

Commit

Permalink
Merge pull request #315 from acrobat/phpunit-upgrade
Browse files Browse the repository at this point in the history
Upgrade phpunit dependency to supported versions
  • Loading branch information
acrobat authored Jul 18, 2017
2 parents b3931e9 + 3c889ca commit 5681d3e
Show file tree
Hide file tree
Showing 41 changed files with 121 additions and 116 deletions.
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/ConsumeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Command/Doctrine/AbstractCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/Command/Doctrine/BaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 4 additions & 3 deletions tests/Command/ProduceCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -29,10 +29,11 @@ public function testProduceMessageWithNoArguments()
));
}

/**
* @expectedException \RuntimeException
*/
public function testInvalidJsonThrowsException()
{
$this->setExpectedException('RuntimeException');

$command = new ProduceCommand($this->producer);

$tester = new CommandTester($command);
Expand Down
13 changes: 6 additions & 7 deletions tests/ConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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')
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -198,6 +198,7 @@ public function testEnvelopeWillBeInvoked()

/**
* @requires PHP 7.0
* @expectedException \TypeError
*/
public function testWillRejectDispatchOnThrowableError()
{
Expand All @@ -222,8 +223,6 @@ public function testWillRejectDispatchOnThrowableError()
})
);

$this->setExpectedException('TypeError');

$this->consumer->tick($queue, ['stop-on-error' => true]);
}
}
2 changes: 1 addition & 1 deletion tests/Doctrine/ConnectionListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/AbstractDoctrineDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/AppEngineDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/FlatFileDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* @author Markus Bachmann <[email protected]>
*/
class FlatFileDriverTest extends \PHPUnit_Framework_TestCase
class FlatFileDriverTest extends \PHPUnit\Framework\TestCase
{
/**
* @var FlatFileDriver
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/IronMqDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Bernard\Driver\IronMqDriver;

class IronMqDriverTest extends \PHPUnit_Framework_TestCase
class IronMqDriverTest extends \PHPUnit\Framework\TestCase
{
public function setUp()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/MongoDBDriverFunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/MongoDBDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use MongoDate;
use MongoId;

class MongoDBDriverTest extends \PHPUnit_Framework_TestCase
class MongoDBDriverTest extends \PHPUnit\Framework\TestCase
{
private $messages;
private $queues;
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/PheanstalkDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
30 changes: 13 additions & 17 deletions tests/Driver/PhpAmqpDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions tests/Driver/PhpRedisDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

use Bernard\Driver\PhpRedisDriver;

class PhpRedisDriverTest extends \PHPUnit_Framework_TestCase
class PhpRedisDriverTest extends \PHPUnit\Framework\TestCase
{
public function setUp()
{
if (!extension_loaded('redis')) {
$this->markTestSkipped('"redis" extension is not loaded.');
}

$this->redis = $this->getMock('Redis', array(
$this->redis = $this->getMockBuilder('Redis')->setMethods(array(
'lLen',
'sMembers',
'lRange',
Expand All @@ -23,7 +23,7 @@ public function setUp()
'sContains',
'rPush',
'sRem',
));
))->getMock();

$this->connection = new PhpRedisDriver($this->redis);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Driver/PredisDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -21,7 +21,7 @@ public function setUp()
'sContains',
'rPush',
'sRem',
));
))->getMock();

$this->connection = new PredisDriver($this->redis);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Driver/PrefetchMessageCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Bernard\Driver\PrefetchMessageCache;

class PrefetchMessageCacheTest extends \PHPUnit_Framework_TestCase
class PrefetchMessageCacheTest extends \PHPUnit\Framework\TestCase
{
public function testPushesAndPop()
{
Expand Down
8 changes: 5 additions & 3 deletions tests/Driver/SqsDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/EnvelopeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Event/EnvelopeEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use Bernard\Event\EnvelopeEvent;

class EnvelopeEventTest extends \PHPUnit_Framework_TestCase
class EnvelopeEventTest extends \PHPUnit\Framework\TestCase
{
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()
Expand Down
4 changes: 2 additions & 2 deletions tests/Event/RejectEnvelopeEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
5 changes: 2 additions & 3 deletions tests/EventListener/ErrorLogSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,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');
Expand Down
Loading

0 comments on commit 5681d3e

Please sign in to comment.