From 03d53ecbc5bf9f3b749cf36834af6fd0418ef254 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 12 Jan 2023 15:19:50 +1300 Subject: [PATCH] Php 8.2 - undefined property fix in test class --- tests/phpunit/api/v3/ACLPermissionTest.php | 43 +++++++++++++--------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/tests/phpunit/api/v3/ACLPermissionTest.php b/tests/phpunit/api/v3/ACLPermissionTest.php index dbd1c85a87..076f8dc024 100644 --- a/tests/phpunit/api/v3/ACLPermissionTest.php +++ b/tests/phpunit/api/v3/ACLPermissionTest.php @@ -38,6 +38,16 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { public $DBResetRequired = FALSE; protected $_entity; + /** + * @var int + */ + protected $_permissionedGroup; + + /** + * @var int + */ + protected $_permissionedDisabledGroup; + public function setUp(): void { parent::setUp(); CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_Pledge', [], 1, 0); @@ -46,7 +56,6 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { } /** - * (non-PHPdoc) * @see CiviUnitTestCase::tearDown() */ public function tearDown(): void { @@ -382,7 +391,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { $this, 'aclWhereOnlySecond', ]); - $fullresult = $this->callAPISuccess('contact', 'get', [ + $fullResult = $this->callAPISuccess('contact', 'get', [ 'sequential' => 1, ]); //return doesn't work for all keys - can't fix that here so let's skip ... @@ -399,7 +408,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { 'worldregion_id', 'world_region', ]; - $expectedReturnElements = array_diff(array_keys($fullresult['values'][0]), $elementsReturnDoesntSupport); + $expectedReturnElements = array_diff(array_keys($fullResult['values'][0]), $elementsReturnDoesntSupport); $result = $this->callAPISuccess('contact', 'get', [ 'check_permissions' => 1, 'return' => $expectedReturnElements, @@ -862,7 +871,7 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { * @dataProvider versionThreeAndFour * @throws \CRM_Core_Exception */ - public function testGetActivityACLSourceContactDeleted($version): void { + public function testGetActivityACLSourceContactDeleted(int $version): void { $this->_apiversion = $version; $this->setPermissions(['access CiviCRM', 'delete contacts']); $activity = $this->activityCreate(); @@ -1124,34 +1133,34 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase { $this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereHookAllResults']); // Without "access deleted contacts" we won't see C2 - $vals = CustomValue::get($group)->setDebug(TRUE)->execute(); - $this->assertCount(1, $vals); - $this->assertEquals($c1, $vals[0]['entity_id']); + $customValues = CustomValue::get($group)->setDebug(TRUE)->execute(); + $this->assertCount(1, $customValues); + $this->assertEquals($c1, $customValues[0]['entity_id']); $this->setPermissions(['access CiviCRM', 'access deleted contacts', 'view debug output', 'access all custom data']); $this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereHookAllResults']); $this->cleanupCachedPermissions(); - $vals = CustomValue::get($group)->execute(); - $this->assertCount(2, $vals); + $customValues = CustomValue::get($group)->execute(); + $this->assertCount(2, $customValues); $this->allowedContactId = $c2; $this->hookClass->setHook('civicrm_aclWhereClause', [$this, 'aclWhereOnlyOne']); $this->cleanupCachedPermissions(); - $vals = CustomValue::get($group)->addSelect('*', 'contact.first_name')->execute(); - $this->assertCount(1, $vals); - $this->assertEquals($c2, $vals[0]['entity_id']); - $this->assertEquals('C2', $vals[0]['contact.first_name']); + $customValues = CustomValue::get($group)->addSelect('*', 'contact.first_name')->execute(); + $this->assertCount(1, $customValues); + $this->assertEquals($c2, $customValues[0]['entity_id']); + $this->assertEquals('C2', $customValues[0]['contact.first_name']); - $vals = Contact::get() + $customValues = Contact::get() ->addJoin('Custom_' . $group . ' AS cf') ->addSelect('first_name', 'cf.' . $textField) ->addWhere('is_deleted', '=', TRUE) ->execute(); - $this->assertCount(1, $vals); - $this->assertEquals('C2', $vals[0]['first_name']); - $this->assertEquals('2', $vals[0]['cf.' . $textField]); + $this->assertCount(1, $customValues); + $this->assertEquals('C2', $customValues[0]['first_name']); + $this->assertEquals('2', $customValues[0]['cf.' . $textField]); } } -- 2.25.1