Repository: symfony/symfony
File: src/Symfony/Component/Messenger/Tests/Middleware/HandleMessageMiddlewareTest.php (PHP)

Code before:

            private function getBatchSize(): int
            {
                return 3;
            }

            private function process(array $jobs): void
            {
                $this->processedMessages = array_column($jobs, 0);

                foreach ($jobs as [$job, $ack]) {
                    $ack->ack($job);
                }
            }
        };

        $middleware = new HandleMessageMiddleware(new HandlersLocator([
            DummyMessage::class => [new HandlerDescriptor($handler)],
        ]));

        $ack = static function () {};

        $message = new DummyMessage('Hey');
        $envelope = $middleware->handle(new Envelope($message, [new AckStamp($ack)]), new StackMiddleware());

        $this->assertEmpty($handler->processedMessages);
        $this->assertCount(1, $envelope->all(NoAutoAckStamp::class));

        $handler->flush(false);

        $this->assertEmpty($handler->processedMessages);

        $handler->flush(true);

        $this->assertSame([$message], $handler->processedMessages);
    }

    public function testHandlerArgumentsStamp()
    {
        $message = new DummyMessage('Hey');
        $envelope = new Envelope($message);
        $envelope = $envelope->with(new HandlerArgumentsStamp(['additional argument']));

        $handler = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']);

        $middleware = new HandleMessageMiddleware(new HandlersLocator([
            DummyMessage::class => [$handler],
        ]));

        $handler->expects($this->once())->method('__invoke')->with($message, 'additional argument');


Review comment (suggestion):
empty is banned :) (same below)
```suggestion
        $this->assertSame([], $handler->processedMessages);
```

Code after:

            private function getBatchSize(): int
            {
                return 3;
            }

            private function process(array $jobs): void
            {
                $this->processedMessages = array_column($jobs, 0);

                foreach ($jobs as [$job, $ack]) {
                    $ack->ack($job);
                }
            }
        };

        $middleware = new HandleMessageMiddleware(new HandlersLocator([
            DummyMessage::class => [new HandlerDescriptor($handler)],
        ]));

        $ack = static function () {};

        $message = new DummyMessage('Hey');
        $envelope = $middleware->handle(new Envelope($message, [new AckStamp($ack)]), new StackMiddleware());

        $this->assertSame([], $handler->processedMessages);
        $this->assertCount(1, $envelope->all(NoAutoAckStamp::class));

        $handler->flush(false);

        $this->assertSame([], $handler->processedMessages);

        $handler->flush(true);

        $this->assertSame([$message], $handler->processedMessages);
    }

    public function testHandlerArgumentsStamp()
    {
        $message = new DummyMessage('Hey');
        $envelope = new Envelope($message);
        $envelope = $envelope->with(new HandlerArgumentsStamp(['additional argument']));

        $handler = $this->createPartialMock(HandleMessageMiddlewareTestCallable::class, ['__invoke']);

        $middleware = new HandleMessageMiddleware(new HandlersLocator([
            DummyMessage::class => [$handler],
        ]));

        $handler->expects($this->once())->method('__invoke')->with($message, 'additional argument');