feat: provision a teamer from a received application

This commit is contained in:
fromme committed 2026-09-25 14:36:24 +02:00
1 parent d5f4b12f0a
commit b530679658
23 files changed
+2433 -148

No files matched your search

+58
View File
@@ -9,6 +9,7 @@ use App\BusProNet\Model\Hotel;
use App\BusProNet\Model\Pickup;
use App\BusProNet\Model\ProfileResponse;
use App\BusProNet\Model\ProfileUpdateResponse;
use App\BusProNet\Model\RegistrationResponse;
use App\BusProNet\ResponseParser;
use App\BusProNet\ResponseParserException;
use PHPUnit\Framework\TestCase;
@@ -238,6 +239,63 @@ class ResponseParserTest extends TestCase
}
}
/**
* The write answers idadresse + idperson + änderung, not a selection tree - the shape
* createProfileUpdateResponse() reads. It used to be routed to the CRM attribute parser, which
* would have returned an empty response with every role flag false
* (.ddev/plans/buspro-crm-selection-write.md).
*/
public function testParseCrmSelectionWriteResponse(): void
{
$content = '<?xml version="1.0" encoding="utf-8"?><ergebnis><satz typ="KUNDENKONTO"></satz><art>SelektionCRM_Ändern</art><idadresse>141747</idadresse><idperson>224526</idperson><änderung>True</änderung></ergebnis>';
$response = $this->getParserInstance()->parseXmlString(ApiClient::TYPE_CUSTOMER_DATA, $content);
$this->assertInstanceOf(ProfileUpdateResponse::class, $response);
$this->assertSame(141747, $response->getAddressId());
$this->assertSame(224526, $response->getPersonId());
$this->assertTrue($response->isUpdated());
}
public function testParseNewAddressResponse(): void
{
$content = '<?xml version="1.0" encoding="utf-8"?><ergebnis><satz typ="KUNDENKONTO"></satz><art>Adresse_Neu</art><idadresse>141747</idadresse><idperson>224526</idperson><neuanlage>True</neuanlage></ergebnis>';
$response = $this->getParserInstance()->parseXmlString(ApiClient::TYPE_CUSTOMER_DATA, $content);
$this->assertInstanceOf(RegistrationResponse::class, $response);
$this->assertSame(141747, $response->getAddressId());
$this->assertSame(224526, $response->getPersonId());
$this->assertTrue($response->isNewRecord());
}
/**
* BusPro recognised the person and answered with the ids of the address it already held. Not a
* failure and not a duplicate - provisioning carries on with those ids.
*/
public function testParseNewAddressResponseForAnExistingPerson(): void
{
$content = '<?xml version="1.0" encoding="utf-8"?><ergebnis><satz typ="KUNDENKONTO"></satz><art>Adresse_Neu</art><idadresse>141747</idadresse><idperson>224526</idperson><neuanlage>False</neuanlage></ergebnis>';
$response = $this->getParserInstance()->parseXmlString(ApiClient::TYPE_CUSTOMER_DATA, $content);
$this->assertInstanceOf(RegistrationResponse::class, $response);
$this->assertFalse($response->isNewRecord());
}
/**
* Without both ids there is nothing to provision with, and a silent 0 would be stored on the
* account and never match again.
*/
public function testParseNewAddressResponseWithoutIdsFails(): void
{
$content = '<?xml version="1.0" encoding="utf-8"?><ergebnis><satz typ="KUNDENKONTO"></satz><art>Adresse_Neu</art><neuanlage>True</neuanlage></ergebnis>';
$this->expectException(ResponseParserException::class);
$this->getParserInstance()->parseXmlString(ApiClient::TYPE_CUSTOMER_DATA, $content);
}
private function loadFixture(string $filename): string
{
return file_get_contents(__DIR__.'/../Resources/'.$filename);