4 * Class CRM_Core_Permission_BaseTest
7 class CRM_Core_Permission_BaseTest
extends CiviUnitTestCase
{
11 * (0 => input to translatePermission, 1 => expected output from translatePermission)
13 public function translateData() {
16 $cases[] = ["administer CiviCRM", "administer CiviCRM"];
17 $cases[] = ["cms:universal name", "local name"];
18 $cases[] = ["cms:universal name2", "local name2"];
19 $cases[] = ["cms:unknown universal name", CRM_Core_Permission
::ALWAYS_DENY_PERMISSION
];
20 $cases[] = ["myruntime:foo", "foo"];
21 $cases[] = ["otherruntime:foo", CRM_Core_Permission
::ALWAYS_DENY_PERMISSION
];
22 $cases[] = ["otherruntime:foo:bar", CRM_Core_Permission
::ALWAYS_DENY_PERMISSION
];
23 $cases[] = [CRM_Core_Permission
::ALWAYS_ALLOW_PERMISSION
, CRM_Core_Permission
::ALWAYS_ALLOW_PERMISSION
];
29 * @dataProvider translateData
30 * @param string $input
31 * The name of a permission which should be translated.
32 * @param string $expected
33 * The name of an actual permission (based on translation matrix for "runtime").
35 public function testTranslate($input, $expected) {
36 $perm = new CRM_Core_Permission_Base();
37 $actual = $perm->translatePermission($input, "myruntime", [
38 'universal name' => 'local name',
39 'universal name2' => 'local name2',
42 $this->assertEquals($expected, $actual);