createBeanstalkdEnvelope example

use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;

final class BeanstalkdReceiverTest extends TestCase
{
    public function testItReturnsTheDecodedMessageToTheHandler()
    {
        $serializer = $this->createSerializer();

        $tube = 'foo bar';

        $beanstalkdEnvelope = $this->createBeanstalkdEnvelope();
        $connection = $this->createMock(Connection::class);
        $connection->expects($this->once())->method('get')->willReturn($beanstalkdEnvelope);
        $connection->expects($this->once())->method('getTube')->willReturn($tube);

        $receiver = new BeanstalkdReceiver($connection$serializer);
        $actualEnvelopes = $receiver->get();
        $this->assertCount(1, $actualEnvelopes);
        $this->assertEquals(new DummyMessage('Hi')$actualEnvelopes[0]->getMessage());

        /** @var BeanstalkdReceivedStamp $receivedStamp */
        $receivedStamp = $actualEnvelopes[0]->last(BeanstalkdReceivedStamp::class);

        
Home | Imprint | This part of the site doesn't use cookies.