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