4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 namespace api\v
4\Entity
;
22 use api\v
4\UnitTestCase
;
27 class ExampleDataTest
extends UnitTestCase
{
30 * Basic canary test fetching a specific example.
32 * @throws \API_Exception
33 * @throws \Civi\API\Exception\UnauthorizedException
35 public function testGet() {
36 $file = \Civi
::paths()->getPath('[civicrm.root]/Civi/WorkflowMessage/GenericWorkflowMessage/alex.ex.php');
37 $workflow = 'generic';
38 $name = 'generic.alex';
40 $this->assertTrue(file_exists($file), "Expect find canary file ($file)");
42 $get = \Civi\Api4\ExampleData
::get()
43 ->addWhere('name', '=', $name)
46 $this->assertEquals($workflow, $get['workflow']);
47 $this->assertTrue(!isset($get['data']));
48 $this->assertTrue(!isset($get['asserts']));
50 $get = \Civi\Api4\ExampleData
::get()
51 ->addWhere('name', '=', $name)
52 ->addSelect('workflow', 'data')
55 $this->assertEquals($workflow, $get['workflow']);
56 $this->assertEquals(100, $get['data']['modelProps']['contact']['contact_id']);