INFRA-132 - Trailing commas for multiline arrays
[civicrm-core.git] / tests / phpunit / CRM / Core / Permission / BaseTest.php
CommitLineData
085823c1
TO
1<?php
2
3require_once 'CiviTest/CiviUnitTestCase.php';
4
aba1cd8b
EM
5/**
6 * Class CRM_Core_Permission_BaseTest
7 */
085823c1
TO
8class CRM_Core_Permission_BaseTest extends CiviUnitTestCase {
9
10 /**
11 * @return array (0 => input to translatePermission, 1 => expected output from translatePermission)
12 */
13 public function translateData() {
14 $cases = array();
15
16 $cases[] = array("administer CiviCRM", "administer CiviCRM");
17 $cases[] = array("cms:universal name", "local name");
18 $cases[] = array("cms:universal name2", "local name2");
19 $cases[] = array("cms:unknown universal name", CRM_Core_Permission::ALWAYS_DENY_PERMISSION);
20 $cases[] = array("myruntime:foo", "foo");
21 $cases[] = array("otherruntime:foo", CRM_Core_Permission::ALWAYS_DENY_PERMISSION);
22 $cases[] = array("otherruntime:foo:bar", CRM_Core_Permission::ALWAYS_DENY_PERMISSION);
23 $cases[] = array(CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION, CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION);
24
25 return $cases;
26 }
27
28 /**
29 * @dataProvider translateData
e16033b4
TO
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").
085823c1
TO
34 */
35 public function testTranslate($input, $expected) {
36 $perm = new CRM_Core_Permission_Base();
37 $actual = $perm->translatePermission($input, "myruntime", array(
38 'universal name' => 'local name',
39 'universal name2' => 'local name2',
40 'gunk' => 'gunky',
41 ));
42 $this->assertEquals($expected, $actual);
43 }
44}