}
/**
+ * 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'];
}
/**
*/
public function build(array &$example): void {
$alex = \Civi\Test::example('workflow/generic/Alex');
- $contact = $this->extend($alex['data']['modelProps']['contact'], [
+ $contact = $this->extend($alex['modelProps']['contact'], [
'role' => 'myrole',
]);
$example['data'] = [
*/
public function build(array &$example): void {
$alex = \Civi\Test::example('workflow/generic/Alex');
- $example['data'] = $this->extend($alex['data'], [
+ $example['data'] = $this->extend($alex, [
'workflow' => $this->wfName,
'modelProps' => [
'contact' => [