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