-
-
Notifications
You must be signed in to change notification settings - Fork 827
/
Copy pathNavigationTest.php
92 lines (82 loc) · 2.79 KB
/
NavigationTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
* Class api_v3_NavigationTest
* @group headless
*/
class api_v3_NavigationTest extends CiviUnitTestCase {
protected $_apiversion = 3;
protected $_params;
protected $_entity = 'Navigation';
/**
* Test get function.
* @param int $version
* @dataProvider versionThreeAndFour
*/
public function testGet($version) {
$this->_apiversion = $version;
$this->callAPISuccess($this->_entity, 'getsingle', ['label' => 'Manage Groups', 'domain_id' => 1]);
}
/**
* Test get specifying parent
* FIXME: Api4
*/
public function testGetByParent(): void {
// get by name
$this->callAPISuccess($this->_entity, 'get', ['parentID' => 'Administer', 'domain_id' => 1]);
$params = [
'name' => 'Administer',
'domain_id' => 1,
'return' => 'id',
];
$adminId = $this->callAPISuccess($this->_entity, 'getvalue', $params);
$this->callAPISuccess($this->_entity, 'get', ['parentID' => $adminId, 'domain_id' => 1]);
}
/**
* Test create function.
* @param int $version
* @dataProvider versionThreeAndFour
*/
public function testCreate($version) {
$this->_apiversion = $version;
$params = ['label' => 'Feed the Goats', 'domain_id' => 1];
$result = $this->callAPISuccess($this->_entity, 'create', $params);
$this->getAndCheck($params, $result['id'], $this->_entity, TRUE);
}
/**
* Test create function.
* @param int $version
* @dataProvider versionThreeAndFour
*/
public function testDefaultDomain($version) {
$this->_apiversion = $version;
$params = ['label' => 'Herd the Cats'];
$result = $this->callAPISuccess($this->_entity, 'create', $params);
// Check domain_id has been set per default
$params['domain_id'] = CRM_Core_Config::domainID();
$this->getAndCheck($params, $result['id'], $this->_entity, TRUE);
}
/**
* Test delete function.
* @param int $version
* @dataProvider versionThreeAndFour
*/
public function testDelete($version) {
$this->_apiversion = $version;
$getParams = [
'return' => 'id',
'options' => ['limit' => 1],
];
$result = $this->callAPISuccess('Navigation', 'getvalue', $getParams);
$this->callAPISuccess('Navigation', 'delete', ['id' => $result]);
$this->callAPIFailure('Navigation', 'getvalue', ['id' => $result]);
}
}