Skip to content

Commit

Permalink
Improve the change request template text
Browse files Browse the repository at this point in the history
And store the template (sprintf format) in a const (not a static var)
  • Loading branch information
MKodde committed May 30, 2024
1 parent 748fce4 commit ad1627e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/Application/Metadata/JsonGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]"', $data['note']);
$this->assertStringContainsString('CHR-5421', $data['note']);
$this->assertStringContainsString('revisionnote', $data['note']);
}

private function createManageEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]" via the SPdashboard', $data['note']);
$this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "[email protected]"', $data['note']);
$this->assertStringContainsString('CHR-421', $data['note']);
$this->assertStringContainsString('revisionnote', $data['note']);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/unit/Application/Metadata/OidcngJsonGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]" via the SPdashboard', $data['note']);
$this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "[email protected]', $data['note']);
$this->assertStringContainsString('CHR-7432', $data['note']);
$this->assertStringContainsString('revisionnote', $data['note']);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 "[email protected]" via the SPdashboard', $data['note']);
$this->assertStringContainsString('Change request by user A.F.Th. van der Heijden with email address "[email protected]"', $data['note']);
$this->assertStringContainsString('CHR-1956', $data['note']);
$this->assertStringContainsString('revisionnote', $data['note']);
}

Expand Down

0 comments on commit ad1627e

Please sign in to comment.