feat: align role assignment logic with myep-team
This commit is contained in:
@@ -11,11 +11,17 @@ use Symfony\Component\DomCrawler\Crawler;
|
||||
|
||||
class CrmAttributesResponseParserTest extends TestCase
|
||||
{
|
||||
private const HOUSE_MANAGER_IDS = [
|
||||
2001 => 'DKS',
|
||||
2002 => 'XYZ',
|
||||
2003 => 'ASB',
|
||||
];
|
||||
|
||||
private CrmAttributesResponseParser $parser;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->parser = new CrmAttributesResponseParser();
|
||||
$this->parser = new CrmAttributesResponseParser(self::HOUSE_MANAGER_IDS);
|
||||
}
|
||||
|
||||
public function testParseAssignsGroupsManagerRoleWhenSelected(): void
|
||||
@@ -38,9 +44,7 @@ class CrmAttributesResponseParserTest extends TestCase
|
||||
{
|
||||
$roles = $this->parseRoles($this->selectionXml(1477, false));
|
||||
|
||||
self::assertNotContains('ROLE_GROUPS_MANAGER', $roles);
|
||||
self::assertNotContains('ROLE_GROUPS_ADMIN', $roles);
|
||||
self::assertSame(['ROLE_CUSTOMER'], $roles);
|
||||
self::assertSame([], $roles, 'the parser reports what BusPro says and adds no fallback');
|
||||
}
|
||||
|
||||
public function testParseStillAssignsExistingAdminManagerTeamerRoles(): void
|
||||
@@ -73,11 +77,25 @@ class CrmAttributesResponseParserTest extends TestCase
|
||||
self::assertSame(['DKS', 'ASB'], $attributes->hotelCodes);
|
||||
}
|
||||
|
||||
public function testParseAddsTheDefaultHotelCodeForAdmins(): void
|
||||
public function testParseIgnoresHausleitungSelectionsThatAreNotMapped(): void
|
||||
{
|
||||
// A house that is deliberately left out of bpn_crm_house_manager_ids claims nothing —
|
||||
// matching is by id, never by label.
|
||||
$parser = new CrmAttributesResponseParser([]);
|
||||
$attributes = $parser->parse((new Crawler($this->hausleitungXml()))->filterXPath('//ergebnis'));
|
||||
|
||||
self::assertSame([], $attributes->roles);
|
||||
self::assertSame([], $attributes->hotelCodes);
|
||||
}
|
||||
|
||||
public function testParseAddsNoDefaultHotelCodeForAdmins(): void
|
||||
{
|
||||
// Hotel codes are synced on every login now, so a default would permanently grant a
|
||||
// house to every administrator.
|
||||
$attributes = $this->parse($this->selectionXml(1292, true));
|
||||
|
||||
self::assertSame(['SSL'], $attributes->hotelCodes);
|
||||
self::assertSame(['ROLE_ADMIN'], $attributes->roles);
|
||||
self::assertSame([], $attributes->hotelCodes);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user