Skip to content

Commit

Permalink
Invite roles: the description field may be missing (#306)
Browse files Browse the repository at this point in the history
Use the name instead when this happens

Closes: #305
  • Loading branch information
thijskh authored Oct 4, 2024
1 parent fdf6d23 commit 24f1ac5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ci/qa/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ parameters:

-
message: "#^Cannot access offset 'name' on mixed\\.$#"
count: 1
count: 2
path: ../../src/OpenConext/InviteApiClientBundle/Tests/Value/InviteRoleListFactoryTest.php

-
message: "#^Cannot access offset mixed on mixed\\.$#"
count: 2
count: 3
path: ../../src/OpenConext/InviteApiClientBundle/Tests/Value/InviteRoleListFactoryTest.php

-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testCreateList(string $jsonData, int $expectedCount): void

foreach ($roles as $index => $role) {
$this->assertEquals($data[$index]['name'], $role->getName());
$this->assertEquals($data[$index]['description'], $role->getDescription());
$this->assertEquals($data[$index]['description'] ?? $data[$index]['name'], $role->getDescription());
}
}

Expand Down Expand Up @@ -86,6 +86,24 @@ public function validDataProvider(): array
]',
2
],
'without description' => [
'[
{
"name": "Admin Role",
"applications": [
{
"landingPage": "https://admin.example.com",
"nameEn": "Admin Panel",
"nameNl": "Beheerderspaneel",
"organisationEn": "Example Org",
"organisationNl": "Voorbeeldorganisatie",
"logo": "https://example.com/logo.png"
}
]
}
]',
1
],
'without applications section' => [
'[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ private static function createInviteRole(
if (array_key_exists('applications', $data)) {
$applications = $data['applications'];
}
return new InviteRole($data['name'], $data['description'], $applications);
return new InviteRole($data['name'], $data['description'] ?? $data['name'], $applications);
}
}

0 comments on commit 24f1ac5

Please sign in to comment.