Skip to content

Commit

Permalink
[HttpKernel] Relax some transient tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Sep 30, 2021
1 parent 7b9fc09 commit 30fa29f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Expand Up @@ -18,9 +18,6 @@
use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
use Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface;

/**
* @group time-sensitive
*/
class FragmentHandlerTest extends TestCase
{
private $requestStack;
Expand Down Expand Up @@ -61,7 +58,20 @@ public function testDeliverWithUnsuccessfulResponse()

public function testRender()
{
$handler = $this->getHandler($this->returnValue(new Response('foo')), ['/', Request::create('/'), ['foo' => 'foo', 'ignore_errors' => true]]);
$expectedRequest = Request::create('/');
$handler = $this->getHandler(
$this->returnValue(new Response('foo')),
[
'/',
$this->callback(function (Request $request) use ($expectedRequest) {
$expectedRequest->server->remove('REQUEST_TIME_FLOAT');
$request->server->remove('REQUEST_TIME_FLOAT');

return $expectedRequest == $request;
}),
['foo' => 'foo', 'ignore_errors' => true],
]
);

$this->assertEquals('foo', $handler->render('/', 'foo', ['foo' => 'foo']));
}
Expand Down
Expand Up @@ -261,13 +261,18 @@ public function testIpAddressOfRangedTrustedProxyIsSetAsRemote()
/**
* Creates a Kernel expecting a request equals to $request.
*/
private function getKernelExpectingRequest(Request $request, $strict = false)
private function getKernelExpectingRequest(Request $expectedRequest)
{
$kernel = $this->createMock(HttpKernelInterface::class);
$kernel
->expects($this->once())
->method('handle')
->with($request)
->with($this->callback(function (Request $request) use ($expectedRequest) {
$expectedRequest->server->remove('REQUEST_TIME_FLOAT');
$request->server->remove('REQUEST_TIME_FLOAT');

return $expectedRequest == $request;
}))
->willReturn(new Response('foo'));

return $kernel;
Expand Down

0 comments on commit 30fa29f

Please sign in to comment.