/** * Tests the JApplicationBase::triggerEvent method. * * @return void * * @since 12.1 */ public function testTriggerEvent() { TestReflection::setValue($this->class, 'dispatcher', null); $this->assertNull($this->class->triggerEvent('onJApplicationBaseTriggerEvent')); TestReflection::setValue($this->class, 'dispatcher', $this->getMockDispatcher()); $this->class->registerEvent('onJApplicationBaseTriggerEvent', 'function'); $this->assertEquals(array('function' => null), $this->class->triggerEvent('onJApplicationBaseTriggerEvent')); }
/** * @testdox Tests that an event is triggered with the application dispatcher. * * @covers JApplicationBase::triggerEvent * @uses JApplicationBase::loadDispatcher * @uses JApplicationBase::registerEvent */ public function testTriggerEvent() { // Inject the mock dispatcher into the application $this->class->loadDispatcher($this->getMockDispatcher()); // Register our event to be triggered $this->class->registerEvent('onJApplicationBaseTriggerEvent', 'function'); // Validate the event was triggered $this->assertSame(array('function' => null), $this->class->triggerEvent('onJApplicationBaseTriggerEvent')); }
/** * @testdox Tests that an event is triggered with the application dispatcher. * * @covers JApplicationBase::triggerEvent * @uses JApplicationBase::setDispatcher * @uses JApplicationBase::registerEvent */ public function testTriggerEvent() { // Inject the mock dispatcher into the application $this->class->setDispatcher($this->getMockDispatcher()); // Register our event to be triggered $this->class->registerEvent('onJApplicationBaseTriggerEvent', [$this, 'eventCallback']); // Validate the event was triggered $this->assertSame([], $this->class->triggerEvent('onJApplicationBaseTriggerEvent')); $this->assertTrue(in_array('onJApplicationBaseTriggerEvent', TestMockDispatcher::$triggered)); }