/** * Test the getListenerPriority method. * * @return void * * @covers Joomla\Event\Dispatcher::getListenerPriority * @since 1.0 */ public function testGetListenerPriority() { $this->assertNull($this->instance->getListenerPriority(new \stdClass(), 'onTest')); $listener = new SomethingListener(); $this->instance->addListener($listener); $this->assertEquals(Priority::NORMAL, $this->instance->getListenerPriority($listener, new Event('onSomething'))); }
/** * Test the addSubscriber method. * * @return void */ public function testAddSubscriber() { $listener = new SomethingListener(); // Add our event subscriber $this->instance->addSubscriber($listener); $this->assertTrue($this->instance->hasListener([$listener, 'onBeforeSomething'])); $this->assertTrue($this->instance->hasListener([$listener, 'onSomething'])); $this->assertTrue($this->instance->hasListener([$listener, 'onAfterSomething'])); $this->assertEquals(Priority::NORMAL, $this->instance->getListenerPriority('onBeforeSomething', [$listener, 'onBeforeSomething'])); $this->assertEquals(Priority::NORMAL, $this->instance->getListenerPriority('onSomething', [$listener, 'onSomething'])); $this->assertEquals(Priority::HIGH, $this->instance->getListenerPriority('onAfterSomething', [$listener, 'onAfterSomething'])); }