(REF) Rename WorkflowMessageExample => ExampleData
[civicrm-core.git] / tests / phpunit / api / v4 / Entity / ExampleDataTest.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
11 */
12
13 /**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 */
18
19
20 namespace api\v4\Entity;
21
22 use api\v4\UnitTestCase;
23
24 /**
25 * @group headless
26 */
27 class ExampleDataTest extends UnitTestCase {
28
29 /**
30 * Basic canary test fetching a specific example.
31 *
32 * @throws \API_Exception
33 * @throws \Civi\API\Exception\UnauthorizedException
34 */
35 public function testGet() {
36 $file = \Civi::paths()->getPath('[civicrm.root]/Civi/WorkflowMessage/GenericWorkflowMessage/alex.ex.php');
37 $workflow = 'generic';
38 $name = 'generic.alex';
39
40 $this->assertTrue(file_exists($file), "Expect find canary file ($file)");
41
42 $get = \Civi\Api4\ExampleData::get()
43 ->addWhere('name', '=', $name)
44 ->execute()
45 ->single();
46 $this->assertEquals($workflow, $get['workflow']);
47 $this->assertTrue(!isset($get['data']));
48 $this->assertTrue(!isset($get['asserts']));
49
50 $get = \Civi\Api4\ExampleData::get()
51 ->addWhere('name', '=', $name)
52 ->addSelect('workflow', 'data')
53 ->execute()
54 ->single();
55 $this->assertEquals($workflow, $get['workflow']);
56 $this->assertEquals(100, $get['data']['modelProps']['contact']['contact_id']);
57 }
58
59 }