1 | <?php |
||
13 | class ProducerFactoryTest extends \PHPUnit_Framework_TestCase |
||
14 | { |
||
15 | public function testCreateService() |
||
16 | { |
||
17 | $factory = new ProducerFactory('foo'); |
||
18 | $serviceManager = new ServiceManager(); |
||
19 | $serviceManager->setService( |
||
20 | 'Configuration', |
||
21 | [ |
||
22 | 'rabbitmq_module' => [ |
||
23 | 'producer' => [ |
||
24 | 'foo' => [ |
||
25 | 'connection' => 'foo', |
||
26 | 'exchange' => [ |
||
27 | 'name' => 'exchange-name', |
||
28 | ], |
||
29 | 'queue' => [ |
||
30 | 'name' => 'queue-name', |
||
31 | ], |
||
32 | 'auto_setup_fabric_enabled' => false, |
||
33 | ], |
||
34 | ], |
||
35 | ], |
||
36 | ] |
||
37 | ); |
||
38 | |||
39 | $connection = static::getMockBuilder(AbstractConnection::class) |
||
40 | ->disableOriginalConstructor() |
||
41 | ->getMockForAbstractClass(); |
||
42 | $serviceManager->setService( |
||
43 | 'rabbitmq_module.connection.foo', |
||
44 | $connection |
||
45 | ); |
||
46 | |||
47 | /** @var Producer $service */ |
||
48 | $service = $factory($serviceManager, 'producer'); |
||
49 | |||
50 | static::assertInstanceOf(Producer::class, $service); |
||
51 | static::assertSame($connection, $service->getConnection()); |
||
52 | static::assertEquals('exchange-name', $service->getExchangeOptions()->getName()); |
||
53 | static::assertEquals('queue-name', $service->getQueueOptions()->getName()); |
||
54 | static::assertFalse($service->isAutoSetupFabricEnabled()); |
||
55 | } |
||
56 | } |
||
57 |