APIv4 - Treat navigation permissions as array, add pseudoconstant for operator
[civicrm-core.git] / tests / phpunit / api / v4 / Entity / NavigationTest.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 namespace api\v4\Entity;
20
21 use api\v4\UnitTestCase;
22 use Civi\Api4\Navigation;
23 use Civi\Test\TransactionalInterface;
24
25 /**
26 * @group headless
27 */
28 class NavigationTest extends UnitTestCase implements TransactionalInterface {
29
30 public function testCreate() {
31 $created = Navigation::create(FALSE)
32 ->addValue('permission', ['administer CiviCRM', 'access CiviCRM'])
33 ->addValue('name', 'Test menu item')
34 ->execute()->single();
35
36 $fetched = Navigation::get(FALSE)
37 ->addWhere('id', '=', $created['id'])
38 ->execute()->single();
39
40 $this->assertEquals(['administer CiviCRM', 'access CiviCRM'], $created['permission']);
41 $this->assertEquals(\CRM_Core_Config::domainID(), $fetched['domain_id']);
42 $this->assertGreaterThan(0, $fetched['weight']);
43 }
44
45 }