/** * Test the setEvent method. * * @return void * * @covers Joomla\Event\Dispatcher::setEvent * @since 1.0 */ public function testSetEvent() { $event = new Event('onTest'); $this->instance->setEvent($event); $this->assertTrue($this->instance->hasEvent('onTest')); $this->assertSame($event, $this->instance->getEvent('onTest')); $immutableEvent = new EventImmutable('onAfterSomething'); $this->instance->setEvent($immutableEvent); $this->assertTrue($this->instance->hasEvent('onAfterSomething')); $this->assertSame($immutableEvent, $this->instance->getEvent('onAfterSomething')); // Setting an existing event will replace the old one. $eventCopy = new Event('onTest'); $this->instance->setEvent($eventCopy); $this->assertTrue($this->instance->hasEvent('onTest')); $this->assertSame($eventCopy, $this->instance->getEvent('onTest')); }