You are here

class SurrogateListenerTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php \Symfony\Component\HttpKernel\Tests\EventListener\SurrogateListenerTest

Hierarchy

  • class \Symfony\Component\HttpKernel\Tests\EventListener\SurrogateListenerTest extends \Symfony\Component\HttpKernel\Tests\EventListener\PHPUnit_Framework_TestCase

Expanded class hierarchy of SurrogateListenerTest

File

vendor/symfony/http-kernel/Tests/EventListener/SurrogateListenerTest.php, line 23

Namespace

Symfony\Component\HttpKernel\Tests\EventListener
View source
class SurrogateListenerTest extends \PHPUnit_Framework_TestCase {
  public function testFilterDoesNothingForSubRequests() {
    $dispatcher = new EventDispatcher();
    $kernel = $this
      ->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
    $response = new Response('foo <esi:include src="" />');
    $listener = new SurrogateListener(new Esi());
    $dispatcher
      ->addListener(KernelEvents::RESPONSE, array(
      $listener,
      'onKernelResponse',
    ));
    $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::SUB_REQUEST, $response);
    $dispatcher
      ->dispatch(KernelEvents::RESPONSE, $event);
    $this
      ->assertEquals('', $event
      ->getResponse()->headers
      ->get('Surrogate-Control'));
  }
  public function testFilterWhenThereIsSomeEsiIncludes() {
    $dispatcher = new EventDispatcher();
    $kernel = $this
      ->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
    $response = new Response('foo <esi:include src="" />');
    $listener = new SurrogateListener(new Esi());
    $dispatcher
      ->addListener(KernelEvents::RESPONSE, array(
      $listener,
      'onKernelResponse',
    ));
    $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
    $dispatcher
      ->dispatch(KernelEvents::RESPONSE, $event);
    $this
      ->assertEquals('content="ESI/1.0"', $event
      ->getResponse()->headers
      ->get('Surrogate-Control'));
  }
  public function testFilterWhenThereIsNoEsiIncludes() {
    $dispatcher = new EventDispatcher();
    $kernel = $this
      ->getMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
    $response = new Response('foo');
    $listener = new SurrogateListener(new Esi());
    $dispatcher
      ->addListener(KernelEvents::RESPONSE, array(
      $listener,
      'onKernelResponse',
    ));
    $event = new FilterResponseEvent($kernel, new Request(), HttpKernelInterface::MASTER_REQUEST, $response);
    $dispatcher
      ->dispatch(KernelEvents::RESPONSE, $event);
    $this
      ->assertEquals('', $event
      ->getResponse()->headers
      ->get('Surrogate-Control'));
  }

}

Members