Merge branch '4.4' into 5.1
* 4.4: [ProxyManagerBridge] Fix tests [Messenger] Fix stopwach usage if it has been reset
This commit is contained in:
commit
1c91f55482
@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\DummyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\SunnyInterface
|
class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\DummyInterface, \Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper\SunnyInterface
|
||||||
{
|
{
|
||||||
|
%w private $valueHolder%s = null;
|
||||||
private $valueHolder%s = null;
|
|
||||||
|
|
||||||
private $initializer%s = null;
|
private $initializer%s = null;
|
||||||
|
|
||||||
@ -96,7 +95,7 @@ class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \S
|
|||||||
|
|
||||||
$targetObject = $this->valueHolder%s;
|
$targetObject = $this->valueHolder%s;
|
||||||
|
|
||||||
$targetObject->$name = $value; return $targetObject->$name;
|
$targetObject->$name = $value;%wreturn $targetObject->$name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __isset($name)
|
public function __isset($name)
|
||||||
@ -158,7 +157,5 @@ class SunnyInterface_%s implements \ProxyManager\Proxy\VirtualProxyInterface, \S
|
|||||||
public function getWrappedValueHolderValue()%S
|
public function getWrappedValueHolderValue()%S
|
||||||
{
|
{
|
||||||
return $this->valueHolder%s;
|
return $this->valueHolder%s;
|
||||||
}
|
}%w
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class TraceableStack implements StackInterface
|
|||||||
*/
|
*/
|
||||||
public function next(): MiddlewareInterface
|
public function next(): MiddlewareInterface
|
||||||
{
|
{
|
||||||
if (null !== $this->currentEvent) {
|
if (null !== $this->currentEvent && $this->stopwatch->isStarted($this->currentEvent)) {
|
||||||
$this->stopwatch->stop($this->currentEvent);
|
$this->stopwatch->stop($this->currentEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class TraceableMiddlewareTest extends MiddlewareTestCase
|
|||||||
};
|
};
|
||||||
|
|
||||||
$stopwatch = $this->createMock(Stopwatch::class);
|
$stopwatch = $this->createMock(Stopwatch::class);
|
||||||
$stopwatch->expects($this->once())->method('isStarted')->willReturn(true);
|
$stopwatch->expects($this->exactly(2))->method('isStarted')->willReturn(true);
|
||||||
$stopwatch->expects($this->exactly(2))
|
$stopwatch->expects($this->exactly(2))
|
||||||
->method('start')
|
->method('start')
|
||||||
->withConsecutive(
|
->withConsecutive(
|
||||||
@ -91,4 +91,36 @@ class TraceableMiddlewareTest extends MiddlewareTestCase
|
|||||||
$traced = new TraceableMiddleware($stopwatch, $busId);
|
$traced = new TraceableMiddleware($stopwatch, $busId);
|
||||||
$traced->handle(new Envelope(new DummyMessage('Hello')), new StackMiddleware(new \ArrayIterator([null, $middleware])));
|
$traced->handle(new Envelope(new DummyMessage('Hello')), new StackMiddleware(new \ArrayIterator([null, $middleware])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testHandleWhenStopwatchHasBeenReset()
|
||||||
|
{
|
||||||
|
$busId = 'command_bus';
|
||||||
|
$envelope = new Envelope(new DummyMessage('Hello'));
|
||||||
|
|
||||||
|
$stopwatch = new Stopwatch();
|
||||||
|
|
||||||
|
$middleware = new class($stopwatch) implements MiddlewareInterface {
|
||||||
|
public $calls = 0;
|
||||||
|
private $stopwatch;
|
||||||
|
|
||||||
|
public function __construct(Stopwatch $stopwatch)
|
||||||
|
{
|
||||||
|
$this->stopwatch = $stopwatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(Envelope $envelope, StackInterface $stack): Envelope
|
||||||
|
{
|
||||||
|
$this->stopwatch->reset();
|
||||||
|
|
||||||
|
++$this->calls;
|
||||||
|
|
||||||
|
return $stack->next()->handle($envelope, $stack);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$traced = new TraceableMiddleware($stopwatch, $busId);
|
||||||
|
|
||||||
|
$traced->handle($envelope, new StackMiddleware(new \ArrayIterator([null, $middleware])));
|
||||||
|
$this->assertSame(1, $middleware->calls);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user