Rename hook_civicrm_hooks to hook_civicrm_eventDefs
[civicrm-core.git] / tests / phpunit / Civi / Core / CiviEventInspectorTest.php
CommitLineData
bdd65b5c 1<?php
ec84755a 2namespace Civi\Core;
bdd65b5c
TO
3
4/**
ec84755a 5 * Class CiviEventInspectorTest
bdd65b5c
TO
6 * @group headless
7 */
ec84755a 8class CiviEventInspectorTest extends \CiviUnitTestCase {
bdd65b5c
TO
9
10 public function testGet() {
ec84755a 11 $inspector = new CiviEventInspector();
6f1818fd
TO
12 $eventDef = $inspector->get('hook_civicrm_alterSettingsMetaData');
13 $this->assertEquals('hook_civicrm_alterSettingsMetaData', $eventDef['name']);
14 $this->assertEquals(array('settingsMetaData', 'domainID', 'profile'), array_keys($eventDef['fields']));
0d0031a0
TO
15 $this->assertEquals('hook', $eventDef['type']);
16 $this->assertNotEmpty($eventDef['description_html']);
6f1818fd
TO
17 $this->assertTrue($eventDef['fields']['settingsMetaData']['ref']);
18 $this->assertFalse($eventDef['fields']['domainID']['ref']);
19 $this->assertEquals('&$settingsMetaData, $domainID, $profile', $eventDef['signature']);
20 $this->assertTrue($inspector->validate($eventDef));
bdd65b5c
TO
21 }
22
23 public function testGetAll() {
ec84755a 24 $inspector = new CiviEventInspector();
bdd65b5c
TO
25 $all = $inspector->getAll();
26 $this->assertTrue(count($all) > 1);
27 $this->assertTrue(isset($all['hook_civicrm_alterSettingsMetaData']));
6f1818fd
TO
28 foreach ($all as $name => $eventDef) {
29 $this->assertEquals($name, $eventDef['name']);
6f1818fd 30 $this->assertTrue($inspector->validate($eventDef));
bdd65b5c
TO
31 }
32 }
33
6f1818fd
TO
34 public function testFind() {
35 $inspector = new CiviEventInspector();
36
37 $result_a = $inspector->find('/^hook_civicrm_post/');
38 $this->assertTrue(is_array($result_a['hook_civicrm_post']));
39 $this->assertFalse(isset($result_a['hook_civicrm_pre']));
40
41 $result_b = $inspector->find('/^hook_civicrm_pre/');
42 $this->assertTrue(is_array($result_b['hook_civicrm_pre']));
43 $this->assertFalse(isset($result_b['hook_civicrm_post']));
44 }
45
bdd65b5c 46}