Skip to content

Commit

Permalink
minor #43264 [HttpKernel] Relax some transient tests (chalasr)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[HttpKernel] Relax some transient tests

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

As observed in #42824 and more recently #43138, these tests randomly break for some reason.
Replaces #42824

Commits
-------

30fa29f [HttpKernel] Relax some transient tests
  • Loading branch information
xabbuh committed Oct 1, 2021
2 parents 7b9fc09 + 30fa29f commit e6e641c
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 e6e641c

Please sign in to comment.