|
28 | 28 | use Bdf\Queue\Testing\QueueHelper; |
29 | 29 | use Bdf\QueueBundle\BdfQueueBundle; |
30 | 30 | use Bdf\QueueBundle\Consumption\ReceiverLoader; |
| 31 | +use Bdf\QueueBundle\Tests\Fixtures\Bar; |
| 32 | +use Bdf\QueueBundle\Tests\Fixtures\Foo; |
31 | 33 | use Bdf\QueueBundle\Tests\Fixtures\GetDestinationFactory; |
32 | 34 | use Bdf\QueueBundle\Tests\Fixtures\TestHandler; |
33 | 35 | use PHPUnit\Framework\TestCase; |
@@ -82,6 +84,33 @@ public function testFunctional() |
82 | 84 | $this->assertEquals([['foo' => 'bar']], $handler->messages); |
83 | 85 | } |
84 | 86 |
|
| 87 | + public function testWithBind() |
| 88 | + { |
| 89 | + $kernel = new \TestKernel(__DIR__.'/Fixtures/conf_with_bind.yaml'); |
| 90 | + $kernel->boot(); |
| 91 | + |
| 92 | + /** @var DestinationManager $destinations */ |
| 93 | + $destinations = $kernel->getContainer()->get('bdf_queue.destination_manager'); |
| 94 | + $destination = $destinations->create('test'); |
| 95 | + |
| 96 | + $this->assertInstanceOf(DestinationInterface::class, $destination); |
| 97 | + |
| 98 | + /** @var TestHandler $handler */ |
| 99 | + $handler = $kernel->getContainer()->get(TestHandler::class); |
| 100 | + |
| 101 | + $helper = new QueueHelper($kernel->getContainer()); |
| 102 | + $destination->send((new Message(new Foo('azerty')))->setName('Foo')); |
| 103 | + $destination->send((new Message(new Bar(42)))->setName('Bar')); |
| 104 | + $destination->send((new Message(new Bar(42)))->setName('Baz')); |
| 105 | + |
| 106 | + $helper->consume(3, 'test'); |
| 107 | + $this->assertEquals([ |
| 108 | + new Foo('azerty'), |
| 109 | + new Bar(42), |
| 110 | + ['value' => 42], // Not bound to a class |
| 111 | + ], $handler->messages); |
| 112 | + } |
| 113 | + |
85 | 114 | public function testWithJsonSerializer() |
86 | 115 | { |
87 | 116 | $kernel = new \TestKernel(__DIR__.'/Fixtures/conf_with_json_serializer.yaml'); |
|
0 commit comments