Esempio n. 1
0
 public function testAfterLoadEventChangedValue()
 {
     $moduleAlias = 'alias';
     $loadedAlias = '';
     $afterEventID = Event::subscribe(Core::E_AFTER_LOADED, function (&$core, &$module, &$alias) use(&$loadedAlias) {
         $loadedAlias = $alias;
     });
     $this->core->load(new TestModule(), $moduleAlias);
     $this->assertEquals($moduleAlias, $loadedAlias);
     Event::unsubscribe(Core::E_AFTER_LOADED, $afterEventID);
 }
Esempio n. 2
0
 public function testUnsubscribe()
 {
     // Add two subscribers
     $identifier = \samsonphp\event\Event::subscribe('test.unsubscribe', array($this, 'eventDynamicCallback'));
     $param = 'test';
     $result = \samsonphp\event\Event::signal('test.unsubscribe', array(&$param));
     // Perform test - only first subscriber must be executed
     $this->assertEquals(2, $result);
     \samsonphp\event\Event::unsubscribe('test.unsubscribe', $identifier);
     $result = \samsonphp\event\Event::signal('test.unsubscribe', array(&$param));
     $this->assertEquals(null, $result);
 }