fix: collect hotel codes from every CRM selection group
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Tests\BusProNet\XmlParser;
|
||||
|
||||
use App\BusProNet\Model\CrmAttributes;
|
||||
use App\BusProNet\XmlParser\CrmAttributesResponseParser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DomCrawler\Crawler;
|
||||
@@ -64,15 +65,54 @@ class CrmAttributesResponseParserTest extends TestCase
|
||||
self::assertContains('ROLE_TEAMER', $roles);
|
||||
}
|
||||
|
||||
public function testParseCollectsTheHotelCodesOfEveryHausleitungSelection(): void
|
||||
{
|
||||
$attributes = $this->parse($this->hausleitungXml());
|
||||
|
||||
self::assertSame(['ROLE_HOUSE_MANAGER'], $attributes->roles);
|
||||
self::assertSame(['DKS', 'ASB'], $attributes->hotelCodes);
|
||||
}
|
||||
|
||||
public function testParseAddsTheDefaultHotelCodeForAdmins(): void
|
||||
{
|
||||
$attributes = $this->parse($this->selectionXml(1292, true));
|
||||
|
||||
self::assertSame(['SSL'], $attributes->hotelCodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function parseRoles(string $xmlContent): array
|
||||
{
|
||||
return $this->parse($xmlContent)->roles;
|
||||
}
|
||||
|
||||
private function parse(string $xmlContent): CrmAttributes
|
||||
{
|
||||
$crawler = new Crawler($xmlContent);
|
||||
$resultNode = $crawler->filterXPath('//ergebnis');
|
||||
|
||||
return $this->parser->parse($resultNode)->roles;
|
||||
return $this->parser->parse($resultNode);
|
||||
}
|
||||
|
||||
private function hausleitungXml(): string
|
||||
{
|
||||
// Two groups, so the codes have to survive both closure levels of parse().
|
||||
return '<?xml version="1.0" encoding="utf-8"?>
|
||||
<ergebnis>
|
||||
<satz typ="KUNDENDATEN" />
|
||||
<selektionsmerkmale>
|
||||
<selektionsgruppe id="1" bezeichnung="Rollen">
|
||||
<selektion id="2001" bezeichnung="Hausleitung DKS" aenderbar="0" auswahl="True" />
|
||||
<selektion id="2002" bezeichnung="Hausleitung XYZ" aenderbar="0" auswahl="False" />
|
||||
</selektionsgruppe>
|
||||
<selektionsgruppe id="2" bezeichnung="Häuser">
|
||||
<selektion id="2003" bezeichnung="Hausleitung ASB" aenderbar="0" auswahl="True" />
|
||||
</selektionsgruppe>
|
||||
</selektionsmerkmale>
|
||||
<crmaktionen></crmaktionen>
|
||||
</ergebnis>';
|
||||
}
|
||||
|
||||
private function selectionXml(int $id, bool $selected): string
|
||||
|
||||
Reference in New Issue
Block a user