fix contracts support
This commit is contained in:
parent
82f110d0d0
commit
4de6a3b798
@ -24,8 +24,7 @@ use Pnz\JsonException\Json;
|
|||||||
*/
|
*/
|
||||||
class ArraySupportDecorator implements SerializerInterface
|
class ArraySupportDecorator implements SerializerInterface
|
||||||
{
|
{
|
||||||
/** @var \Liip\Serializer\SerializerInterface */
|
private SerializerInterface $serializer;
|
||||||
private $serializer;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ArraySupportDecorator constructor.
|
* ArraySupportDecorator constructor.
|
||||||
@ -69,7 +68,7 @@ class ArraySupportDecorator implements SerializerInterface
|
|||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function deserialize(string $data, string $type, string $format, ?Context $context = null)
|
public function deserialize(string $data, string $type, string $format, ?Context $context = null): mixed
|
||||||
{
|
{
|
||||||
if ('json' !== $format) {
|
if ('json' !== $format) {
|
||||||
throw new UnsupportedFormatException('Liip serializer only supports JSON for now');
|
throw new UnsupportedFormatException('Liip serializer only supports JSON for now');
|
||||||
@ -109,7 +108,7 @@ class ArraySupportDecorator implements SerializerInterface
|
|||||||
*
|
*
|
||||||
* @return array<int|string, mixed>|object
|
* @return array<int|string, mixed>|object
|
||||||
*/
|
*/
|
||||||
public function fromArray(array $data, string $type, ?Context $context = null)
|
public function fromArray(array $data, string $type, ?Context $context = null): mixed
|
||||||
{
|
{
|
||||||
if (static::isArrayType($type)) {
|
if (static::isArrayType($type)) {
|
||||||
return $this->decodeArray($data, $type, $context);
|
return $this->decodeArray($data, $type, $context);
|
||||||
|
@ -18,7 +18,10 @@ if (!is_file($autoloadFile = __DIR__ . '/../vendor/autoload.php')) {
|
|||||||
$loader = require $autoloadFile;
|
$loader = require $autoloadFile;
|
||||||
$loader->add('RetailCrm\\TestUtils', __DIR__ . '/tests/utils');
|
$loader->add('RetailCrm\\TestUtils', __DIR__ . '/tests/utils');
|
||||||
$loader->add('RetailCrm\\Tests', __DIR__ . '/src');
|
$loader->add('RetailCrm\\Tests', __DIR__ . '/src');
|
||||||
|
|
||||||
|
if (method_exists(AnnotationRegistry::class, 'registerLoader')) {
|
||||||
AnnotationRegistry::registerLoader('class_exists');
|
AnnotationRegistry::registerLoader('class_exists');
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists(__DIR__ . '/../.env')) {
|
if (file_exists(__DIR__ . '/../.env')) {
|
||||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
|
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
|
||||||
|
@ -2698,14 +2698,15 @@ EOF;
|
|||||||
$response = $client->customers->get(4770, $request);
|
$response = $client->customers->get(4770, $request);
|
||||||
|
|
||||||
self::assertModelsCallback($json, $response, static function ($expected, $actual) {
|
self::assertModelsCallback($json, $response, static function ($expected, $actual) {
|
||||||
$actualTags = $actual['customer']['tags'];
|
// TODO: Check if it's really necessary to do tag conversion here. Maybe underlying serializer is broken.
|
||||||
$actual['customer']['tags'] = array_filter(
|
// $actualTags = $actual['customer']['tags'];
|
||||||
array_map(static function ($tag) use ($actualTags) {
|
// $actual['customer']['tags'] = array_filter(
|
||||||
if (in_array($tag['name'], $actualTags, true)) {
|
// array_map(static function ($tag) use ($actualTags) {
|
||||||
return $tag;
|
// if (in_array($tag['name'], $actualTags, true)) {
|
||||||
}
|
// return $tag;
|
||||||
}, $expected['customer']['tags'])
|
// }
|
||||||
);
|
// }, $expected['customer']['tags'])
|
||||||
|
// );
|
||||||
|
|
||||||
$expected['customer']['marginSumm'] = (float)$expected['customer']['marginSumm'];
|
$expected['customer']['marginSumm'] = (float)$expected['customer']['marginSumm'];
|
||||||
$expected['customer']['totalSumm'] = (float)$expected['customer']['totalSumm'];
|
$expected['customer']['totalSumm'] = (float)$expected['customer']['totalSumm'];
|
||||||
|
Loading…
Reference in New Issue
Block a user