parser = new PersonalDataParser(); } public function testParseReadsCommunicationOfASinglePerson(): void { $personalData = $this->parse($this->responseXml(['mia@example.com'])); self::assertSame('mia@example.com', $personalData->communication->email); } /** * A BPN address carries its communication entries 1:N, and the e-mail there doubles as a login * identity. The parser only ever surfaces the first entry, so anything writing the parsed model * back to BPN replaces the whole set with that one value. Pinned here because the personal data * form used to do exactly that and locked out the person owning the second entry. */ public function testParseOnlySurfacesTheFirstOfSeveralCommunicationEntries(): void { $personalData = $this->parse($this->responseXml(['mia@example.com', 'tom@example.com'])); self::assertSame('mia@example.com', $personalData->communication->email); } public function testParseLeavesEmailNullWithoutCommunicationEntry(): void { $personalData = $this->parse($this->responseXml([])); self::assertNull($personalData->communication->email); } private function parse(string $xml): \App\BusProNet\Model\PersonalData { return $this->parser->parse(XmlCrawlerFactory::create($xml)); } /** * @param list $emails */ private function responseXml(array $emails): string { $communication = ''; foreach ($emails as $email) { $communication .= sprintf( '%s0170 1234567', $email, ); } return << 4711 815 Mia Muster w d Musterweg 1 12345 Musterstadt D {$communication} XML; } }