Exemplo n.º 1
0
 /**
  * Test that all observer information is returned correctly.
  */
 public function test_get_all_observers()
 {
     // Retrieve all observers.
     $observers = \core\event\manager::get_all_observers();
     // Expected information from the workshop allocation scheduled observer.
     $expected = new stdClass();
     $expected->callable = '\\workshopallocation_scheduled\\observer::workshop_viewed';
     $expected->priority = 0;
     $expected->internal = true;
     $expected->includefile = null;
     $expected->plugintype = 'workshopallocation';
     $expected->plugin = 'scheduled';
     // May be more than one observer for the mod_workshop event.
     $found = false;
     foreach ($observers['\\mod_workshop\\event\\course_module_viewed'] as $observer) {
         if ($expected == $observer) {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found);
 }
Exemplo n.º 2
0
 /**
  * Get the full list of observers for the system.
  *
  * @return array An array of observers in the system.
  */
 public static function get_observer_list()
 {
     $events = \core\event\manager::get_all_observers();
     foreach ($events as $key => $observers) {
         foreach ($observers as $observerskey => $observer) {
             $events[$key][$observerskey]->parentplugin = \core_plugin_manager::instance()->get_parent_of_subplugin($observer->plugintype);
         }
     }
     return $events;
 }
Exemplo n.º 3
0
 /**
  * Test that all observer information is returned correctly.
  */
 public function test_get_all_observers()
 {
     // Retrieve all observers.
     $observers = \core\event\manager::get_all_observers();
     // Expected information from the workshop allocation scheduled observer.
     $expected = array();
     $observer = new stdClass();
     $observer->callable = '\\workshopallocation_scheduled\\observer::workshop_viewed';
     $observer->priority = 0;
     $observer->internal = true;
     $observer->includefile = null;
     $observer->plugintype = 'workshopallocation';
     $observer->plugin = 'scheduled';
     $expected[0] = $observer;
     $this->assertEquals($expected, $observers['\\mod_workshop\\event\\course_module_viewed']);
 }