Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 36dc8dc

Browse files
committed
Test stopwatch start and stop when there's a cloned TraceableStack
1 parent e46dba8 commit 36dc8dc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Symfony/Component/Messenger/Tests/Middleware/TraceableMiddlewareTest.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,24 @@ public function testCloneTraceableStack(): void
153153

154154
$stopwatch = $this->createMock(Stopwatch::class);
155155

156-
$traceableStack = new TraceableStack($stackMiddleware, $stopwatch, 'command.bus', 'test');
156+
$series = [
157+
[$this->matches('"%sMiddlewareInterface%s" on "command_bus"'), 'messenger.middleware'],
158+
[$this->matches('"%sMiddlewareInterface%s" on "command_bus"'), 'messenger.middleware'],
159+
];
160+
$stopwatch->expects($this->exactly(2))
161+
->method('start')
162+
->willReturnCallback(function (string $name, string $category = null) use (&$series) {
163+
[$constraint, $expectedCategory] = array_shift($series);
164+
165+
$constraint->evaluate($name);
166+
$this->assertSame($expectedCategory, $category);
167+
168+
return $this->createMock(StopwatchEvent::class);
169+
})
170+
;
171+
$stopwatch->expects($this->never())->method('stop');
172+
173+
$traceableStack = new TraceableStack($stackMiddleware, $stopwatch, 'command_bus', 'messenger.middleware');
157174
$clonedStack = clone $traceableStack;
158175

159176
self::assertSame($traceableStack->next(), $clonedStack->next());

0 commit comments

Comments
 (0)