Commit | Line | Data |
---|---|---|
3523b615 | 1 | <?php |
7d61e75f TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
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 | +--------------------------------------------------------------------+ | |
3523b615 | 10 | */ |
11 | ||
3523b615 | 12 | /** |
13 | * Class api_v3_NavigationTest | |
acb109b7 | 14 | * @group headless |
3523b615 | 15 | */ |
16 | class api_v3_NavigationTest extends CiviUnitTestCase { | |
17 | protected $_apiversion = 3; | |
18 | protected $_params; | |
19 | ||
20 | protected $_entity = 'Navigation'; | |
21 | ||
22 | /** | |
23 | * Test get function. | |
2d932085 CW |
24 | * @param int $version |
25 | * @dataProvider versionThreeAndFour | |
3523b615 | 26 | */ |
2d932085 CW |
27 | public function testGet($version) { |
28 | $this->_apiversion = $version; | |
9099cab3 | 29 | $this->callAPISuccess($this->_entity, 'getsingle', ['label' => 'Manage Groups', 'domain_id' => 1]); |
3523b615 | 30 | } |
31 | ||
e2c44ec0 AH |
32 | /** |
33 | * Test get specifying parent | |
2d932085 | 34 | * FIXME: Api4 |
e2c44ec0 AH |
35 | */ |
36 | public function testGetByParent() { | |
37 | // get by name | |
9099cab3 | 38 | $this->callAPISuccess($this->_entity, 'get', ['parentID' => 'Administer', 'domain_id' => 1]); |
e2c44ec0 | 39 | |
9099cab3 | 40 | $params = [ |
e2c44ec0 AH |
41 | 'name' => 'Administer', |
42 | 'domain_id' => 1, | |
43 | 'return' => 'id', | |
9099cab3 | 44 | ]; |
e2c44ec0 AH |
45 | $adminId = $this->callAPISuccess($this->_entity, 'getvalue', $params); |
46 | ||
9099cab3 | 47 | $this->callAPISuccess($this->_entity, 'get', ['parentID' => $adminId, 'domain_id' => 1]); |
e2c44ec0 AH |
48 | } |
49 | ||
3523b615 | 50 | /** |
51 | * Test create function. | |
2d932085 CW |
52 | * @param int $version |
53 | * @dataProvider versionThreeAndFour | |
3523b615 | 54 | */ |
2d932085 CW |
55 | public function testCreate($version) { |
56 | $this->_apiversion = $version; | |
9099cab3 | 57 | $params = ['label' => 'Feed the Goats', 'domain_id' => 1]; |
3523b615 | 58 | $result = $this->callAPISuccess($this->_entity, 'create', $params); |
59 | $this->getAndCheck($params, $result['id'], $this->_entity, TRUE); | |
60 | } | |
61 | ||
91978228 CW |
62 | /** |
63 | * Test create function. | |
2d932085 CW |
64 | * @param int $version |
65 | * @dataProvider versionThreeAndFour | |
91978228 | 66 | */ |
2d932085 CW |
67 | public function testDefaultDomain($version) { |
68 | $this->_apiversion = $version; | |
9099cab3 | 69 | $params = ['label' => 'Herd the Cats']; |
91978228 CW |
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); | |
74 | } | |
75 | ||
3523b615 | 76 | /** |
77 | * Test delete function. | |
2d932085 CW |
78 | * @param int $version |
79 | * @dataProvider versionThreeAndFour | |
3523b615 | 80 | */ |
2d932085 CW |
81 | public function testDelete($version) { |
82 | $this->_apiversion = $version; | |
9099cab3 | 83 | $getParams = [ |
3523b615 | 84 | 'return' => 'id', |
9099cab3 CW |
85 | 'options' => ['limit' => 1], |
86 | ]; | |
3523b615 | 87 | $result = $this->callAPISuccess('Navigation', 'getvalue', $getParams); |
9099cab3 CW |
88 | $this->callAPISuccess('Navigation', 'delete', ['id' => $result]); |
89 | $this->callAPIFailure('Navigation', 'getvalue', ['id' => $result]); | |
3523b615 | 90 | } |
91 | ||
92 | } |