| 1 | <?php |
||
| 12 | |||
| 13 | class TransportFactoryFactoryTest extends TestCase |
||
| 14 | { |
||
| 15 | use ProphecyTrait; |
||
| 16 | |||
| 17 | public function testFactory(): void |
||
| 18 | { |
||
| 19 | $container = $this->prophesize(ContainerInterface::class); |
||
| 20 | $container->get('config')->willReturn([ |
||
| 21 | 'messenger' => [ |
||
| 22 | 'transport_factories' => [ |
||
| 23 | 'foo_factory', |
||
| 24 | ], |
||
| 25 | ], |
||
| 26 | ]); |
||
| 27 | |||
| 28 | $fooFactory = $this->prophesize(TransportFactoryInterface::class); |
||
| 29 | $fooFactory->supports('foo', [])->willReturn(true); |
||
| 30 | $fooFactory->supports('bar', [])->willReturn(false); |
||
| 31 | |||
| 32 | $container->get('foo_factory') |
||
| 33 | ->shouldBeCalled() |
||
| 34 | ->willReturn($fooFactory->reveal()); |
||
| 35 | |||
| 36 | $factory = new TransportFactoryFactory(); |
||
| 37 | |||
| 38 | $service = $factory($container->reveal()); |
||
| 39 | |||
| 40 | $this->assertTrue($service->supports('foo', [])); |
||
| 41 | $this->assertFalse($service->supports('bar', [])); |
||
| 44 |