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

Code before:
                DummyCommand::class => [[DummyCommandHandler::class, ['bus' => $commandBusId]]],
                MultipleBusesMessage::class => [[MultipleBusesMessageHandler::class, ['bus' => $commandBusId]]],
            ],
            $queryBusId => [
                DummyQuery::class => [[DummyQueryHandler::class, ['bus' => $queryBusId]]],
                MultipleBusesMessage::class => [[MultipleBusesMessageHandler::class, ['bus' => $queryBusId]]],
            ],
            $emptyBus => [],
        ], $container->getDefinition('console.command.messenger_debug')->getArgument(0));
    }

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

        $container->register('messenger.middleware.handle_message', HandleMessageMiddleware::class)
            ->setAbstract(true)
        ;

        $container
            ->register(DummyHandler::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], $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])
        ;

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

Code after:
                DummyCommand::class => [[DummyCommandHandler::class, ['bus' => $commandBusId]]],
                MultipleBusesMessage::class => [[MultipleBusesMessageHandler::class, ['bus' => $commandBusId]]],
            ],
            $queryBusId => [
                DummyQuery::class => [[DummyQueryHandler::class, ['bus' => $queryBusId]]],
                MultipleBusesMessage::class => [[MultipleBusesMessageHandler::class, ['bus' => $queryBusId]]],
            ],
            $emptyBus => [],
        ], $container->getDefinition('console.command.messenger_debug')->getArgument(0));
    }

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

        $container->register('messenger.middleware.handle_message', HandleMessageMiddleware::class)
            ->setAbstract(true)
        ;

        $container
            ->register(DummyHandler::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], $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])
        ;