public function testGet() {
$inspector = new CiviEventInspector();
- $hook = $inspector->get('hook_civicrm_alterSettingsMetaData');
- $this->assertEquals('hook_civicrm_alterSettingsMetaData', $hook['name']);
- $this->assertEquals(array('settingsMetaData', 'domainID', 'profile'), array_keys($hook['fields']));
- $this->assertTrue($hook['fields']['settingsMetaData']['ref']);
- $this->assertFalse($hook['fields']['domainID']['ref']);
- $this->assertEquals('&$settingsMetaData, $domainID, $profile', $hook['signature']);
- $this->assertTrue($inspector->validate($hook));
+ $eventDef = $inspector->get('hook_civicrm_alterSettingsMetaData');
+ $this->assertEquals('hook_civicrm_alterSettingsMetaData', $eventDef['name']);
+ $this->assertEquals(array('settingsMetaData', 'domainID', 'profile'), array_keys($eventDef['fields']));
+ $this->assertEquals('hook', $eventDef['type']);
+ $this->assertNotEmpty($eventDef['description_html']);
+ $this->assertTrue($eventDef['fields']['settingsMetaData']['ref']);
+ $this->assertFalse($eventDef['fields']['domainID']['ref']);
+ $this->assertEquals('&$settingsMetaData, $domainID, $profile', $eventDef['signature']);
+ $this->assertTrue($inspector->validate($eventDef));
+ $this->assertTrue($eventDef['stub'] instanceof \ReflectionMethod);
+ $this->assertTrue($eventDef['stub']->isStatic());
}
public function testGetAll() {
$all = $inspector->getAll();
$this->assertTrue(count($all) > 1);
$this->assertTrue(isset($all['hook_civicrm_alterSettingsMetaData']));
- foreach ($all as $name => $hook) {
- $this->assertEquals($name, $hook['name']);
- $this->assertNotEmpty($hook['description_html']);
- $this->assertTrue($inspector->validate($hook));
+ foreach ($all as $name => $eventDef) {
+ $this->assertEquals($name, $eventDef['name']);
+ $this->assertTrue($inspector->validate($eventDef));
+ if (isset($eventDef['stub'])) {
+ $this->assertTrue($eventDef['stub'] instanceof \ReflectionMethod);
+ $this->assertTrue($eventDef['stub']->isStatic());
+ }
}
}
+ public function testFind() {
+ $inspector = new CiviEventInspector();
+
+ $result_a = $inspector->find('/^hook_civicrm_post/');
+ $this->assertTrue(is_array($result_a['hook_civicrm_post']));
+ $this->assertFalse(isset($result_a['hook_civicrm_pre']));
+
+ $result_b = $inspector->find('/^hook_civicrm_pre/');
+ $this->assertTrue(is_array($result_b['hook_civicrm_pre']));
+ $this->assertFalse(isset($result_b['hook_civicrm_post']));
+ }
+
}