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\UnitTestCase
;
29 class EntityTest
extends UnitTestCase
{
31 public function testEntityGet() {
32 \CRM_Core_BAO_ConfigSetting
::enableComponent('CiviEvent');
33 $result = Entity
::get(FALSE)
36 $this->assertArrayHasKey('Entity', $result,
37 "Entity::get missing itself");
38 $this->assertArrayHasKey('Participant', $result,
39 "Entity::get missing Participant");
42 public function testEntity() {
43 $result = Entity
::getActions(FALSE)
46 $this->assertNotContains(
48 array_keys((array) $result),
49 "Entity entity has more than basic actions");
52 public function testEntityComponent() {
53 \CRM_Core_BAO_ConfigSetting
::disableComponent('CiviEvent');
54 $result = Entity
::get(FALSE)
57 $this->assertArrayNotHasKey('Participant', $result,
58 "Entity::get should not have Participant when CiviEvent disabled");
60 // Trying to use a CiviEvent API will fail when component is disabled
62 \Civi\Api4\Participant
::get(FALSE)->execute();
65 catch (NotImplementedException
$e) {
66 $this->assertStringContainsString('CiviEvent', $e->getMessage());
69 \CRM_Core_BAO_ConfigSetting
::enableComponent('CiviEvent');
70 $result = Entity
::get(FALSE)
73 $this->assertArrayHasKey('Participant', $result,
74 "Entity::get should have Participant when CiviEvent enabled");