From ad1627edc6c8d3afa1804e3cf978b051b6ea0108 Mon Sep 17 00:00:00 2001 From: Michiel Kodde Date: Tue, 21 May 2024 14:29:38 +0200 Subject: [PATCH] Improve the change request template text And store the template (sprintf format) in a const (not a static var) --- .../Domain/Entity/Entity/ChangeRequestRevisionNote.php | 9 +++++---- tests/unit/Application/Metadata/JsonGeneratorTest.php | 3 +++ .../OauthClientCredentialsClientJsonGeneratorTest.php | 3 ++- .../Application/Metadata/OidcngJsonGeneratorTest.php | 3 ++- .../Metadata/OidcngResourceServerJsonGeneratorTest.php | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Surfnet/ServiceProviderDashboard/Domain/Entity/Entity/ChangeRequestRevisionNote.php b/src/Surfnet/ServiceProviderDashboard/Domain/Entity/Entity/ChangeRequestRevisionNote.php index 639520b80..29f80cc20 100644 --- a/src/Surfnet/ServiceProviderDashboard/Domain/Entity/Entity/ChangeRequestRevisionNote.php +++ b/src/Surfnet/ServiceProviderDashboard/Domain/Entity/Entity/ChangeRequestRevisionNote.php @@ -26,9 +26,10 @@ class ChangeRequestRevisionNote implements Stringable { - private static string $template = - 'Change request by user %s with email address "%s" via the SPdashboard on %s (%s) ' . PHP_EOL . - 'Comment from user: "%s"'; + private const REVISION_NOTE_FORMAT = + 'Change request by user %s with email address "%s"' . PHP_EOL . + 'Via the SPdashboard on %s (%s) ' . PHP_EOL . + 'Comment: "%s"'; public function __construct( private ?string $comments, private string $commonName, @@ -44,7 +45,7 @@ public function __toString(): string $this->comments = 'No comment provided'; } return sprintf( - self::$template, + self::REVISION_NOTE_FORMAT, $this->commonName, $this->emailAddress, $dateTime->format(DateTimeImmutable::ATOM), diff --git a/tests/unit/Application/Metadata/JsonGeneratorTest.php b/tests/unit/Application/Metadata/JsonGeneratorTest.php index ea500cd30..56cad6398 100644 --- a/tests/unit/Application/Metadata/JsonGeneratorTest.php +++ b/tests/unit/Application/Metadata/JsonGeneratorTest.php @@ -496,6 +496,9 @@ public function test_it_builds_an_entity_change_request() $this->assertEquals('saml20_sp', $data['type']); $this->assertIsArray($data['pathUpdates']); $this->assertCount(4, $data['pathUpdates']); + $this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "j.doe@example.com"', $data['note']); + $this->assertStringContainsString('CHR-5421', $data['note']); + $this->assertStringContainsString('revisionnote', $data['note']); } private function createManageEntity( diff --git a/tests/unit/Application/Metadata/OauthClientCredentialsClientJsonGeneratorTest.php b/tests/unit/Application/Metadata/OauthClientCredentialsClientJsonGeneratorTest.php index 399633a27..9d2a776f4 100644 --- a/tests/unit/Application/Metadata/OauthClientCredentialsClientJsonGeneratorTest.php +++ b/tests/unit/Application/Metadata/OauthClientCredentialsClientJsonGeneratorTest.php @@ -73,7 +73,8 @@ public function test_it_builds_an_entity_change_request() $this->assertEquals('oidc10_rp', $data['type']); $this->assertIsArray($data['pathUpdates']); $this->assertCount(2, $data['pathUpdates']); - $this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "j.doe@example.com" via the SPdashboard', $data['note']); + $this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "j.doe@example.com"', $data['note']); + $this->assertStringContainsString('CHR-421', $data['note']); $this->assertStringContainsString('revisionnote', $data['note']); } diff --git a/tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php b/tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php index 23a939293..3a5d9aefe 100644 --- a/tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php +++ b/tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php @@ -288,7 +288,8 @@ public function test_it_builds_an_entity_change_request() $this->assertEquals('oidc10_rp', $data['type']); $this->assertIsArray($data['pathUpdates']); $this->assertCount(4, $data['pathUpdates']); - $this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "j.doe@example.com" via the SPdashboard', $data['note']); + $this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "j.doe@example.com', $data['note']); + $this->assertStringContainsString('CHR-7432', $data['note']); $this->assertStringContainsString('revisionnote', $data['note']); } diff --git a/tests/unit/Application/Metadata/OidcngResourceServerJsonGeneratorTest.php b/tests/unit/Application/Metadata/OidcngResourceServerJsonGeneratorTest.php index ee10ec23f..b2a3389ef 100644 --- a/tests/unit/Application/Metadata/OidcngResourceServerJsonGeneratorTest.php +++ b/tests/unit/Application/Metadata/OidcngResourceServerJsonGeneratorTest.php @@ -157,7 +157,8 @@ public function test_it_builds_an_entity_change_request() $this->assertEquals('oauth20_rs', $data['type']); $this->assertIsArray($data['pathUpdates']); $this->assertCount(4, $data['pathUpdates']); - $this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "j.doe@example.com" via the SPdashboard', $data['note']); + $this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "j.doe@example.com"', $data['note']); + $this->assertStringContainsString('CHR-1956', $data['note']); $this->assertStringContainsString('revisionnote', $data['note']); }