diff --git a/src/contracts/Repository/Values/ValueObject.php b/src/contracts/Repository/Values/ValueObject.php index 3aa5b81e76..0ab3d6e7fe 100644 --- a/src/contracts/Repository/Values/ValueObject.php +++ b/src/contracts/Repository/Values/ValueObject.php @@ -8,6 +8,7 @@ use Ibexa\Contracts\Core\Repository\Exceptions\PropertyNotFoundException; use Ibexa\Contracts\Core\Repository\Exceptions\PropertyReadOnlyException; +use Symfony\Component\Serializer\Annotation\Ignore as SerializerIgnore; /** * The base class for all value objects and structs. @@ -46,6 +47,8 @@ public function __construct(array $properties = []) * @param array $dynamicProperties Additional dynamic properties exposed on the object * * @return array + * + * @SerializerIgnore() */ protected function getProperties($dynamicProperties = []) { @@ -201,6 +204,8 @@ final public function attributes() * @param string $property * * @return bool + * + * @SerializerIgnore() */ final public function hasAttribute($property) { diff --git a/src/contracts/Test/IbexaKernelTestTrait.php b/src/contracts/Test/IbexaKernelTestTrait.php index c40329634d..698bb2e5be 100644 --- a/src/contracts/Test/IbexaKernelTestTrait.php +++ b/src/contracts/Test/IbexaKernelTestTrait.php @@ -76,20 +76,23 @@ protected static function getFixtures(): iterable * * @return T */ - final protected static function getServiceByClassName(string $className, ?string $id = null): object - { + final protected static function getServiceByClassName( + string $className, + ?string $id = null, + bool $prefix = true + ): object { if (!self::$booted) { static::bootKernel(); } - $serviceId = self::getTestServiceId($id, $className); + $serviceId = self::getTestServiceId($id, $className, $prefix); $service = self::getContainer()->get($serviceId); assert(is_object($service) && is_a($service, $className)); return $service; } - protected static function getTestServiceId(?string $id, string $className): string + protected static function getTestServiceId(?string $id, string $className, bool $prefix = true): string { $kernel = self::$kernel; if (!$kernel instanceof IbexaTestKernelInterface) { @@ -102,7 +105,7 @@ protected static function getTestServiceId(?string $id, string $className): stri $id = $id ?? $className; - return $kernel->getAliasServiceId($id); + return $prefix ? $kernel->getAliasServiceId($id) : $id; } protected static function getDoctrineConnection(): Connection diff --git a/tests/integration/Core/Repository/SerializationTest.php b/tests/integration/Core/Repository/SerializationTest.php new file mode 100644 index 0000000000..02954b9903 --- /dev/null +++ b/tests/integration/Core/Repository/SerializationTest.php @@ -0,0 +1,62 @@ +loadContent(14); + $field = $user->getField('user_account'); + self::assertNotNull($field, 'Field "name" for admin user should not be null'); + + $result = $serializer->serialize($field, 'json', [JsonEncode::OPTIONS => JSON_PRETTY_PRINT]); + $passwordHash = '$2y$10$FDn9NPwzhq85cLLxfD5Wu.L3SL3Z\/LNCvhkltJUV0wcJj7ciJg2oy'; + self::assertSame( + <<