Rename CRM_Utils_Hook_Inspector to Civi\Core\CiviEventInspector
[civicrm-core.git] / tests / phpunit / Civi / Core / CiviEventInspectorTest.php
1 <?php
2 namespace Civi\Core;
3
4 /**
5 * Class CiviEventInspectorTest
6 * @group headless
7 */
8 class CiviEventInspectorTest extends \CiviUnitTestCase {
9
10 public function testGet() {
11 $inspector = new CiviEventInspector();
12 $hook = $inspector->get('hook_civicrm_alterSettingsMetaData');
13 $this->assertEquals('hook_civicrm_alterSettingsMetaData', $hook['name']);
14 $this->assertEquals(array('settingsMetaData', 'domainID', 'profile'), array_keys($hook['fields']));
15 $this->assertTrue($hook['fields']['settingsMetaData']['ref']);
16 $this->assertFalse($hook['fields']['domainID']['ref']);
17 $this->assertEquals('&$settingsMetaData, $domainID, $profile', $hook['signature']);
18 $this->assertTrue($inspector->validate($hook));
19 }
20
21 public function testGetAll() {
22 $inspector = new CiviEventInspector();
23 $all = $inspector->getAll();
24 $this->assertTrue(count($all) > 1);
25 $this->assertTrue(isset($all['hook_civicrm_alterSettingsMetaData']));
26 foreach ($all as $name => $hook) {
27 $this->assertEquals($name, $hook['name']);
28 $this->assertNotEmpty($hook['description_html']);
29 $this->assertTrue($inspector->validate($hook));
30 }
31 }
32
33 }