Skip to content

Commit

Permalink
Removed unused imports, removed duplicate codes and fixed all phpunit…
Browse files Browse the repository at this point in the history
… test deprecated warnings
  • Loading branch information
nursultanturdaliev committed Nov 1, 2016
1 parent 2b34ed0 commit 5a22fa2
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 40 deletions.
1 change: 0 additions & 1 deletion Command/DynamicConsumerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
*/
namespace OldSound\RabbitMqBundle\Command;

use OldSound\RabbitMqBundle\Command\BaseConsumerCommand;
use Symfony\Component\Console\Input\InputArgument;

class DynamicConsumerCommand extends BaseConsumerCommand
Expand Down
1 change: 0 additions & 1 deletion RabbitMq/AnonConsumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace OldSound\RabbitMqBundle\RabbitMq;

use OldSound\RabbitMqBundle\RabbitMq\Consumer;
use PhpAmqpLib\Connection\AbstractConnection;

class AnonConsumer extends Consumer
Expand Down
1 change: 0 additions & 1 deletion RabbitMq/BaseAmqp.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use PhpAmqpLib\Connection\AMQPLazyConnection;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;

abstract class BaseAmqp
Expand Down
1 change: 0 additions & 1 deletion RabbitMq/Consumer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use OldSound\RabbitMqBundle\Event\AfterProcessingMessageEvent;
use OldSound\RabbitMqBundle\Event\BeforeProcessingMessageEvent;
use OldSound\RabbitMqBundle\Event\OnConsumeEvent;
use OldSound\RabbitMqBundle\RabbitMq\BaseConsumer;
use PhpAmqpLib\Message\AMQPMessage;

class Consumer extends BaseConsumer
Expand Down
1 change: 0 additions & 1 deletion RabbitMq/RpcClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace OldSound\RabbitMqBundle\RabbitMq;

use OldSound\RabbitMqBundle\RabbitMq\BaseAmqp;
use PhpAmqpLib\Message\AMQPMessage;

class RpcClient extends BaseAmqp
Expand Down
2 changes: 1 addition & 1 deletion Tests/Command/BaseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function setUp()
$this->definition = $this->getMockBuilder('Symfony\\Component\\Console\\Input\\InputDefinition')
->disableOriginalConstructor()
->getMock();
$this->helperSet = $this->getMock('Symfony\\Component\\Console\\Helper\\HelperSet');
$this->helperSet = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\HelperSet')->getMock();

$this->application->expects($this->any())
->method('getDefinition')
Expand Down
21 changes: 11 additions & 10 deletions Tests/Command/ConsumerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,22 @@ protected function setUp()
*/
public function testInputsDefinitionCommand()
{
$definition = $this->command->getDefinition();
// check argument
$this->assertTrue($this->command->getDefinition()->hasArgument('name'));
$this->assertTrue($this->command->getDefinition()->getArgument('name')->isRequired()); // Name is required to find the service
$this->assertTrue($definition->hasArgument('name'));
$this->assertTrue($definition->getArgument('name')->isRequired()); // Name is required to find the service

//check options
$this->assertTrue($this->command->getDefinition()->hasOption('messages'));
$this->assertTrue($this->command->getDefinition()->getOption('messages')->isValueOptional()); // It should accept value
$this->assertTrue($definition->hasOption('messages'));
$this->assertTrue($definition->getOption('messages')->isValueOptional()); // It should accept value

$this->assertTrue($this->command->getDefinition()->hasOption('route'));
$this->assertTrue($this->command->getDefinition()->getOption('route')->isValueOptional()); // It should accept value
$this->assertTrue($definition->hasOption('route'));
$this->assertTrue($definition->getOption('route')->isValueOptional()); // It should accept value

$this->assertTrue($this->command->getDefinition()->hasOption('without-signals'));
$this->assertFalse($this->command->getDefinition()->getOption('without-signals')->acceptValue()); // It shouldn't accept value because it is a true/false input
$this->assertTrue($definition->hasOption('without-signals'));
$this->assertFalse($definition->getOption('without-signals')->acceptValue()); // It shouldn't accept value because it is a true/false input

$this->assertTrue($this->command->getDefinition()->hasOption('debug'));
$this->assertFalse($this->command->getDefinition()->getOption('debug')->acceptValue()); // It shouldn't accept value because it is a true/false input
$this->assertTrue($definition->hasOption('debug'));
$this->assertFalse($definition->getOption('debug')->acceptValue()); // It shouldn't accept value because it is a true/false input
}
}
25 changes: 13 additions & 12 deletions Tests/Command/DynamicConsumerCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,24 @@ protected function setUp()
public function testInputsDefinitionCommand()
{
// check argument
$this->assertTrue($this->command->getDefinition()->hasArgument('name'));
$this->assertTrue($this->command->getDefinition()->getArgument('name')->isRequired()); // Name is required to find the service
$definition = $this->command->getDefinition();
$this->assertTrue($definition->hasArgument('name'));
$this->assertTrue($definition->getArgument('name')->isRequired()); // Name is required to find the service

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

//check options
$this->assertTrue($this->command->getDefinition()->hasOption('messages'));
$this->assertTrue($this->command->getDefinition()->getOption('messages')->isValueOptional()); // It should accept value
$this->assertTrue($definition->hasOption('messages'));
$this->assertTrue($definition->getOption('messages')->isValueOptional()); // It should accept value

$this->assertTrue($this->command->getDefinition()->hasOption('route'));
$this->assertTrue($this->command->getDefinition()->getOption('route')->isValueOptional()); // It should accept value
$this->assertTrue($definition->hasOption('route'));
$this->assertTrue($definition->getOption('route')->isValueOptional()); // It should accept value

$this->assertTrue($this->command->getDefinition()->hasOption('without-signals'));
$this->assertFalse($this->command->getDefinition()->getOption('without-signals')->acceptValue()); // It shouldn't accept value because it is a true/false input
$this->assertTrue($definition->hasOption('without-signals'));
$this->assertFalse($definition->getOption('without-signals')->acceptValue()); // It shouldn't accept value because it is a true/false input

$this->assertTrue($this->command->getDefinition()->hasOption('debug'));
$this->assertFalse($this->command->getDefinition()->getOption('debug')->acceptValue()); // It shouldn't accept value because it is a true/false input
$this->assertTrue($definition->hasOption('debug'));
$this->assertFalse($definition->getOption('debug')->acceptValue()); // It shouldn't accept value because it is a true/false input
}
}
11 changes: 5 additions & 6 deletions Tests/Command/PurgeCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace OldSound\RabbitMqBundle\Tests\Command;

use OldSound\RabbitMqBundle\Command\ConsumerCommand;

use OldSound\RabbitMqBundle\Command\PurgeConsumerCommand;
use Symfony\Component\Console\Input\InputOption;

Expand Down Expand Up @@ -31,11 +29,12 @@ protected function setUp()
public function testInputsDefinitionCommand()
{
// check argument
$this->assertTrue($this->command->getDefinition()->hasArgument('name'));
$this->assertTrue($this->command->getDefinition()->getArgument('name')->isRequired()); // Name is required to find the service
$definition = $this->command->getDefinition();
$this->assertTrue($definition->hasArgument('name'));
$this->assertTrue($definition->getArgument('name')->isRequired()); // Name is required to find the service

//check options
$this->assertTrue($this->command->getDefinition()->hasOption('no-confirmation'));
$this->assertFalse($this->command->getDefinition()->getOption('no-confirmation')->acceptValue()); // It shouldn't accept value because it is a true/false input
$this->assertTrue($definition->hasOption('no-confirmation'));
$this->assertFalse($definition->getOption('no-confirmation')->acceptValue()); // It shouldn't accept value because it is a true/false input
}
}
1 change: 0 additions & 1 deletion Tests/RabbitMq/BaseAmqpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace OldSound\RabbitMqBundle\Tests\RabbitMq;

use OldSound\RabbitMqBundle\Event\AMQPEvent;
use OldSound\RabbitMqBundle\Event\OnConsumeEvent;
use OldSound\RabbitMqBundle\RabbitMq\BaseAmqp;
use OldSound\RabbitMqBundle\RabbitMq\Consumer;
use PhpAmqpLib\Connection\AMQPLazyConnection;
Expand Down
4 changes: 2 additions & 2 deletions Tests/RabbitMq/RpcClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public function testProcessMessageWithCustomUnserializer()
->setMethods(array('sendReply', 'maybeStopConsumer'))
->disableOriginalConstructor()
->getMock();
$message = $this->getMock('\PhpAmqpLib\Message\AMQPMessage', array('get'), array('message'));
$serializer = $this->getMock('\Symfony\Component\Serializer\SerializerInterface', array('serialize', 'deserialize'));
$message = $this->getMockBuilder('\PhpAmqpLib\Message\AMQPMessage')->setMethods(array('get'))->setConstructorArgs(array('message'))->getMock();
$serializer = $this->getMockBuilder('\Symfony\Component\Serializer\SerializerInterface')->setMethods(array('serialize', 'deserialize'))->getMock();
$serializer->expects($this->once())->method('deserialize')->with('message', 'json', null);
$client->initClient(true);
$client->setUnserializer(function($data) use ($serializer) {
Expand Down
15 changes: 12 additions & 3 deletions Tests/RabbitMq/RpcServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,28 @@ public function testProcessMessageWithCustomSerializer()
->setMethods(array('sendReply', 'maybeStopConsumer'))
->disableOriginalConstructor()
->getMock();
$message = $this->getMock('\PhpAmqpLib\Message\AMQPMessage', array('get'));
$message = $this->getMockBuilder('\PhpAmqpLib\Message\AMQPMessage')
->setMethods( array('get'))
->getMock();
$message->delivery_info = array(
'channel' => $this->getMock('\PhpAmqpLib\Channel\AMQPChannel', array(), array(), '', false),
'channel' => $this->getMockBuilder('\PhpAmqpLib\Channel\AMQPChannel')
->setMethods(array())->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock(),
'delivery_tag' => null
);
$server->setCallback(function() {
return 'message';
});
$serializer = $this->getMock('\Symfony\Component\Serializer\SerializerInterface', array('serialize', 'deserialize'));
$serializer = $this->getMockBuilder('\Symfony\Component\Serializer\SerializerInterface')
->setMethods(array('serialize', 'deserialize'))
->getMock();
$serializer->expects($this->once())->method('serialize')->with('message', 'json');
$server->setSerializer(function($data) use ($serializer) {
$serializer->serialize($data, 'json');
});
$server->processMessage($message);
}
}

0 comments on commit 5a22fa2

Please sign in to comment.