3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class api_v3_NavigationTest
16 class api_v3_NavigationTest
extends CiviUnitTestCase
{
17 protected $_apiversion = 3;
20 protected $_entity = 'Navigation';
25 * @dataProvider versionThreeAndFour
27 public function testGet($version) {
28 $this->_apiversion
= $version;
29 $this->callAPISuccess($this->_entity
, 'getsingle', ['label' => 'Manage Groups', 'domain_id' => 1]);
33 * Test get specifying parent
36 public function testGetByParent() {
38 $this->callAPISuccess($this->_entity
, 'get', ['parentID' => 'Administer', 'domain_id' => 1]);
41 'name' => 'Administer',
45 $adminId = $this->callAPISuccess($this->_entity
, 'getvalue', $params);
47 $this->callAPISuccess($this->_entity
, 'get', ['parentID' => $adminId, 'domain_id' => 1]);
51 * Test create function.
53 * @dataProvider versionThreeAndFour
55 public function testCreate($version) {
56 $this->_apiversion
= $version;
57 $params = ['label' => 'Feed the Goats', 'domain_id' => 1];
58 $result = $this->callAPISuccess($this->_entity
, 'create', $params);
59 $this->getAndCheck($params, $result['id'], $this->_entity
, TRUE);
63 * Test create function.
65 * @dataProvider versionThreeAndFour
67 public function testDefaultDomain($version) {
68 $this->_apiversion
= $version;
69 $params = ['label' => 'Herd the Cats'];
70 $result = $this->callAPISuccess($this->_entity
, 'create', $params);
71 // Check domain_id has been set per default
72 $params['domain_id'] = CRM_Core_Config
::domainID();
73 $this->getAndCheck($params, $result['id'], $this->_entity
, TRUE);
77 * Test delete function.
79 * @dataProvider versionThreeAndFour
81 public function testDelete($version) {
82 $this->_apiversion
= $version;
85 'options' => ['limit' => 1],
87 $result = $this->callAPISuccess('Navigation', 'getvalue', $getParams);
88 $this->callAPISuccess('Navigation', 'delete', ['id' => $result]);
89 $this->callAPIFailure('Navigation', 'getvalue', ['id' => $result]);