public function KernelTest::testTerminateDelegatesTerminationOnlyForTerminableInterface

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Tests/KernelTest.php, line 776

Class

KernelTest

Namespace

Symfony\Component\HttpKernel\Tests

Code

public function testTerminateDelegatesTerminationOnlyForTerminableInterface() {

  // does not implement TerminableInterface
  $httpKernelMock = $this
    ->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernelInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $httpKernelMock
    ->expects($this
    ->never())
    ->method('terminate');
  $kernel = $this
    ->getMockBuilder('Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\KernelForTest')
    ->disableOriginalConstructor()
    ->setMethods(array(
    'getHttpKernel',
  ))
    ->getMock();
  $kernel
    ->expects($this
    ->once())
    ->method('getHttpKernel')
    ->will($this
    ->returnValue($httpKernelMock));
  $kernel
    ->setIsBooted(true);
  $kernel
    ->terminate(Request::create('/'), new Response());

  // implements TerminableInterface
  $httpKernelMock = $this
    ->getMockBuilder('Symfony\\Component\\HttpKernel\\HttpKernel')
    ->disableOriginalConstructor()
    ->setMethods(array(
    'terminate',
  ))
    ->getMock();
  $httpKernelMock
    ->expects($this
    ->once())
    ->method('terminate');
  $kernel = $this
    ->getMockBuilder('Symfony\\Component\\HttpKernel\\Tests\\Fixtures\\KernelForTest')
    ->disableOriginalConstructor()
    ->setMethods(array(
    'getHttpKernel',
  ))
    ->getMock();
  $kernel
    ->expects($this
    ->exactly(2))
    ->method('getHttpKernel')
    ->will($this
    ->returnValue($httpKernelMock));
  $kernel
    ->setIsBooted(true);
  $kernel
    ->terminate(Request::create('/'), new Response());
}