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\Api4TestBase
;
23 use Civi\Test\TransactionalInterface
;
28 class ExampleDataTest
extends Api4TestBase
implements TransactionalInterface
{
31 * Basic canary test fetching a specific example.
33 * @throws \API_Exception
34 * @throws \Civi\API\Exception\UnauthorizedException
36 public function testGet() {
37 $file = \Civi
::paths()->getPath('[civicrm.root]/Civi/WorkflowMessage/GenericWorkflowMessage/Alex.ex.php');
38 $name = 'workflow/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($name, $get['name']);
47 $this->assertTrue(!isset($get['data']), 'Default "get" should not return "data"');
48 $this->assertTrue(!isset($get['asserts']), 'Default "get" should not return "asserts"');
50 $get = \Civi\Api4\ExampleData
::get()
51 ->addWhere('name', 'LIKE', 'workflow/generic/%')
53 $this->assertTrue($get->count() > 0);
54 foreach ($get as $gotten) {
55 $this->assertStringStartsWith('workflow/generic/', $gotten['name']);
58 $get = \Civi\Api4\ExampleData
::get()
59 ->addWhere('name', '=', $name)
60 ->addSelect('workflow', 'data')
63 $this->assertEquals($name, $get['name']);
64 $this->assertEquals(100, $get['data']['modelProps']['contact']['contact_id']);