Commit | Line | Data |
---|---|---|
cc222cb6 TO |
1 | <?php |
2 | ||
aba1cd8b EM |
3 | /** |
4 | * Class CRM_Core_Permission_JoomlaTest | |
acb109b7 | 5 | * @group headless |
aba1cd8b | 6 | */ |
cc222cb6 TO |
7 | class CRM_Core_Permission_JoomlaTest extends CiviUnitTestCase { |
8 | ||
9 | /** | |
a6c01b45 CW |
10 | * @return array |
11 | * (0 => input to translatePermission, 1 => expected output from translatePermission) | |
cc222cb6 TO |
12 | */ |
13 | public function translateData() { | |
9099cab3 | 14 | $cases = []; |
cc222cb6 | 15 | |
9099cab3 | 16 | $cases[] = ["administer CiviCRM", ["civicrm.administer_civicrm", "com_civicrm"]]; |
cc222cb6 TO |
17 | // TODO $cases[] = array("cms:universal name", "local name"); |
18 | // TODO $cases[] = array("cms:universal name2", "local name2"); | |
9099cab3 CW |
19 | $cases[] = ["cms:unknown universal name", CRM_Core_Permission::ALWAYS_DENY_PERMISSION]; |
20 | $cases[] = [ | |
cc222cb6 | 21 | "Joomla:civicrmplusplus.extragood:com_civicrmplusplus", |
9099cab3 CW |
22 | ["civicrmplusplus.extragood", "com_civicrmplusplus"], |
23 | ]; | |
24 | $cases[] = ["otherruntime:foo", CRM_Core_Permission::ALWAYS_DENY_PERMISSION]; | |
25 | $cases[] = [CRM_Core_Permission::ALWAYS_DENY_PERMISSION, CRM_Core_Permission::ALWAYS_DENY_PERMISSION]; | |
26 | $cases[] = [CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION, CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION]; | |
cc222cb6 TO |
27 | |
28 | return $cases; | |
29 | } | |
30 | ||
31 | /** | |
32 | * @dataProvider translateData | |
e16033b4 TO |
33 | * @param string $input |
34 | * The name of a permission which should be translated. | |
35 | * @param string $expected | |
36 | * The name of an actual permission (based on translation matrix for "runtime"). | |
cc222cb6 TO |
37 | */ |
38 | public function testTranslate($input, $expected) { | |
39 | $perm = new CRM_Core_Permission_Joomla(); | |
40 | $actual = $perm->translateJoomlaPermission($input); | |
41 | $this->assertEquals($expected, $actual); | |
42 | } | |
96025800 | 43 | |
cc222cb6 | 44 | } |