Merge pull request #11250 from agh1/no-update-indices
[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));
e1d66df7
TO
21 $this->assertTrue($eventDef['stub'] instanceof \ReflectionMethod);
22 $this->assertTrue($eventDef['stub']->isStatic());
bdd65b5c
TO
23 }
24
25 public function testGetAll() {
ec84755a 26 $inspector = new CiviEventInspector();
bdd65b5c
TO
27 $all = $inspector->getAll();
28 $this->assertTrue(count($all) > 1);
29 $this->assertTrue(isset($all['hook_civicrm_alterSettingsMetaData']));
6f1818fd
TO
30 foreach ($all as $name => $eventDef) {
31 $this->assertEquals($name, $eventDef['name']);
6f1818fd 32 $this->assertTrue($inspector->validate($eventDef));
e1d66df7
TO
33 if (isset($eventDef['stub'])) {
34 $this->assertTrue($eventDef['stub'] instanceof \ReflectionMethod);
35 $this->assertTrue($eventDef['stub']->isStatic());
36 }
bdd65b5c
TO
37 }
38 }
39
6f1818fd
TO
40 public function testFind() {
41 $inspector = new CiviEventInspector();
42
43 $result_a = $inspector->find('/^hook_civicrm_post/');
44 $this->assertTrue(is_array($result_a['hook_civicrm_post']));
45 $this->assertFalse(isset($result_a['hook_civicrm_pre']));
46
47 $result_b = $inspector->find('/^hook_civicrm_pre/');
48 $this->assertTrue(is_array($result_b['hook_civicrm_pre']));
49 $this->assertFalse(isset($result_b['hook_civicrm_post']));
50 }
51
bdd65b5c 52}