refactor: split buspro ApiClient into domain clients

This commit is contained in:
fromme committed 2026-10-02 13:55:30 +02:00
1 parent 0a55544ca8
commit b755a6f43e
52 files changed
+805 -695

No files matched your search

@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Tests\BusProNet\XmlParser;
use App\BusProNet\ApiClient;
use App\BusProNet\Exception\ResponseParserException;
use App\BusProNet\MessageType;
use App\BusProNet\XmlParser\ApiResponseParser;
use App\BusProNet\XmlParser\TravelParser;
use PHPUnit\Framework\TestCase;
@@ -23,7 +23,7 @@ class ApiResponseParserFailureTest extends TestCase
$this->expectException(ResponseParserException::class);
$this->expectExceptionMessage('empty response (0 bytes)');
$this->createParser()->parseXmlString(ApiClient::TYPE_NOTIFICATION, '');
$this->createParser()->parseXmlString(MessageType::Notification, '');
}
public function testTruncatedResponseNamesTheLibxmlReason(): void
@@ -31,7 +31,7 @@ class ApiResponseParserFailureTest extends TestCase
$xml = '<?xml version="1.0" encoding="utf-8"?><ergebnis><satz typ="HINWEIS"></satz><hinweis';
try {
$this->createParser()->parseXmlString(ApiClient::TYPE_NOTIFICATION, $xml);
$this->createParser()->parseXmlString(MessageType::Notification, $xml);
$this->fail('Expected a ResponseParserException');
} catch (ResponseParserException $e) {
self::assertStringContainsString('('.strlen($xml).' bytes)', $e->getMessage());
@@ -46,7 +46,7 @@ class ApiResponseParserFailureTest extends TestCase
$this->expectException(ResponseParserException::class);
$this->expectExceptionMessage('Unrecognised BusProNet response type "IRGENDWAS"');
$this->createParser()->parseXmlString(ApiClient::TYPE_NOTIFICATION, $xml);
$this->createParser()->parseXmlString(MessageType::Notification, $xml);
}
public function testUnknownCustomerDataSubtype(): void
@@ -56,7 +56,7 @@ class ApiResponseParserFailureTest extends TestCase
$this->expectException(ResponseParserException::class);
$this->expectExceptionMessage('Unrecognised customer data subtype "Irgendwas"');
$this->createParser()->parseXmlString(ApiClient::TYPE_CUSTOMER_DATA, $xml);
$this->createParser()->parseXmlString(MessageType::CustomerData, $xml);
}
public function testDiagnosingDoesNotLeakLibxmlErrorState(): void
@@ -65,7 +65,7 @@ class ApiResponseParserFailureTest extends TestCase
try {
try {
$this->createParser()->parseXmlString(ApiClient::TYPE_NOTIFICATION, '<ergebnis');
$this->createParser()->parseXmlString(MessageType::Notification, '<ergebnis');
} catch (ResponseParserException) {
}