public function RouterListenerTest::testSubRequestWithDifferentMethod

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/EventListener/RouterListenerTest.php, line 105

Class

RouterListenerTest

Namespace

Symfony\Component\HttpKernel\Tests\EventListener

Code

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, new RequestContext());
  $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());
}