Merge pull request #14667 from hoegrammer/master
[civicrm-core.git] / CRM / Core / Permission / UnitTests.php
1 <?php
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 * $Id$
17 *
18 */
19
20 /**
21 *
22 */
23 class CRM_Core_Permission_UnitTests extends CRM_Core_Permission_Base {
24
25 /**
26 * permission mapping to stub check() calls
27 * @var array
28 */
29 public $permissions = NULL;
30
31 /**
32 * Given a permission string, check for access requirements
33 *
34 * @param string $str
35 * The permission to check.
36 * @param int $userId
37 *
38 * @return bool
39 * true if yes, else false
40 */
41 public function check($str, $userId = NULL) {
42 if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
43 return FALSE;
44 }
45 if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
46 return TRUE;
47 }
48
49 // return the stubbed permission (defaulting to true if the array is missing)
50 return is_array($this->permissions) ? in_array($str, $this->permissions) : TRUE;
51 }
52
53 /**
54 * Get the permissioned where clause for the user.
55 *
56 * @param int $type
57 * The type of permission needed.
58 * @param array $tables
59 * (reference ) add the tables that are needed for the select clause.
60 * @param array $whereTables
61 * (reference ) add the tables that are needed for the where clause.
62 *
63 * @return string
64 * the group where clause for this user
65 */
66 public function whereClause($type, &$tables, &$whereTables) {
67 return '( 1 )';
68 }
69
70 }