public function EventDispatcherTest::testGetListenersSortsByPriority

File

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

Class

EventDispatcherTest

Namespace

Symfony\Component\EventDispatcher\Tests

Code

public function testGetListenersSortsByPriority() {
  $listener1 = new TestEventListener();
  $listener2 = new TestEventListener();
  $listener3 = new TestEventListener();
  $listener1->name = '1';
  $listener2->name = '2';
  $listener3->name = '3';
  $this->dispatcher
    ->addListener('pre.foo', array(
    $listener1,
    'preFoo',
  ), -10);
  $this->dispatcher
    ->addListener('pre.foo', array(
    $listener2,
    'preFoo',
  ), 10);
  $this->dispatcher
    ->addListener('pre.foo', array(
    $listener3,
    'preFoo',
  ));
  $expected = array(
    array(
      $listener2,
      'preFoo',
    ),
    array(
      $listener3,
      'preFoo',
    ),
    array(
      $listener1,
      'preFoo',
    ),
  );
  $this
    ->assertSame($expected, $this->dispatcher
    ->getListeners('pre.foo'));
}