Commit | Line | Data |
---|---|---|
3523b615 | 1 | <?php |
2 | /** | |
3 | * +--------------------------------------------------------------------+ | |
4 | * | CiviCRM version 4.7 | | |
5 | * +--------------------------------------------------------------------+ | |
8c9251b3 | 6 | * | Copyright CiviCRM LLC (c) 2004-2018 | |
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 | ||
71 | /** | |
72 | * Test delete function. | |
73 | */ | |
74 | public function testDelete() { | |
75 | $getParams = array( | |
76 | 'return' => 'id', | |
77 | 'options' => array('limit' => 1), | |
78 | ); | |
79 | $result = $this->callAPISuccess('Navigation', 'getvalue', $getParams); | |
80 | $this->callAPISuccess('Navigation', 'delete', array('id' => $result)); | |
81 | $this->callAPIFailure('Navigation', 'getvalue', array('id' => $result)); | |
82 | } | |
83 | ||
84 | } |