From 4ac147bdc41b8feceaa5c375f35e5ac4baec0d80 Mon Sep 17 00:00:00 2001 From: ccheng Date: Tue, 10 Dec 2024 09:42:07 +0100 Subject: [PATCH] fix(GDPR/test): dip with self service enabled should not be shown --- .../DataIntendedPurposeRecordTest.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/tine20/GDPR/Controller/DataIntendedPurposeRecordTest.php b/tests/tine20/GDPR/Controller/DataIntendedPurposeRecordTest.php index 1032e40566..64554ebb9e 100644 --- a/tests/tine20/GDPR/Controller/DataIntendedPurposeRecordTest.php +++ b/tests/tine20/GDPR/Controller/DataIntendedPurposeRecordTest.php @@ -409,6 +409,27 @@ public function testPublicApiGetManageConsent() $createdContact = Addressbook_Controller_Contact::getInstance()->create($contact); $response = GDPR_Controller_DataIntendedPurposeRecord::getInstance()->publicApiGetManageConsent($createdContact->getId()); $responseData = json_decode($response->getBody(), true); - static::assertEquals(2, sizeof($responseData['allDataIntendedPurposes']), 'expect to find 2 data intended purpose records for this contact'); + $dipCount = $responseData['allDataIntendedPurposes']; + + $filter = Tinebase_Model_Filter_FilterGroup::getFilterForModel(GDPR_Model_DataIntendedPurpose::class, [ + ['field' => GDPR_Model_DataIntendedPurpose::FLD_IS_SELF_SERVICE, 'operator' => 'equals', 'value' => false] + ]); + $allDips = GDPR_Controller_DataIntendedPurpose::getInstance()->search($filter); + $expander = new Tinebase_Record_Expander(GDPR_Model_DataIntendedPurpose::class, [ + Tinebase_Record_Expander::EXPANDER_PROPERTIES => [ + GDPR_Model_DataIntendedPurpose::FLD_NAME => [], + GDPR_Model_DataIntendedPurpose::FLD_DESCRIPTION => [], + ], + ]); + $expander->expand($allDips); + $dataIntendedPurpose = $allDips->getFirstRecord(); + $dataIntendedPurpose[GDPR_Model_DataIntendedPurpose::FLD_IS_SELF_SERVICE] = true; + $dataIntendedPurpose = GDPR_Controller_DataIntendedPurpose::getInstance()->update($dataIntendedPurpose); + + $response = GDPR_Controller_DataIntendedPurposeRecord::getInstance()->publicApiGetManageConsent($createdContact->getId()); + $responseData = json_decode($response->getBody(), true); + $dipCountNew = $responseData['allDataIntendedPurposes']; + + static::assertEquals(count($dipCount), count($dipCountNew) + 1, 'dip with self service enabled should not be shown'); } }