Skip to content

Commit 052c495

Browse files
committed
test
1 parent f7dd4c1 commit 052c495

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Symfony/Component/Messenger/Tests/Command/ConsumeMessagesCommandTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
namespace Symfony\Component\Messenger\Tests\Command;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Psr\Log\LoggerInterface;
16+
use Psr\Log\LoggerTrait;
1517
use Symfony\Component\Console\Application;
1618
use Symfony\Component\Console\Exception\InvalidOptionException;
1719
use Symfony\Component\Console\Tester\CommandCompletionTester;
@@ -231,18 +233,31 @@ public function testRunWithMemoryLimit()
231233
$busLocator->method('has')->with('dummy-bus')->willReturn(true);
232234
$busLocator->method('get')->with('dummy-bus')->willReturn($bus);
233235

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);
235247

236248
$application = new Application();
237249
$application->add($command);
238250
$tester = new CommandTester($application->get('messenger:consume'));
239251
$tester->execute([
240252
'receivers' => ['dummy-receiver'],
241-
'--memory-limit' => '0.5M',
253+
'--memory-limit' => '1.5M',
242254
]);
243255

244256
$this->assertSame(0, $tester->getStatusCode());
245257
$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']);
246261
}
247262

248263
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy