CiviEventInspector - Include stub for hooks (when available)
authorTim Otten <totten@civicrm.org>
Fri, 14 Apr 2017 03:55:51 +0000 (20:55 -0700)
committerTim Otten <totten@civicrm.org>
Fri, 14 Apr 2017 03:55:51 +0000 (20:55 -0700)
Civi/Core/CiviEventInspector.php
tests/phpunit/Civi/Core/CiviEventInspectorTest.php

index d5d3678607239cddd59dad6fe195526241317bba..8a4f14c3bc40cadb29200228982a8d0d974f954b 100644 (file)
@@ -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) {
index 6997d9618c82074351a693df864a985436d1b381..144232d50f709c39ecb1da4899e913849e0bf814 100644 (file)
@@ -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());
+      }
     }
   }