Skip to content

Commit e8a4b95

Browse files
committed
Merge branch '4.6'
2 parents 773c7d0 + cd57d58 commit e8a4b95

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

src/contracts/Repository/Values/ValueObject.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use Ibexa\Contracts\Core\Repository\Exceptions\PropertyNotFoundException;
1111
use Ibexa\Contracts\Core\Repository\Exceptions\PropertyReadOnlyException;
12+
use Symfony\Component\Serializer\Annotation\Ignore as SerializerIgnore;
1213

1314
/**
1415
* The base class for all value objects and structs.
@@ -47,6 +48,8 @@ public function __construct(array $properties = [])
4748
* @param array $dynamicProperties Additional dynamic properties exposed on the object
4849
*
4950
* @return array
51+
*
52+
* @SerializerIgnore()
5053
*/
5154
protected function getProperties($dynamicProperties = [])
5255
{
@@ -202,6 +205,8 @@ final public function attributes()
202205
* @param string $property
203206
*
204207
* @return bool
208+
*
209+
* @SerializerIgnore()
205210
*/
206211
final public function hasAttribute($property)
207212
{
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright (C) Ibexa AS. All rights reserved.
5+
* @license For full copyright and license information view LICENSE file distributed with this source code.
6+
*/
7+
declare(strict_types=1);
8+
9+
namespace Ibexa\Tests\Integration\Core\Repository;
10+
11+
use Ibexa\Tests\Integration\Core\RepositoryTestCase;
12+
use Symfony\Component\Serializer\Encoder\JsonEncode;
13+
use Symfony\Component\Serializer\SerializerInterface;
14+
15+
final class SerializationTest extends RepositoryTestCase
16+
{
17+
public function testSerialization(): void
18+
{
19+
$serializer = $this->getContainer()->get(SerializerInterface::class);
20+
self::assertInstanceOf(SerializerInterface::class, $serializer);
21+
$contentService = self::getContentService();
22+
23+
$user = $contentService->loadContent(14);
24+
$field = $user->getField('user_account');
25+
self::assertNotNull($field, 'Field "name" for admin user should not be null');
26+
27+
$result = $serializer->serialize($field, 'json', [JsonEncode::OPTIONS => JSON_PRETTY_PRINT]);
28+
$passwordHash = '$2y$10$FDn9NPwzhq85cLLxfD5Wu.L3SL3Z\/LNCvhkltJUV0wcJj7ciJg2oy';
29+
self::assertSame(
30+
<<<JSON
31+
{
32+
"id": 30,
33+
"fieldDefIdentifier": "user_account",
34+
"value": {
35+
"hasStoredLogin": true,
36+
"contentId": 14,
37+
"login": "admin",
38+
"email": "[email protected]",
39+
"passwordHash": "$passwordHash",
40+
"passwordHashType": "7",
41+
"passwordUpdatedAt": null,
42+
"enabled": true,
43+
"maxLogin": 10,
44+
"plainPassword": null
45+
},
46+
"languageCode": "eng-US",
47+
"fieldTypeIdentifier": "ezuser",
48+
"fieldDefinitionIdentifier": "user_account",
49+
"virtual": false
50+
}
51+
JSON,
52+
$result,
53+
);
54+
}
55+
}

0 commit comments

Comments
 (0)