From 1028f75e97d4c3e70a7e675bfa8cd215a4b36417 Mon Sep 17 00:00:00 2001 From: eileenmcnaughton Date: Fri, 21 Aug 2015 01:38:09 +0000 Subject: [PATCH] CRM-16512 add test to demonstrate breakage from code committed on ticket --- tests/phpunit/api/v3/ACLPermissionTest.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index 0d81bbe6e6..4624b4a393 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -82,6 +82,22 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { $this->assertEquals(0, $result['count']); } + /** + * Function tests that an empty where hook returns no results with edit my contact. + * + * CRM-16512 caused contacts with Edit my contact to be able to view all records. + */ + public function testContactGetNoResultsHookWithEditMyContact() { + $this->createLoggedInUser(); + $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults')); + CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM', 'view my contact'); + $result = $this->callAPISuccess('contact', 'get', array( + 'check_permissions' => 1, + 'return' => 'display_name', + )); + $this->assertEquals(0, $result['count']); + } + /** * Function tests all results are returned. */ @@ -122,7 +138,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { } /** - * Confirm that without check permissions we still get 2 contacts returned + * Confirm that without check permissions we still get 2 contacts returned. */ public function testContactGetHookLimitingHookDontCheck() { $result = $this->callAPISuccess('contact', 'get', array( @@ -299,7 +315,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { /** * @dataProvider entities * Function tests that an empty where hook returns no results - * @param $entity + * @param string $entity * @throws \PHPUnit_Framework_IncompleteTestError */ public function testEntityGetNoResultsHook($entity) { -- 2.25.1