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->headers->set('x-forwarded-for', array('127.0.0.1'));
|
||||||
$subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
$subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
||||||
|
|
||||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($subRequest));
|
||||||
$kernel
|
|
||||||
->expects($this->any())
|
|
||||||
->method('handle')
|
|
||||||
->with($subRequest)
|
|
||||||
;
|
|
||||||
|
|
||||||
$strategy = new InlineFragmentRenderer($kernel);
|
|
||||||
|
|
||||||
$strategy->render(new ControllerReference('main_controller', array('object' => $object), array()), Request::create('/'));
|
$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, '');
|
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, '');
|
||||||
|
|
||||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest(Request::create('/')));
|
||||||
$kernel
|
|
||||||
->expects($this->any())
|
|
||||||
->method('handle')
|
|
||||||
->with(Request::create('/'))
|
|
||||||
;
|
|
||||||
|
|
||||||
$strategy = new InlineFragmentRenderer($kernel);
|
|
||||||
|
|
||||||
$strategy->render('/', Request::create('/'));
|
$strategy->render('/', Request::create('/'));
|
||||||
|
|
||||||
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
|
Request::setTrustedHeaderName(Request::HEADER_CLIENT_IP, $trustedHeaderName);
|
||||||
@ -132,6 +117,22 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||||||
return $kernel;
|
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()
|
public function testExceptionInSubRequestsDoesNotMangleOutputBuffers()
|
||||||
{
|
{
|
||||||
$resolver = $this->getMock('Symfony\\Component\\HttpKernel\\Controller\\ControllerResolverInterface');
|
$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');
|
$expectedSubRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
||||||
}
|
}
|
||||||
|
|
||||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
$strategy = new InlineFragmentRenderer($this->getKernelExpectingRequest($expectedSubRequest));
|
||||||
$kernel
|
|
||||||
->expects($this->any())
|
|
||||||
->method('handle')
|
|
||||||
->with($expectedSubRequest)
|
|
||||||
;
|
|
||||||
|
|
||||||
$strategy = new InlineFragmentRenderer($kernel);
|
|
||||||
|
|
||||||
$request = Request::create('/');
|
$request = Request::create('/');
|
||||||
$request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
|
$request->headers->set('Surrogate-Capability', 'abc="ESI/1.0"');
|
||||||
|
Reference in New Issue
Block a user