invoke() public method

Handle other requests
public invoke ( Imbo\EventManager\EventInterface $event )
$event Imbo\EventManager\EventInterface The event instance
Example #1
0
 /**
  * @covers Imbo\EventListener\Cors::invoke
  */
 public function testAddsVaryHeaderContainingOriginRegardlessOfAllowedStatus()
 {
     $this->request->expects($this->any())->method('getMethod')->will($this->returnValue('GET'));
     $route = $this->getMock('Imbo\\Router\\Route');
     $route->expects($this->any())->method('__toString')->will($this->returnValue('index'));
     $this->request->expects($this->any())->method('getRoute')->will($this->returnValue($route));
     // Allowed
     $listener = new Cors(['allowedOrigins' => ['http://imbo-project.org']]);
     $event = $this->getMock('Imbo\\EventManager\\Event');
     $event->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $response = $this->getMock('Imbo\\Http\\Response\\Response');
     $response->expects($this->once())->method('setVary')->with('Origin', false);
     $event->expects($this->any())->method('getResponse')->will($this->returnValue($response));
     $listener->invoke($event);
     // Disallowed
     $listener = new Cors(['allowedOrigins' => []]);
     $event = $this->getMock('Imbo\\EventManager\\Event');
     $event->expects($this->any())->method('getRequest')->will($this->returnValue($this->request));
     $response = $this->getMock('Imbo\\Http\\Response\\Response');
     $response->expects($this->once())->method('setVary')->with('Origin', false);
     $event->expects($this->any())->method('getResponse')->will($this->returnValue($response));
     $listener->invoke($event);
 }