[HttpKernel] added some unit tests
This commit is contained in:
parent
fd0e589c2b
commit
8ebe624b82
@ -106,4 +106,34 @@ class RouterListenerTest extends \PHPUnit_Framework_TestCase
|
||||
$listener = new RouterListener($requestMatcher);
|
||||
$listener->onKernelRequest($event);
|
||||
}
|
||||
|
||||
public function testSubRequestWithDifferentMethod()
|
||||
{
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
$request = Request::create('http://localhost/', 'post');
|
||||
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
|
||||
|
||||
$requestMatcher = $this->getMock('Symfony\Component\Routing\Matcher\RequestMatcherInterface');
|
||||
$requestMatcher->expects($this->any())
|
||||
->method('matchRequest')
|
||||
->with($this->isInstanceOf('Symfony\Component\HttpFoundation\Request'))
|
||||
->will($this->returnValue(array()));
|
||||
|
||||
$context = new RequestContext();
|
||||
$requestMatcher->expects($this->any())
|
||||
->method('getContext')
|
||||
->will($this->returnValue($context));
|
||||
|
||||
$listener = new RouterListener($requestMatcher);
|
||||
$listener->onKernelRequest($event);
|
||||
|
||||
// sub-request with another HTTP method
|
||||
$kernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface');
|
||||
$request = Request::create('http://localhost/', 'get');
|
||||
$event = new GetResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST);
|
||||
|
||||
$listener->onKernelRequest($event);
|
||||
|
||||
$this->assertEquals('GET', $context->getMethod());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user