Repository: symfony/symfony
File: src/Symfony/Component/Messenger/Tests/DependencyInjection/MessengerPassTest.php (PHP)

Code before:
        (new ResolveClassPass())->process($container);
        (new MessengerPass())->process($container);

        $this->assertSame([DummyMessage::class], $container->getDefinition('messenger.signing_serializer')->getArgument(2));

        $child = $container->getDefinition('.signing.messenger.default_serializer');
        $this->assertInstanceOf(ChildDefinition::class, $child);
        $this->assertSame(['messenger.default_serializer', null, 0], $child->getDecoratedService());
    }

    public function testAllSignedMessagesAreMapped()
    {
        $container = $this->getContainerBuilder('message_bus');

        $container
            ->register(DummyHandler::class)
            ->addTag('messenger.message_handler', ['sign' => true])
        ;

        $container
            ->register(DummyCommandHandler::class)
            ->addTag('messenger.message_handler', ['sign' => true])
        ;

        $container->register('messenger.signing_serializer')
                  ->setArguments([null, null, [DummyMessage::class => ['messenger.default_serializer']]])
        ;

        (new ResolveClassPass())->process($container);
        (new MessengerPass())->process($container);

        $this->assertSame([DummyMessage::class, DummyCommand::class], $container->getDefinition('messenger.signing_serializer')->getArgument(2));
    }

    public function testDecoratesAllSerializersFromMappingRegardlessOfSignedTypes()
    {
        $container = $this->getContainerBuilder('message_bus');

        $container
            ->register(DummyHandler::class)
            ->addTag('messenger.message_handler', ['sign' => true])
        ;
        // Do not sign SecondMessage on purpose; we only include it in the mapping below

        $container->register('messenger.signing_serializer')
            ->setArguments([null, null, [
                DummyMessage::class => ['messenger.serializer.one', 'messenger.serializer.two'],
                SecondMessage::class => ['messenger.serializer.three'],
            ]])
        ;


Review comment (suggestion):
```suggestion
            ->setArguments([null, null, [DummyMessage::class => ['messenger.default_serializer']]])
```

Code after:
        (new ResolveClassPass())->process($container);
        (new MessengerPass())->process($container);

        $this->assertSame([DummyMessage::class], $container->getDefinition('messenger.signing_serializer')->getArgument(2));

        $child = $container->getDefinition('.signing.messenger.default_serializer');
        $this->assertInstanceOf(ChildDefinition::class, $child);
        $this->assertSame(['messenger.default_serializer', null, 0], $child->getDecoratedService());
    }

    public function testAllSignedMessagesAreMapped()
    {
        $container = $this->getContainerBuilder('message_bus');

        $container
            ->register(DummyHandler::class)
            ->addTag('messenger.message_handler', ['sign' => true])
        ;

        $container
            ->register(DummyCommandHandler::class)
            ->addTag('messenger.message_handler', ['sign' => true])
        ;

        $container->register('messenger.signing_serializer')
            ->setArguments([null, null, [DummyMessage::class => ['messenger.default_serializer']]])
        ;

        (new ResolveClassPass())->process($container);
        (new MessengerPass())->process($container);

        $this->assertSame([DummyMessage::class, DummyCommand::class], $container->getDefinition('messenger.signing_serializer')->getArgument(2));
    }

    public function testDecoratesAllSerializersFromMappingRegardlessOfSignedTypes()
    {
        $container = $this->getContainerBuilder('message_bus');

        $container
            ->register(DummyHandler::class)
            ->addTag('messenger.message_handler', ['sign' => true])
        ;
        // Do not sign SecondMessage on purpose; we only include it in the mapping below

        $container->register('messenger.signing_serializer')
            ->setArguments([null, null, [
                DummyMessage::class => ['messenger.serializer.one', 'messenger.serializer.two'],
                SecondMessage::class => ['messenger.serializer.three'],
            ]])
        ;