Merge pull request #20905 from eileenmcnaughton/utf8
[civicrm-core.git] / Civi / Test / HookInterface.php
index 4885cd06772525e0610ac326716ea60dd2c169c4..12b0cb7588d10b4f0a6f019fd35878e8e809b3c4 100644 (file)
@@ -17,12 +17,29 @@ namespace Civi\Test;
  * }
  * ```
  *
+ * Similarly, to subscribe using Symfony-style listeners, create function with the 'on_' prefix:
+ *
+ * ```
+ * class MyTest extends \PHPUnit_Framework_TestCase implements \Civi\Test\HookInterface {
+ *   public function on_civi_api_authorize(AuthorizeEvent $e): void {
+ *     echo "Running civi.api.authorize\n";
+ *   }
+ *   public function on_hook_civicrm_post(GenericHookEvent $e): void {
+ *     echo "Running hook_civicrm_post\n";
+ *   }
+ * }
+ * ```
+ *
  * At time of writing, there are a few limitations in how HookInterface is handled
  * by CiviTestListener:
  *
  *  - The test must execute in-process (aka HeadlessInterface; aka CIVICRM_UF==UnitTests).
  *    End-to-end tests (multi-process tests) are not supported.
  *  - Early bootstrap hooks (e.g. hook_civicrm_config) are not supported.
+ *  - This does not support priorities or registering multiple listeners.
+ *
+ * If you need more advanced registration abilities, consider using `Civi::dispatcher()`
+ * or `EventDispatcherInterface`.
  *
  * @see CiviTestListener
  */