public function EventDispatcherTest::testStopEventPropagation

File

drupal/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php, line 133

Class

EventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests

Code

public function testStopEventPropagation() {
  $otherListener = new TestEventListener();

  // postFoo() stops the propagation, so only one listener should
  // be executed
  // Manually set priority to enforce $this->listener to be called first
  $this->dispatcher
    ->addListener('post.foo', array(
    $this->listener,
    'postFoo',
  ), 10);
  $this->dispatcher
    ->addListener('post.foo', array(
    $otherListener,
    'preFoo',
  ));
  $this->dispatcher
    ->dispatch(self::postFoo);
  $this
    ->assertTrue($this->listener->postFooInvoked);
  $this
    ->assertFalse($otherListener->postFooInvoked);
}