/**
  * Test the triggerEvent method with a previously registered event.
  *
  * @return  void
  *
  * @covers  Joomla\Event\Dispatcher::triggerEvent
  * @since   1.0
  */
 public function testTriggerEventRegistered()
 {
     $event = new Event('onSomething');
     $mockedListener = $this->getMock('Joomla\\Event\\Test\\Stubs\\SomethingListener', array('onSomething'));
     $mockedListener->expects($this->once())->method('onSomething')->with($event);
     $this->instance->addEvent($event);
     $this->instance->addListener($mockedListener);
     $this->instance->triggerEvent('onSomething');
 }
 /**
  * Test the clearListeners method.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testCountListeners()
 {
     $this->assertEquals(0, $this->instance->countListeners('onTest'));
     // Add 3 listeners listening to the same events.
     $listener1 = new SomethingListener();
     $listener2 = new SomethingListener();
     $listener3 = new SomethingListener();
     $this->instance->addListener('onBeforeSomething', [$listener1, 'onBeforeSomething'])->addListener('onSomething', [$listener1, 'onSomething'])->addListener('onAfterSomething', [$listener1, 'onAfterSomething'])->addListener('onBeforeSomething', [$listener2, 'onBeforeSomething'])->addListener('onSomething', [$listener2, 'onSomething'])->addListener('onAfterSomething', [$listener2, 'onAfterSomething'])->addListener('onBeforeSomething', [$listener3, 'onBeforeSomething'])->addListener('onSomething', [$listener3, 'onSomething'])->addListener('onAfterSomething', [$listener3, 'onAfterSomething']);
     $this->assertEquals(3, $this->instance->countListeners('onSomething'));
 }
 /**
  * Registers the event listener for the current hook and project
  *
  * @return  void
  *
  * @since   1.0
  */
 protected function addEventListener()
 {
     /*
      * Add the event listener if it exists.  Listeners are named in the format of <project><type>Listener in the Hooks\Listeners namespace.
      * For example, the listener for a joomla-cms pull activity would be JoomlacmsPullsListener
      */
     $baseClass = ucfirst(str_replace('-', '', $this->project->gh_project)) . ucfirst($this->type) . 'Listener';
     $fullClass = __NAMESPACE__ . '\\Hooks\\Listeners\\' . $baseClass;
     if (class_exists($fullClass)) {
         $this->dispatcher->addListener(new $fullClass());
         $this->listenerSet = true;
     }
 }
 /**
  * Registers the event listener for the current project.
  *
  * @param   string  $type  The event listener type.
  *
  * @return  $this
  *
  * @since   1.0
  */
 protected function addEventListener($type)
 {
     /* @type \JTracker\Application $application */
     $application = $this->getContainer()->get('app');
     /*
      * Add the event listener if it exists.  Listeners are named in the format of <project><type>Listener in the Hooks\Listeners namespace.
      * For example, the listener for a joomla-cms pull activity would be JoomlacmsPullsListener
      */
     $baseClass = ucfirst(str_replace('-', '', $application->getProject()->gh_project)) . ucfirst($type) . 'Listener';
     $fullClass = 'App\\Tracker\\Controller\\Hooks\\Listeners\\' . $baseClass;
     if (class_exists($fullClass)) {
         $this->dispatcher->addListener(new $fullClass());
         $this->listenerSet = true;
     }
     return $this;
 }