Commit | Line | Data |
---|---|---|
3523b615 | 1 | <?php |
2 | /** | |
3 | * +--------------------------------------------------------------------+ | |
2fe49090 | 4 | * | CiviCRM version 5 | |
3523b615 | 5 | * +--------------------------------------------------------------------+ |
6b83d5bd | 6 | * | Copyright CiviCRM LLC (c) 2004-2019 | |
3523b615 | 7 | * +--------------------------------------------------------------------+ |
8 | * | This file is a part of CiviCRM. | | |
9 | * | | | |
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. | | |
13 | * | | | |
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. | | |
18 | * | | | |
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 | * +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
3523b615 | 28 | /** |
29 | * Class api_v3_NavigationTest | |
acb109b7 | 30 | * @group headless |
3523b615 | 31 | */ |
32 | class api_v3_NavigationTest extends CiviUnitTestCase { | |
33 | protected $_apiversion = 3; | |
34 | protected $_params; | |
35 | ||
36 | protected $_entity = 'Navigation'; | |
37 | ||
38 | /** | |
39 | * Test get function. | |
40 | */ | |
41 | public function testGet() { | |
42 | $this->callAPISuccess($this->_entity, 'getsingle', array('label' => 'Manage Groups', 'domain_id' => 1)); | |
43 | } | |
44 | ||
e2c44ec0 AH |
45 | /** |
46 | * Test get specifying parent | |
47 | */ | |
48 | public function testGetByParent() { | |
49 | // get by name | |
50 | $this->callAPISuccess($this->_entity, 'get', array('parentID' => 'Administer', 'domain_id' => 1)); | |
51 | ||
52 | $params = array( | |
53 | 'name' => 'Administer', | |
54 | 'domain_id' => 1, | |
55 | 'return' => 'id', | |
56 | ); | |
57 | $adminId = $this->callAPISuccess($this->_entity, 'getvalue', $params); | |
58 | ||
59 | $this->callAPISuccess($this->_entity, 'get', array('parentID' => $adminId, 'domain_id' => 1)); | |
60 | } | |
61 | ||
3523b615 | 62 | /** |
63 | * Test create function. | |
64 | */ | |
65 | public function testCreate() { | |
66 | $params = array('label' => 'Feed the Goats', 'domain_id' => 1); | |
67 | $result = $this->callAPISuccess($this->_entity, 'create', $params); | |
68 | $this->getAndCheck($params, $result['id'], $this->_entity, TRUE); | |
69 | } | |
70 | ||
91978228 CW |
71 | /** |
72 | * Test create function. | |
73 | */ | |
74 | public function testDefaultDomain() { | |
75 | $params = array('label' => 'Herd the Cats'); | |
76 | $result = $this->callAPISuccess($this->_entity, 'create', $params); | |
77 | // Check domain_id has been set per default | |
78 | $params['domain_id'] = CRM_Core_Config::domainID(); | |
79 | $this->getAndCheck($params, $result['id'], $this->_entity, TRUE); | |
80 | } | |
81 | ||
3523b615 | 82 | /** |
83 | * Test delete function. | |
84 | */ | |
85 | public function testDelete() { | |
86 | $getParams = array( | |
87 | 'return' => 'id', | |
88 | 'options' => array('limit' => 1), | |
89 | ); | |
90 | $result = $this->callAPISuccess('Navigation', 'getvalue', $getParams); | |
91 | $this->callAPISuccess('Navigation', 'delete', array('id' => $result)); | |
92 | $this->callAPIFailure('Navigation', 'getvalue', array('id' => $result)); | |
93 | } | |
94 | ||
95 | } |