|
12 | 12 | namespace Symfony\Component\Messenger\Tests\Command;
|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
| 15 | +use Psr\Log\LoggerInterface; |
| 16 | +use Psr\Log\LoggerTrait; |
15 | 17 | use Symfony\Component\Console\Application;
|
16 | 18 | use Symfony\Component\Console\Exception\InvalidOptionException;
|
17 | 19 | use Symfony\Component\Console\Tester\CommandCompletionTester;
|
@@ -231,18 +233,31 @@ public function testRunWithMemoryLimit()
|
231 | 233 | $busLocator->method('has')->with('dummy-bus')->willReturn(true);
|
232 | 234 | $busLocator->method('get')->with('dummy-bus')->willReturn($bus);
|
233 | 235 |
|
234 |
| - $command = new ConsumeMessagesCommand(new RoutableMessageBus($busLocator), $receiverLocator, new EventDispatcher()); |
| 236 | + $logger = new class() implements LoggerInterface { |
| 237 | + use LoggerTrait; |
| 238 | + |
| 239 | + public array $logs = []; |
| 240 | + |
| 241 | + public function log($level, $message, array $context = []): void |
| 242 | + { |
| 243 | + $this->logs[] = func_get_args(); |
| 244 | + } |
| 245 | + }; |
| 246 | + $command = new ConsumeMessagesCommand(new RoutableMessageBus($busLocator), $receiverLocator, new EventDispatcher(), $logger); |
235 | 247 |
|
236 | 248 | $application = new Application();
|
237 | 249 | $application->add($command);
|
238 | 250 | $tester = new CommandTester($application->get('messenger:consume'));
|
239 | 251 | $tester->execute([
|
240 | 252 | 'receivers' => ['dummy-receiver'],
|
241 |
| - '--memory-limit' => '0.5M', |
| 253 | + '--memory-limit' => '1.5M', |
242 | 254 | ]);
|
243 | 255 |
|
244 | 256 | $this->assertSame(0, $tester->getStatusCode());
|
245 | 257 | $this->assertStringContainsString('[OK] Consuming messages from transport "dummy-receiver"', $tester->getDisplay());
|
| 258 | + $this->assertStringContainsString('The worker will automatically exit once it has exceeded 1.5M of memory', $tester->getDisplay()); |
| 259 | + |
| 260 | + $this->assertSame(1572864, $logger->logs[1][2]['limit']); |
246 | 261 | }
|
247 | 262 |
|
248 | 263 | /**
|
|
0 commit comments