Skip to content

Commit

Permalink
Merge pull request #488 from carusogabriel/phpunit
Browse files Browse the repository at this point in the history
Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase
  • Loading branch information
stloyd authored Dec 7, 2017
2 parents 8d715e9 + 732d47f commit a4ae481
Show file tree
Hide file tree
Showing 19 changed files with 55 additions and 43 deletions.
4 changes: 3 additions & 1 deletion Tests/Command/BaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace OldSound\RabbitMqBundle\Tests\Command;

abstract class BaseCommandTest extends \PHPUnit_Framework_TestCase
use PHPUnit\Framework\TestCase;

abstract class BaseCommandTest extends TestCase
{
protected $application;
protected $definition;
Expand Down
1 change: 0 additions & 1 deletion Tests/Command/ConsumerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace OldSound\RabbitMqBundle\Tests\Command;

use OldSound\RabbitMqBundle\Command\ConsumerCommand;

use Symfony\Component\Console\Input\InputOption;

class ConsumerCommandTest extends BaseCommandTest
Expand Down
10 changes: 5 additions & 5 deletions Tests/Command/DynamicConsumerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace OldSound\RabbitMqBundle\Tests\Command;

use OldSound\RabbitMqBundle\Command\DynamicConsumerCommand;

use Symfony\Component\Console\Input\InputOption;

class DynamicConsumerCommandTest extends BaseCommandTest{

class DynamicConsumerCommandTest extends BaseCommandTest
{

protected function setUp()
{
parent::setUp();
Expand All @@ -25,7 +25,7 @@ protected function setUp()
$this->command = new DynamicConsumerCommand();
$this->command->setApplication($this->application);
}

/**
* testInputsDefinitionCommand
*/
Expand All @@ -35,7 +35,7 @@ public function testInputsDefinitionCommand()
$definition = $this->command->getDefinition();
$this->assertTrue($definition->hasArgument('name'));
$this->assertTrue($definition->getArgument('name')->isRequired()); // Name is required to find the service

$this->assertTrue($definition->hasArgument('context'));
$this->assertTrue($definition->getArgument('context')->isRequired()); // Context is required for the queue options provider

Expand Down
10 changes: 5 additions & 5 deletions Tests/Command/MultipleConsumerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace OldSound\RabbitMqBundle\Tests\Command;

use OldSound\RabbitMqBundle\Command\MultipleConsumerCommand;

use Symfony\Component\Console\Input\InputOption;

class MultipleConsumerCommandTest extends BaseCommandTest{

class MultipleConsumerCommandTest extends BaseCommandTest
{

protected function setUp()
{
parent::setUp();
Expand All @@ -25,7 +25,7 @@ protected function setUp()
$this->command = new MultipleConsumerCommand();
$this->command->setApplication($this->application);
}

/**
* testInputsDefinitionCommand
*/
Expand All @@ -35,7 +35,7 @@ public function testInputsDefinitionCommand()
$definition = $this->command->getDefinition();
$this->assertTrue($definition->hasArgument('name'));
$this->assertTrue($definition->getArgument('name')->isRequired()); // Name is required to find the service

$this->assertTrue($definition->hasArgument('context'));
$this->assertFalse($definition->getArgument('context')->isRequired()); // Context is required for the queue options provider

Expand Down
3 changes: 2 additions & 1 deletion Tests/DependencyInjection/OldSoundRabbitMqExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
use OldSound\RabbitMqBundle\DependencyInjection\OldSoundRabbitMqExtension;
use Symfony\Component\DependencyInjection\Reference;
use PHPUnit\Framework\TestCase;

class OldSoundRabbitMqExtensionTest extends \PHPUnit_Framework_TestCase
class OldSoundRabbitMqExtensionTest extends TestCase
{
public function testFooConnectionDefinition()
{
Expand Down
5 changes: 3 additions & 2 deletions Tests/Event/AfterProcessingMessageEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
use OldSound\RabbitMqBundle\Event\AfterProcessingMessageEvent;
use OldSound\RabbitMqBundle\RabbitMq\Consumer;
use PhpAmqpLib\Message\AMQPMessage;
use PHPUnit\Framework\TestCase;

/**
* Class AfterProcessingMessageEventTest
*
* @package OldSound\RabbitMqBundle\Tests\Event
*/
class AfterProcessingMessageEventTest extends \PHPUnit_Framework_TestCase
class AfterProcessingMessageEventTest extends TestCase
{
protected function getConsumer()
{
Expand All @@ -33,4 +34,4 @@ public function testEvent()
$this->assertSame($AMQPMessage, $event->getAMQPMessage());
$this->assertSame($consumer, $event->getConsumer());
}
}
}
3 changes: 2 additions & 1 deletion Tests/Event/BeforeProcessingMessageEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
use OldSound\RabbitMqBundle\Event\BeforeProcessingMessageEvent;
use OldSound\RabbitMqBundle\RabbitMq\Consumer;
use PhpAmqpLib\Message\AMQPMessage;
use PHPUnit\Framework\TestCase;

/**
* Class BeforeProcessingMessageEventTest
*
* @package OldSound\RabbitMqBundle\Tests\Event
*/
class BeforeProcessingMessageEventTest extends \PHPUnit_Framework_TestCase
class BeforeProcessingMessageEventTest extends TestCase
{
protected function getConsumer()
{
Expand Down
3 changes: 2 additions & 1 deletion Tests/Event/OnIdleEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use OldSound\RabbitMqBundle\Event\OnIdleEvent;
use OldSound\RabbitMqBundle\RabbitMq\Consumer;
use PHPUnit\Framework\TestCase;

/**
* Class OnIdleEventTest
*
* @package OldSound\RabbitMqBundle\Tests\Event
*/
class OnIdleEventTest extends \PHPUnit_Framework_TestCase
class OnIdleEventTest extends TestCase
{
protected function getConsumer()
{
Expand Down
3 changes: 2 additions & 1 deletion Tests/Manager/MemoryCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use OldSound\RabbitMqBundle\MemoryChecker\MemoryConsumptionChecker;
use OldSound\RabbitMqBundle\MemoryChecker\NativeMemoryUsageProvider;
use PHPUnit\Framework\TestCase;

/**
* Class MemoryManagerTest
*
* @package OldSound\RabbitMqBundle\Tests\Manager
*/
class MemoryConsumptionCheckerTest extends \PHPUnit_Framework_TestCase
class MemoryConsumptionCheckerTest extends TestCase
{
public function testMemoryIsNotAlmostOverloaded()
{
Expand Down
3 changes: 2 additions & 1 deletion Tests/RabbitMq/AMQPConnectionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
use OldSound\RabbitMqBundle\Provider\ConnectionParametersProviderInterface;
use OldSound\RabbitMqBundle\RabbitMq\AMQPConnectionFactory;
use OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPConnection;
use PHPUnit\Framework\TestCase;

class AMQPConnectionFactoryTest extends \PHPUnit_Framework_TestCase
class AMQPConnectionFactoryTest extends TestCase
{
public function testDefaultValues()
{
Expand Down
3 changes: 2 additions & 1 deletion Tests/RabbitMq/BaseAmqpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
use OldSound\RabbitMqBundle\Event\AMQPEvent;
use OldSound\RabbitMqBundle\RabbitMq\BaseAmqp;
use OldSound\RabbitMqBundle\RabbitMq\Consumer;
use PHPUnit\Framework\TestCase;

class BaseAmqpTest extends \PHPUnit_Framework_TestCase
class BaseAmqpTest extends TestCase
{

public function testLazyConnection()
Expand Down
3 changes: 2 additions & 1 deletion Tests/RabbitMq/BaseConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
namespace OldSound\RabbitMqBundle\Tests\RabbitMq;

use OldSound\RabbitMqBundle\RabbitMq\BaseConsumer;
use PHPUnit\Framework\TestCase;

class BaseConsumerTest extends \PHPUnit_Framework_TestCase
class BaseConsumerTest extends TestCase
{
/** @var BaseConsumer */
protected $consumer;
Expand Down
4 changes: 2 additions & 2 deletions Tests/RabbitMq/BindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace OldSound\RabbitMqBundle\Tests\RabbitMq;


use OldSound\RabbitMqBundle\RabbitMq\Binding;
use PHPUnit\Framework\TestCase;

class BindingTest extends \PHPUnit_Framework_TestCase
class BindingTest extends TestCase
{

protected function getBinding($amqpConnection, $amqpChannel)
Expand Down
5 changes: 3 additions & 2 deletions Tests/RabbitMq/ConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
use PhpAmqpLib\Exception\AMQPTimeoutException;
use PhpAmqpLib\Message\AMQPMessage;
use OldSound\RabbitMqBundle\RabbitMq\ConsumerInterface;
use PHPUnit\Framework\TestCase;

class ConsumerTest extends \PHPUnit_Framework_TestCase
{
class ConsumerTest extends TestCase
{
protected function getConsumer($amqpConnection, $amqpChannel)
{
return new Consumer($amqpConnection, $amqpChannel);
Expand Down
14 changes: 7 additions & 7 deletions Tests/RabbitMq/DynamicConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use OldSound\RabbitMqBundle\RabbitMq\DynamicConsumer;

class DynamicConsumerTest extends ConsumerTest
{
{
public function getConsumer($amqpConnection, $amqpChannel)
{
return new DynamicConsumer($amqpConnection, $amqpChannel);
}

/**
* Preparing QueueOptionsProviderInterface instance
*
Expand All @@ -21,14 +21,14 @@ private function prepareQueueOptionsProvider()
return $this->getMockBuilder('\OldSound\RabbitMqBundle\Provider\QueueOptionsProviderInterface')
->getMock();
}

public function testQueueOptionsPrivider()
{
$amqpConnection = $this->prepareAMQPConnection();
$amqpChannel = $this->prepareAMQPChannel();
$consumer = $this->getConsumer($amqpConnection, $amqpChannel);
$consumer->setContext('foo');

$queueOptionsProvider = $this->prepareQueueOptionsProvider();
$queueOptionsProvider->expects($this->once())
->method('getQueueOptions')
Expand All @@ -40,12 +40,12 @@ public function testQueueOptionsPrivider()
)
)
));

$consumer->setQueueOptionsProvider($queueOptionsProvider);

$reflectionClass = new \ReflectionClass(get_class($consumer));
$reflectionMethod = $reflectionClass->getMethod('mergeQueueOptions');
$reflectionMethod->setAccessible(true);
$reflectionMethod->invoke($consumer);
$reflectionMethod->invoke($consumer);
}
}
15 changes: 8 additions & 7 deletions Tests/RabbitMq/MultipleConsumerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
use PhpAmqpLib\Channel\AMQPChannel;
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
use PHPUnit\Framework\TestCase;

class MultipleConsumerTest extends \PHPUnit_Framework_TestCase
class MultipleConsumerTest extends TestCase
{
/**
* Multiple consumer
Expand Down Expand Up @@ -111,13 +112,13 @@ public function testQueuesProvider($processFlag, $expectedMethod, $expectedReque
$this->multipleConsumer->processQueueMessage('test-1', $amqpMessage);
$this->multipleConsumer->processQueueMessage('test-2', $amqpMessage);
}

public function testQueuesPrivider()
{
$amqpConnection = $this->prepareAMQPConnection();
$amqpChannel = $this->prepareAMQPChannel();
$this->multipleConsumer->setContext('foo');

$queuesProvider = $this->prepareQueuesProvider();
$queuesProvider->expects($this->once())
->method('getQueues')
Expand All @@ -126,13 +127,13 @@ public function testQueuesPrivider()
'queue_foo' => array()
)
));

$this->multipleConsumer->setQueuesProvider($queuesProvider);

$reflectionClass = new \ReflectionClass(get_class($this->multipleConsumer));
$reflectionMethod = $reflectionClass->getMethod('mergeQueues');
$reflectionMethod->setAccessible(true);
$reflectionMethod->invoke($this->multipleConsumer);
$reflectionMethod->invoke($this->multipleConsumer);
}

/**
Expand Down Expand Up @@ -268,4 +269,4 @@ private function prepareCallback($processFlag)
return $processFlag;
};
}
}
}
3 changes: 2 additions & 1 deletion Tests/RabbitMq/RpcClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use OldSound\RabbitMqBundle\RabbitMq\RpcClient;
use PhpAmqpLib\Message\AMQPMessage;
use PHPUnit\Framework\TestCase;

class RpcClientTest extends \PHPUnit_Framework_TestCase
class RpcClientTest extends TestCase
{
public function testProcessMessageWithCustomUnserializer()
{
Expand Down
4 changes: 2 additions & 2 deletions Tests/RabbitMq/RpcServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use OldSound\RabbitMqBundle\RabbitMq\RpcServer;
use PhpAmqpLib\Message\AMQPMessage;
use PHPUnit\Framework\TestCase;

class RpcServerTest extends \PHPUnit_Framework_TestCase
class RpcServerTest extends TestCase
{
public function testProcessMessageWithCustomSerializer()
{
Expand Down Expand Up @@ -38,4 +39,3 @@ public function testProcessMessageWithCustomSerializer()
$server->processMessage($message);
}
}

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"require-dev": {
"symfony/serializer": "^2.7|^3.0|^4.0",
"symfony/debug": "^2.7|^3.0|^4.0",
"phpunit/phpunit": "^4.8|^5.0"
"phpunit/phpunit": "^4.8.35|^5.4.3"
},
"replace": {
"oldsound/rabbitmq-bundle": "self.version"
Expand Down

0 comments on commit a4ae481

Please sign in to comment.