expectException(ResponseParserException::class); $this->expectExceptionMessage('empty response (0 bytes)'); $this->createParser()->parseXmlString(MessageType::Notification, ''); } public function testTruncatedResponseNamesTheLibxmlReason(): void { $xml = 'createParser()->parseXmlString(MessageType::Notification, $xml); $this->fail('Expected a ResponseParserException'); } catch (ResponseParserException $e) { self::assertStringContainsString('('.strlen($xml).' bytes)', $e->getMessage()); self::assertStringContainsString('line 1', $e->getMessage()); } } public function testWellFormedResponseOfAnUnknownType(): void { $xml = ''; $this->expectException(ResponseParserException::class); $this->expectExceptionMessage('Unrecognised BusProNet response type "IRGENDWAS"'); $this->createParser()->parseXmlString(MessageType::Notification, $xml); } public function testUnknownCustomerDataSubtype(): void { $xml = 'Irgendwas'; $this->expectException(ResponseParserException::class); $this->expectExceptionMessage('Unrecognised customer data subtype "Irgendwas"'); $this->createParser()->parseXmlString(MessageType::CustomerData, $xml); } public function testDiagnosingDoesNotLeakLibxmlErrorState(): void { $previous = libxml_use_internal_errors(false); try { try { $this->createParser()->parseXmlString(MessageType::Notification, 'createStub(TravelParser::class)); } }