1 | <?php |
||
11 | class StdInProducerControllerTest extends AbstractConsoleControllerTestCase |
||
12 | { |
||
13 | protected function setUp() |
||
14 | { |
||
15 | $config = include __DIR__.'/../../TestConfiguration.php.dist'; |
||
16 | $this->setApplicationConfig($config); |
||
17 | parent::setUp(); |
||
18 | } |
||
19 | |||
20 | public function testDispatchWithTestProducer() |
||
21 | { |
||
22 | $producer = $this->getMockBuilder('RabbitMqModule\Producer') |
||
23 | ->setMethods(['publish']) |
||
24 | ->disableOriginalConstructor() |
||
25 | ->getMock(); |
||
26 | $producer |
||
27 | ->expects(static::once()) |
||
28 | ->method('publish') |
||
29 | ->with( |
||
30 | static::equalTo('msg'), |
||
31 | static::equalTo('bar') |
||
32 | ); |
||
33 | |||
34 | $serviceManager = $this->getApplicationServiceLocator(); |
||
35 | $serviceManager->setAllowOverride(true); |
||
36 | $serviceManager->setService('rabbitmq_module.producer.foo', $producer); |
||
37 | |||
38 | ob_start(); |
||
39 | $this->dispatch('rabbitmq-module stdin-producer foo --route=bar msg'); |
||
40 | ob_end_clean(); |
||
41 | |||
42 | $this->assertResponseStatusCode(0); |
||
43 | } |
||
44 | |||
45 | public function testDispatchWithInvalidTestProducer() |
||
46 | { |
||
47 | ob_start(); |
||
48 | $this->dispatch('rabbitmq-module stdin-producer foo --route=bar msg'); |
||
49 | $output = ob_get_clean(); |
||
50 | |||
51 | static::assertRegExp('/No producer with name "foo" found/', $output); |
||
52 | |||
53 | $this->assertResponseStatusCode(1); |
||
54 | } |
||
55 | } |
||
56 |