mirror of
https://github.com/wearepixel/laravel-quickbooks.git
synced 2026-11-14 14:01:46 +00:00
fix: switch DataService to JSON serialization to survive QuickBooks schema drift
The SDK's XML deserializer reflects on declared properties of its Data classes and throws a RuntimeException when QuickBooks returns a field the installed SDK version doesn't define yet (e.g. the new invoice AllowOnlinePayPalPayment field), breaking every invoice create/update. The JSON path builds instances from the class's own known properties and silently ignores unrecognised response fields instead, so it tolerates QuickBooks adding fields ahead of the SDK.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use QuickBooksOnline\API\Core\Http\Serialization\SerializationFormat;
|
||||
use QuickBooksOnline\API\DataService\DataService;
|
||||
use QuickBooksOnline\API\Exception\ServiceException;
|
||||
use Wearepixel\QuickBooks\Client;
|
||||
@@ -130,6 +131,27 @@
|
||||
it('returns a report service using the data service')
|
||||
->skip('Once we figure out how to test around the static DataService::Configure');
|
||||
|
||||
it('configures the data service to use JSON serialization so unrecognised QuickBooks response fields do not throw', function () {
|
||||
$this->token_mock
|
||||
->shouldReceive('getAttribute')
|
||||
->twice()
|
||||
->with('hasValidAccessToken')
|
||||
->andReturnFalse();
|
||||
|
||||
$this->token_mock
|
||||
->shouldReceive('getAttribute')
|
||||
->once()
|
||||
->with('hasValidRefreshToken')
|
||||
->andReturnFalse();
|
||||
|
||||
$format = $this->client
|
||||
->getDataService()
|
||||
->getServiceContext()
|
||||
->IppConfiguration->Message->Request->SerializationFormat;
|
||||
|
||||
expect($format)->toBe(SerializationFormat::Json);
|
||||
});
|
||||
|
||||
it('has logging off by default')
|
||||
->skip('Have to figure out how to test this with the new code in 5.x');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user