Example #1
0
 public function testUncallableHandlersAreLogged()
 {
     $hooks = new \Elgg\PluginHooksService();
     $loggerMock = $this->getMock('\\Elgg\\Logger', array(), array(), '', false);
     $hooks->setLogger($loggerMock);
     $hooks->registerHandler('foo', 'bar', array(new \stdClass(), 'uncallableMethod'));
     $expectedMsg = 'handler for plugin hook [foo, bar] is not callable: (stdClass)->uncallableMethod';
     $loggerMock->expects($this->once())->method('warn')->with($expectedMsg);
     $hooks->trigger('foo', 'bar');
 }
Example #2
0
 public function testGetConfigTriggersTheConfigAmdPluginHook()
 {
     $hooks = new \Elgg\PluginHooksService();
     $amdConfig = new \Elgg\Amd\Config($hooks);
     $test_input = ['test' => 'test_' . time()];
     $hooks->registerHandler('config', 'amd', function () use($test_input) {
         return $test_input;
     });
     $config = $amdConfig->getConfig();
     $this->assertEquals($test_input, $config);
 }