|
| 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 | + |
| 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