3 * +--------------------------------------------------------------------+
4 * | CiviCRM version 5 |
5 * +--------------------------------------------------------------------+
6 * | Copyright CiviCRM LLC (c) 2004-2019 |
7 * +--------------------------------------------------------------------+
8 * | This file is a part of CiviCRM. |
10 * | CiviCRM is free software; you can copy, modify, and distribute it |
11 * | under the terms of the GNU Affero General Public License |
12 * | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 * | CiviCRM is distributed in the hope that it will be useful, but |
15 * | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 * | See the GNU Affero General Public License for more details. |
19 * | You should have received a copy of the GNU Affero General Public |
20 * | License and the CiviCRM Licensing Exception along |
21 * | with this program; if not, contact CiviCRM LLC |
22 * | at info[AT]civicrm[DOT]org. If you have questions about the |
23 * | GNU Affero General Public License or the licensing of CiviCRM, |
24 * | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 * +--------------------------------------------------------------------+
29 * Class api_v3_NavigationTest
32 class api_v3_NavigationTest
extends CiviUnitTestCase
{
33 protected $_apiversion = 3;
36 protected $_entity = 'Navigation';
41 * @dataProvider versionThreeAndFour
43 public function testGet($version) {
44 $this->_apiversion
= $version;
45 $this->callAPISuccess($this->_entity
, 'getsingle', ['label' => 'Manage Groups', 'domain_id' => 1]);
49 * Test get specifying parent
52 public function testGetByParent() {
54 $this->callAPISuccess($this->_entity
, 'get', ['parentID' => 'Administer', 'domain_id' => 1]);
57 'name' => 'Administer',
61 $adminId = $this->callAPISuccess($this->_entity
, 'getvalue', $params);
63 $this->callAPISuccess($this->_entity
, 'get', ['parentID' => $adminId, 'domain_id' => 1]);
67 * Test create function.
69 * @dataProvider versionThreeAndFour
71 public function testCreate($version) {
72 $this->_apiversion
= $version;
73 $params = ['label' => 'Feed the Goats', 'domain_id' => 1];
74 $result = $this->callAPISuccess($this->_entity
, 'create', $params);
75 $this->getAndCheck($params, $result['id'], $this->_entity
, TRUE);
79 * Test create function.
81 * @dataProvider versionThreeAndFour
83 public function testDefaultDomain($version) {
84 $this->_apiversion
= $version;
85 $params = ['label' => 'Herd the Cats'];
86 $result = $this->callAPISuccess($this->_entity
, 'create', $params);
87 // Check domain_id has been set per default
88 $params['domain_id'] = CRM_Core_Config
::domainID();
89 $this->getAndCheck($params, $result['id'], $this->_entity
, TRUE);
93 * Test delete function.
95 * @dataProvider versionThreeAndFour
97 public function testDelete($version) {
98 $this->_apiversion
= $version;
101 'options' => ['limit' => 1],
103 $result = $this->callAPISuccess('Navigation', 'getvalue', $getParams);
104 $this->callAPISuccess('Navigation', 'delete', ['id' => $result]);
105 $this->callAPIFailure('Navigation', 'getvalue', ['id' => $result]);