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 Civi\API\Exception\NotImplementedException
;
24 use api\v
4\Api4TestBase
;
25 use Civi\Test\TransactionalInterface
;
30 class EntityTest
extends Api4TestBase
implements TransactionalInterface
{
32 public function testEntityGet() {
33 \CRM_Core_BAO_ConfigSetting
::enableComponent('CiviEvent');
34 $result = Entity
::get(FALSE)
37 $this->assertArrayHasKey('Entity', $result,
38 "Entity::get missing itself");
39 $this->assertArrayHasKey('Participant', $result,
40 "Entity::get missing Participant");
43 public function testEntity() {
44 $result = Entity
::getActions(FALSE)
47 $this->assertNotContains(
49 array_keys((array) $result),
50 "Entity entity has more than basic actions");
53 public function testEntityComponent() {
54 \CRM_Core_BAO_ConfigSetting
::disableComponent('CiviEvent');
55 $result = Entity
::get(FALSE)
58 $this->assertArrayNotHasKey('Participant', $result,
59 "Entity::get should not have Participant when CiviEvent disabled");
61 // Trying to use a CiviEvent API will fail when component is disabled
63 \Civi\Api4\Participant
::get(FALSE)->execute();
66 catch (NotImplementedException
$e) {
67 $this->assertStringContainsString('CiviEvent', $e->getMessage());
70 \CRM_Core_BAO_ConfigSetting
::enableComponent('CiviEvent');
71 $result = Entity
::get(FALSE)
74 $this->assertArrayHasKey('Participant', $result,
75 "Entity::get should have Participant when CiviEvent enabled");