You are here

public function AbstractEventDispatcherTest::testStopEventPropagation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/event-dispatcher/Tests/AbstractEventDispatcherTest.php \Symfony\Component\EventDispatcher\Tests\AbstractEventDispatcherTest::testStopEventPropagation()

File

vendor/symfony/event-dispatcher/Tests/AbstractEventDispatcherTest.php, line 147

Class

AbstractEventDispatcherTest

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);
}