Filters a value by calling all listeners of a given event.
public function testFilterWhenThereIsNoEsiIncludes() { $dispatcher = new EventDispatcher(); $listener = new EsiListener(new Esi()); $dispatcher->connect('core.response', array($listener, 'filter')); $event = new Event(null, 'core.response', array('request_type' => HttpKernelInterface::MASTER_REQUEST)); $dispatcher->filter($event, $response = new Response('foo')); $this->assertEquals('', $response->headers->get('Surrogate-Control')); }
public function testFilter() { $listener = new Listener(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'filterFoo')); $dispatcher->connect('foo', array($listener, 'filterFooBis')); $ret = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo'); $this->assertEquals('-*foo*-', $ret, '->filter() returns the filtered value'); $listener->reset(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'filterFooBis')); $dispatcher->connect('foo', array($listener, 'filterFoo')); $ret = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo'); $this->assertEquals('*-foo-*', $ret, '->filter() returns the filtered value'); }
public function testFilter() { $listener = new Listener(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'filterFoo')); $dispatcher->connect('foo', array($listener, 'filterFooBis')); $e = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo'); $this->assertEquals('-*foo*-', $e->getReturnValue(), '->filter() filters a value'); $this->assertEquals($event, $e, '->filter() returns the event object'); $listener->reset(); $dispatcher = new EventDispatcher(); $dispatcher->connect('foo', array($listener, 'filterFooBis')); $dispatcher->connect('foo', array($listener, 'filterFoo')); $e = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo'); $this->assertEquals('*-foo-*', $e->getReturnValue(), '->filter() filters a value'); }