Merge pull request #22619 from demeritcowboy/wrong-tz
[civicrm-core.git] / Civi / Test.php
index ff498544235d06c4927f9d381fb5d8934bc64717..3deca30fbc2862b12cc7a928e51e2eb83de0918b 100644 (file)
@@ -50,7 +50,7 @@ class Test {
   /**
    * Get the data source used for testing.
    *
-   * @param string|NULL $part
+   * @param string|null $part
    *   One of NULL, 'hostspec', 'port', 'username', 'password', 'database'.
    * @return string|array|NULL
    *   If $part is omitted, return full DSN array.
@@ -193,16 +193,33 @@ class Test {
   }
 
   /**
+   * Lookup the content of an example data-set.
+   *
+   * This helper is for the common case of looking up the data for a specific example.
+   * If you need more detailed information (eg the list of examples or other metadata),
+   * then use `\Civi\Test::examples(): ExampleDataLoader`. It  provides more methods.
+   *
    * @param string $name
    *   Symbolic name of the data-set.
    * @return array
+   *   The example data.
    */
   public static function example(string $name): array {
     $result = static::examples()->getFull($name);
-    if ($result === NULL) {
+    if (!isset($result['data'])) {
       throw new \CRM_Core_Exception("Failed to load example data-set: $name");
     }
-    return $result;
+    return $result['data'];
+  }
+
+  /**
+   * @return \Civi\Test\EventChecker
+   */
+  public static function eventChecker() {
+    if (!isset(self::$singletons['eventChecker'])) {
+      self::$singletons['eventChecker'] = new \Civi\Test\EventChecker();
+    }
+    return self::$singletons['eventChecker'];
   }
 
   /**