Repository navigation
Expand file tree
/
Copy pathPropertySchemaFormatFunctionalTest.php
More file actions
54 lines (43 loc) · 1.88 KB
/
Copy pathPropertySchemaFormatFunctionalTest.php
File metadata and controls
54 lines (43 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace ApiPlatform\Tests\Functional;
use ApiPlatform\JsonSchema\SchemaFactoryInterface;
use ApiPlatform\Test\ApiTestCase;
use ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\PropertySchemaFormatResource;
use ApiPlatform\Tests\SetupClassResourcesTrait;
final class PropertySchemaFormatFunctionalTest extends ApiTestCase
{
use SetupClassResourcesTrait;
protected static ?bool $alwaysBootKernel = false;
/**
* @return class-string[]
*/
public static function getResources(): array
{
return [PropertySchemaFormatResource::class];
}
public function testJsonSchemaFormats(): void
{
/** @var SchemaFactoryInterface $schemaFactory */
$schemaFactory = self::getContainer()->get('api_platform.json_schema.schema_factory');
$schema = $schemaFactory->buildSchema(PropertySchemaFormatResource::class);
$properties = $schema['definitions']['PropertySchemaFormatResource']['properties'] ?? null;
$this->assertIsArray($properties);
$this->assertSame('email', $properties['email']['format'] ?? null);
$this->assertSame('uri', $properties['url']['format'] ?? null);
$this->assertSame('hostname', $properties['hostname']['format'] ?? null);
$this->assertSame('uuid', $properties['uuid']['format'] ?? null);
$this->assertSame('ulid', $properties['ulid']['format'] ?? null);
$this->assertSame('ipv4', $properties['ipv4']['format'] ?? null);
$this->assertSame('ipv6', $properties['ipv6']['format'] ?? null);
$this->assertSame([['format' => 'ipv4'], ['format' => 'ipv6']], $properties['ip']['oneOf'] ?? null);
}
}