You are here

public function AbstractEventDispatcherTest::testDispatchByPriority in Zircon Profile 8.0

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

File

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

Class

AbstractEventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests

Code

public function testDispatchByPriority() {
  $invoked = array();
  $listener1 = function () use (&$invoked) {
    $invoked[] = '1';
  };
  $listener2 = function () use (&$invoked) {
    $invoked[] = '2';
  };
  $listener3 = function () use (&$invoked) {
    $invoked[] = '3';
  };
  $this->dispatcher
    ->addListener('pre.foo', $listener1, -10);
  $this->dispatcher
    ->addListener('pre.foo', $listener2);
  $this->dispatcher
    ->addListener('pre.foo', $listener3, 10);
  $this->dispatcher
    ->dispatch(self::preFoo);
  $this
    ->assertEquals(array(
    '3',
    '2',
    '1',
  ), $invoked);
}