From e1d66df799edae6bc951d39a773344e7e28e9576 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 13 Apr 2017 20:55:51 -0700 Subject: [PATCH] CiviEventInspector - Include stub for hooks (when available) --- Civi/Core/CiviEventInspector.php | 1 + tests/phpunit/Civi/Core/CiviEventInspectorTest.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Civi/Core/CiviEventInspector.php b/Civi/Core/CiviEventInspector.php index d5d3678607..8a4f14c3bc 100644 --- a/Civi/Core/CiviEventInspector.php +++ b/Civi/Core/CiviEventInspector.php @@ -192,6 +192,7 @@ class CiviEventInspector { 'description_html' => $method->getDocComment() ? \CRM_Admin_Page_APIExplorer::formatDocBlock($method->getDocComment()) : '', 'fields' => array(), 'class' => 'Civi\Core\Event\GenericHookEvent', + 'stub' => $method, ); foreach ($method->getParameters() as $parameter) { diff --git a/tests/phpunit/Civi/Core/CiviEventInspectorTest.php b/tests/phpunit/Civi/Core/CiviEventInspectorTest.php index 6997d9618c..144232d50f 100644 --- a/tests/phpunit/Civi/Core/CiviEventInspectorTest.php +++ b/tests/phpunit/Civi/Core/CiviEventInspectorTest.php @@ -18,6 +18,8 @@ class CiviEventInspectorTest extends \CiviUnitTestCase { $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() { @@ -28,6 +30,10 @@ class CiviEventInspectorTest extends \CiviUnitTestCase { 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()); + } } } -- 2.25.1