Added delta for Request comparison
Sometimes, tests are failing because REQUEST_TIME changes between the creation of the various sub-requests. By using delta, we allow maximum of second of difference. Example: https://travis-ci.org/symfony/symfony/jobs/17668158#L511
This commit is contained in:
parent
0cb789a369
commit
72d45839f0
@ -55,14 +55,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
||||
$subRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
|
||||
$subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
||||
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('handle')
|
||||
->with($subRequest)
|
||||
;
|
||||
|
||||
$strategy = new InlineFragmentRenderer($kernel);
|
||||
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest));
|
||||
|
||||
$strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/'));
|
||||
}
|
||||
@ -73,15 +66,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, '');
|
||||
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('handle')
|
||||
->with(Request::create('/'))
|
||||
;
|
||||
|
||||
$strategy = new InlineFragmentRenderer($kernel);
|
||||
|
||||
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/')));
|
||||
$strategy->render('/', Request::create('/'));
|
||||
|
||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
|
||||
@ -132,6 +117,22 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
||||
return $kernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Kernel expecting a request equals to $request
|
||||
* Allows delta in comparison in case REQUEST_TIME changed by 1 second
|
||||
*/
|
||||
private function getKernelExpectingRequest(Request $request)
|
||||
{
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('handle')
|
||||
->with($this->equalTo($request, 1))
|
||||
;
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
|
||||
public function testExceptionInSubRequestsDoesNotMangleOutputBuffers()
|
||||
{
|
||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
||||
@ -173,14 +174,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
||||
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
||||
}
|
||||
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
$kernel
|
||||
->expects($this->any())
|
||||
->method('handle')
|
||||
->with($expectedSubRequest)
|
||||
;
|
||||
|
||||
$strategy = new InlineFragmentRenderer($kernel);
|
||||
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
|
||||
|
Reference in New Issue
Block a user