Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
276 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
tests/Container/AmqpCommandConsumerCallbackFactoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/humus-amqp-producer. | ||
* (c) 2016 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare (strict_types=1); | ||
|
||
namespace ProophTest\ServiceBus\Message\HumusAmqp\Container; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Prooph\Common\Messaging\MessageFactory; | ||
use Prooph\ServiceBus\CommandBus; | ||
use Prooph\ServiceBus\Message\HumusAmqp\AmqpCommandConsumerCallback; | ||
use Prooph\ServiceBus\Message\HumusAmqp\Container\AmqpCommandConsumerCallbackFactory; | ||
|
||
/** | ||
* Class AmqpCommandConsumerCallbackFactoryTest | ||
* @package ProophTest\ServiceBus\Message\HumusAmqp\Container | ||
*/ | ||
class AmqpCommandConsumerCallbackFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_creates_amqp_command_consumer_callback() | ||
{ | ||
$commandBus = $this->prophesize(CommandBus::class); | ||
$messageFactory = $this->prophesize(MessageFactory::class); | ||
|
||
$container = $this->prophesize(ContainerInterface::class); | ||
$container->get('config')->willReturn([ | ||
'prooph' => [ | ||
'humus-amqp-producer' => [ | ||
'command_consumer_callback' => [ | ||
'test-command-consumer-callback' => [ | ||
'command_bus' => 'test-command-bus', | ||
'message_factory' => 'test-message-factory' | ||
] | ||
] | ||
] | ||
] | ||
])->shouldBeCalled(); | ||
$container->get('test-command-bus')->willReturn($commandBus->reveal())->shouldBeCalled(); | ||
$container->get('test-message-factory')->willReturn($messageFactory->reveal())->shouldBeCalled(); | ||
|
||
$name = 'test-command-consumer-callback'; | ||
$amqpCommandConsumerCallback = AmqpCommandConsumerCallbackFactory::$name($container->reveal()); | ||
$this->assertInstanceOf(AmqpCommandConsumerCallback::class, $amqpCommandConsumerCallback); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_throws_exception_when_no_container_passed_to_call_static() | ||
{ | ||
$this->expectException(\Prooph\ServiceBus\Exception\InvalidArgumentException::class); | ||
$this->expectExceptionMessage('The first argument must be of type ' . ContainerInterface::class); | ||
|
||
$name = 'test-command-consumer-callback'; | ||
AmqpCommandConsumerCallbackFactory::$name('invalid_container'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/humus-amqpDelayed-producer. | ||
* (c) 2016 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare (strict_types=1); | ||
|
||
namespace ProophTest\ServiceBus\Message\HumusAmqpDelayed\Container; | ||
|
||
use Humus\Amqp\Producer; | ||
use Interop\Container\ContainerInterface; | ||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Prooph\Common\Messaging\MessageConverter; | ||
use Prooph\ServiceBus\Message\HumusAmqp\AmqpDelayedMessageProducer; | ||
use Prooph\ServiceBus\Message\HumusAmqp\Container\AmqpDelayedMessageProducerFactory; | ||
|
||
/** | ||
* Class AmqpDelayedMessageProducerFactoryTest | ||
* @package ProophTest\ServiceBus\Message\HumusAmqpDelayed\Container | ||
*/ | ||
class AmqpDelayedMessageProducerFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_creates_amqpDelayed_message_producer() | ||
{ | ||
$producer = $this->prophesize(Producer::class); | ||
$messageConverter = $this->prophesize(MessageConverter::class); | ||
|
||
$container = $this->prophesize(ContainerInterface::class); | ||
$container->get('config')->willReturn([ | ||
'prooph' => [ | ||
'humus-amqp-producer' => [ | ||
'delayed_message_producer' => [ | ||
'test-delayed-message-producer' => [ | ||
'producer' => 'test-producer', | ||
'message_converter' => 'test-message-converter', | ||
'app_id' => 'test-app' | ||
] | ||
] | ||
] | ||
] | ||
])->shouldBeCalled(); | ||
$container->get('test-producer')->willReturn($producer->reveal())->shouldBeCalled(); | ||
$container->get('test-message-converter')->willReturn($messageConverter->reveal())->shouldBeCalled(); | ||
|
||
$name = 'test-delayed-message-producer'; | ||
$amqpDelayedMessageProducer = AmqpDelayedMessageProducerFactory::$name($container->reveal()); | ||
$this->assertInstanceOf(AmqpDelayedMessageProducer::class, $amqpDelayedMessageProducer); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_throws_exception_when_no_container_passed_to_call_static() | ||
{ | ||
$this->expectException(\Prooph\ServiceBus\Exception\InvalidArgumentException::class); | ||
$this->expectExceptionMessage('The first argument must be of type ' . ContainerInterface::class); | ||
|
||
$name = 'test-delayed-message-producer'; | ||
AmqpDelayedMessageProducerFactory::$name('invalid_container'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/humus-amqp-producer. | ||
* (c) 2016 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare (strict_types=1); | ||
|
||
namespace ProophTest\ServiceBus\Message\HumusAmqp\Container; | ||
|
||
use Interop\Container\ContainerInterface; | ||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Prooph\Common\Messaging\MessageFactory; | ||
use Prooph\ServiceBus\EventBus; | ||
use Prooph\ServiceBus\Message\HumusAmqp\AmqpEventConsumerCallback; | ||
use Prooph\ServiceBus\Message\HumusAmqp\Container\AmqpEventConsumerCallbackFactory; | ||
|
||
/** | ||
* Class AmqpEventConsumerCallbackFactoryTest | ||
* @package ProophTest\ServiceBus\Message\HumusAmqp\Container | ||
*/ | ||
class AmqpEventConsumerCallbackFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_creates_amqp_event_consumer_callback() | ||
{ | ||
$eventBus = $this->prophesize(EventBus::class); | ||
$messageFactory = $this->prophesize(MessageFactory::class); | ||
|
||
$container = $this->prophesize(ContainerInterface::class); | ||
$container->get('config')->willReturn([ | ||
'prooph' => [ | ||
'humus-amqp-producer' => [ | ||
'event_consumer_callback' => [ | ||
'test-event-consumer-callback' => [ | ||
'event_bus' => 'test-event-bus', | ||
'message_factory' => 'test-message-factory' | ||
] | ||
] | ||
] | ||
] | ||
])->shouldBeCalled(); | ||
$container->get('test-event-bus')->willReturn($eventBus->reveal())->shouldBeCalled(); | ||
$container->get('test-message-factory')->willReturn($messageFactory->reveal())->shouldBeCalled(); | ||
|
||
$name = 'test-event-consumer-callback'; | ||
$amqpEventConsumerCallback = AmqpEventConsumerCallbackFactory::$name($container->reveal()); | ||
$this->assertInstanceOf(AmqpEventConsumerCallback::class, $amqpEventConsumerCallback); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_throws_exception_when_no_container_passed_to_call_static() | ||
{ | ||
$this->expectException(\Prooph\ServiceBus\Exception\InvalidArgumentException::class); | ||
$this->expectExceptionMessage('The first argument must be of type ' . ContainerInterface::class); | ||
|
||
$name = 'test-event-consumer-callback'; | ||
AmqpEventConsumerCallbackFactory::$name('invalid_container'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/humus-amqp-producer. | ||
* (c) 2016 prooph software GmbH <contact@prooph.de> | ||
* (c) 2016 Sascha-Oliver Prolic <saschaprolic@googlemail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare (strict_types=1); | ||
|
||
namespace ProophTest\ServiceBus\Message\HumusAmqp\Container; | ||
|
||
use Humus\Amqp\Producer; | ||
use Interop\Container\ContainerInterface; | ||
use PHPUnit_Framework_TestCase as TestCase; | ||
use Prooph\Common\Messaging\MessageConverter; | ||
use Prooph\ServiceBus\Message\HumusAmqp\AmqpMessageProducer; | ||
use Prooph\ServiceBus\Message\HumusAmqp\Container\AmqpMessageProducerFactory; | ||
|
||
/** | ||
* Class AmqpMessageProducerFactoryTest | ||
* @package ProophTest\ServiceBus\Message\HumusAmqp\Container | ||
*/ | ||
class AmqpMessageProducerFactoryTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_creates_amqp_message_producer() | ||
{ | ||
$producer = $this->prophesize(Producer::class); | ||
$messageConverter = $this->prophesize(MessageConverter::class); | ||
|
||
$container = $this->prophesize(ContainerInterface::class); | ||
$container->get('config')->willReturn([ | ||
'prooph' => [ | ||
'humus-amqp-producer' => [ | ||
'message_producer' => [ | ||
'test-message-producer' => [ | ||
'producer' => 'test-producer', | ||
'message_converter' => 'test-message-converter', | ||
'app_id' => 'test-app' | ||
] | ||
] | ||
] | ||
] | ||
])->shouldBeCalled(); | ||
$container->get('test-producer')->willReturn($producer->reveal())->shouldBeCalled(); | ||
$container->get('test-message-converter')->willReturn($messageConverter->reveal())->shouldBeCalled(); | ||
|
||
$name = 'test-message-producer'; | ||
$amqpMessageProducer = AmqpMessageProducerFactory::$name($container->reveal()); | ||
$this->assertInstanceOf(AmqpMessageProducer::class, $amqpMessageProducer); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_throws_exception_when_no_container_passed_to_call_static() | ||
{ | ||
$this->expectException(\Prooph\ServiceBus\Exception\InvalidArgumentException::class); | ||
$this->expectExceptionMessage('The first argument must be of type ' . ContainerInterface::class); | ||
|
||
$name = 'test-message-producer'; | ||
AmqpMessageProducerFactory::$name('invalid_container'); | ||
} | ||
} |