forked from civicrm/civicrm-core
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test, enotice fixes, handling for permissions key for Member_Tasks
Alternate potential approach to the enotice portion of civicrm#20940 This approach adds support for permissions using a syntax like https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_summaryActions/ and would potentially standardise that onto the search_tasks hook https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_searchTasks/ - it's not quite clear what the search hooks supports - https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_searchKitTasks/
- Loading branch information
1 parent
96adc46
commit 80bc1b7
Showing
3 changed files
with
138 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?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 CRM_Member_BAO_MembershipTest | ||
* @group headless | ||
*/ | ||
class CRM_Member_TaskTest extends CiviUnitTestCase { | ||
|
||
use Civi\Test\ACLPermissionTrait; | ||
|
||
/** | ||
* Test tiles are correctly filtered on permissions. | ||
*/ | ||
public function testPermissionedTiles(): void { | ||
$this->createLoggedInUser(); | ||
|
||
CRM_Member_Task::tasks(); | ||
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['view memberships']; | ||
$tasks = CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::VIEW); | ||
$this->assertEquals([8 => 'Export members', 5 => 'Print selected rows'], $tasks); | ||
|
||
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['delete in CiviMember', 'view memberships']; | ||
$tasks = CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::VIEW); | ||
$this->assertEquals([8 => 'Export members', 5 => 'Print selected rows', 4 => 'Delete memberships'], $tasks); | ||
|
||
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['edit memberships']; | ||
$tasks = CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::VIEW); | ||
$this->assertEquals([8 => 'Export members', 5 => 'Print selected rows'], $tasks); | ||
|
||
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['edit memberships']; | ||
$tasks = CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::EDIT); | ||
$this->assertEquals([ | ||
8 => 'Export members', | ||
5 => 'Print selected rows', | ||
9 => 'Email - send now (to 50 or less)', | ||
201 => 'Mailing labels - print', | ||
3 => 'Print/merge document for memberships', | ||
6 => 'Update multiple memberships', | ||
], $tasks); | ||
|
||
\CRM_Core_Config::singleton()->userPermissionClass->permissions = ['edit memberships', 'delete in CiviMember', 'edit groups']; | ||
$tasks = CRM_Member_Task::permissionedTaskTitles(CRM_Core_Permission::EDIT); | ||
$this->assertEquals([ | ||
8 => 'Export members', | ||
5 => 'Print selected rows', | ||
9 => 'Email - send now (to 50 or less)', | ||
201 => 'Mailing labels - print', | ||
3 => 'Print/merge document for memberships', | ||
6 => 'Update multiple memberships', | ||
4 => 'Delete memberships', | ||
12 => 'Group - create smart group', | ||
], $tasks); | ||
} | ||
|
||
} |