• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 13175309672

06 Feb 2025 09:04AM UTC coverage: 7.663% (-0.2%) from 7.841%
13175309672

push

github

web-flow
fix: ensure template files have a tpl file extension (#6826) (#6829)

2 of 5 new or added lines in 4 files covered. (40.0%)

3676 existing lines in 122 files now uncovered.

13073 of 170593 relevant lines covered (7.66%)

27.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Hydra/Tests/Serializer/DocumentationNormalizerTest.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Hydra\Tests\Serializer;
15

16
use ApiPlatform\Documentation\Documentation;
17
use ApiPlatform\Hydra\Serializer\DocumentationNormalizer;
18
use ApiPlatform\Hydra\Tests\Fixtures\CustomConverter;
19
use ApiPlatform\JsonLd\ContextBuilder;
20
use ApiPlatform\Metadata\ApiProperty;
21
use ApiPlatform\Metadata\ApiResource;
22
use ApiPlatform\Metadata\Get;
23
use ApiPlatform\Metadata\GetCollection;
24
use ApiPlatform\Metadata\Operations;
25
use ApiPlatform\Metadata\Post;
26
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
27
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
28
use ApiPlatform\Metadata\Property\PropertyNameCollection;
29
use ApiPlatform\Metadata\Put;
30
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
31
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
32
use ApiPlatform\Metadata\Resource\ResourceNameCollection;
33
use ApiPlatform\Metadata\ResourceClassResolverInterface;
34
use ApiPlatform\Metadata\UrlGeneratorInterface;
35
use PHPUnit\Framework\TestCase;
36
use Prophecy\Argument;
37
use Prophecy\PhpUnit\ProphecyTrait;
38
use Symfony\Component\PropertyInfo\Type;
39

40
use const ApiPlatform\JsonLd\HYDRA_CONTEXT;
41

42
/**
43
 * @author Amrouche Hamza <hamza.simperfit@gmail.com>
44
 */
45
class DocumentationNormalizerTest extends TestCase
46
{
47
    use ProphecyTrait;
48

49
    public function testNormalize(): void
50
    {
51
        $resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
×
52
        $resourceMetadataFactoryProphecy->create('dummy')->shouldBeCalled()->willReturn(new ResourceMetadataCollection('dummy', [
×
53
            (new ApiResource())->withShortName('dummy')->withDescription('dummy')->withTypes(['#dummy'])->withOperations(new Operations([
×
54
                'get' => (new Get())->withHydraContext(['hydra:foo' => 'bar', 'hydra:title' => 'foobar'])->withTypes(['#dummy'])->withShortName('dummy'),
×
55
                'put' => (new Put())->withShortName('dummy'),
×
56
                'get_collection' => (new GetCollection())->withShortName('dummy'),
×
57
                'post' => (new Post())->withShortName('dummy'),
×
58
            ])),
×
59
            (new ApiResource())->withShortName('relatedDummy')->withOperations(new Operations(['get' => (new Get())->withTypes(['#relatedDummy'])->withShortName('relatedDummy')])),
×
60
        ]));
×
61
        $resourceMetadataFactoryProphecy->create('relatedDummy')->shouldBeCalled()->willReturn(new ResourceMetadataCollection('relatedDummy', [
×
UNCOV
62
            (new ApiResource())->withShortName('relatedDummy')->withOperations(new Operations(['get' => (new Get())->withShortName('relatedDummy')])),
×
63
        ]));
×
64

UNCOV
65
        $this->doTestNormalize($resourceMetadataFactoryProphecy->reveal());
×
66
    }
67

68
    private function doTestNormalize($resourceMetadataFactory = null): void
69
    {
70
        $title = 'Test Api';
×
71
        $desc = 'test ApiGerard';
×
UNCOV
72
        $version = '0.0.0';
×
73
        $documentation = new Documentation(new ResourceNameCollection(['dummy' => 'dummy']), $title, $desc, $version);
×
74

UNCOV
75
        $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
×
76
        $propertyNameCollectionFactoryProphecy->create('dummy', [])->shouldBeCalled()->willReturn(new PropertyNameCollection(['name', 'description', 'nameConverted', 'relatedDummy', 'iri']));
×
77

78
        $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
×
79
        $propertyMetadataFactoryProphecy->create('dummy', 'name', Argument::type('array'))->shouldBeCalled()->willReturn(
×
80
            (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('name')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)
×
81
        );
×
82
        $propertyMetadataFactoryProphecy->create('dummy', 'description', Argument::type('array'))->shouldBeCalled()->willReturn(
×
83
            (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('description')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)->withJsonldContext(['@type' => '@id'])
×
84
        );
×
85
        $propertyMetadataFactoryProphecy->create('dummy', 'nameConverted', Argument::type('array'))->shouldBeCalled()->willReturn(
×
86
            (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('name converted')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)
×
87
        );
×
UNCOV
88
        $propertyMetadataFactoryProphecy->create('dummy', 'relatedDummy', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_OBJECT, false, 'dummy', true, null, new Type(Type::BUILTIN_TYPE_OBJECT, false, 'relatedDummy'))])->withDescription('This is a name.')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
×
89
        $propertyMetadataFactoryProphecy->create('dummy', 'iri', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withIris(['https://schema.org/Dummy']));
×
90

UNCOV
91
        $resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
×
92
        $resourceClassResolverProphecy->isResourceClass(Argument::type('string'))->willReturn(true);
×
93

94
        $urlGenerator = $this->prophesize(UrlGeneratorInterface::class);
×
UNCOV
95
        $urlGenerator->generate('api_entrypoint')->willReturn('/')->shouldBeCalledTimes(1);
×
96
        $urlGenerator->generate('api_doc', ['_format' => 'jsonld'])->willReturn('/doc')->shouldBeCalledTimes(1);
×
97

98
        $urlGenerator->generate('api_doc', ['_format' => 'jsonld'], 0)->willReturn('/doc')->shouldBeCalledTimes(1);
×
99

100
        $documentationNormalizer = new DocumentationNormalizer(
×
101
            $resourceMetadataFactory,
×
102
            $propertyNameCollectionFactoryProphecy->reveal(),
×
103
            $propertyMetadataFactoryProphecy->reveal(),
×
104
            $resourceClassResolverProphecy->reveal(),
×
105
            $urlGenerator->reveal(),
×
UNCOV
106
            new CustomConverter()
×
107
        );
×
108

109
        $expected = [
×
110
            '@context' => [
×
111
                HYDRA_CONTEXT,
×
112
                [
×
113
                    '@vocab' => '/doc#',
×
114
                    'hydra' => 'http://www.w3.org/ns/hydra/core#',
×
115
                    'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
×
116
                    'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
×
117
                    'xmls' => 'http://www.w3.org/2001/XMLSchema#',
×
118
                    'owl' => 'http://www.w3.org/2002/07/owl#',
×
119
                    'schema' => 'https://schema.org/',
×
120
                    'domain' => [
×
121
                        '@id' => 'rdfs:domain',
×
122
                        '@type' => '@id',
×
123
                    ],
×
124
                    'range' => [
×
125
                        '@id' => 'rdfs:range',
×
126
                        '@type' => '@id',
×
127
                    ],
×
128
                    'subClassOf' => [
×
129
                        '@id' => 'rdfs:subClassOf',
×
130
                        '@type' => '@id',
×
131
                    ],
×
132
                ],
×
133
            ],
×
134
            '@id' => '/doc',
×
135
            '@type' => 'hydra:ApiDocumentation',
×
136
            'hydra:title' => 'Test Api',
×
137
            'hydra:description' => 'test ApiGerard',
×
138
            'hydra:supportedClass' => [
×
139
                [
×
140
                    '@id' => '#dummy',
×
141
                    '@type' => 'hydra:Class',
×
142
                    'rdfs:label' => 'dummy',
×
143
                    'hydra:title' => 'dummy',
×
144
                    'hydra:description' => 'dummy',
×
145
                    'hydra:supportedProperty' => [
×
146
                        [
×
147
                            '@type' => 'hydra:SupportedProperty',
×
148
                            'hydra:property' => [
×
149
                                '@id' => '#dummy/name',
×
150
                                '@type' => 'rdf:Property',
×
151
                                'rdfs:label' => 'name',
×
152
                                'domain' => '#dummy',
×
153
                                'range' => 'xmls:string',
×
154
                            ],
×
155
                            'hydra:title' => 'name',
×
156
                            'hydra:required' => false,
×
157
                            'hydra:readable' => true,
×
158
                            'hydra:writeable' => true,
×
159
                            'hydra:description' => 'name',
×
160
                        ],
×
161
                        [
×
162
                            '@type' => 'hydra:SupportedProperty',
×
163
                            'hydra:property' => [
×
164
                                '@id' => '#dummy/description',
×
165
                                '@type' => 'rdf:Property',
×
166
                                'rdfs:label' => 'description',
×
167
                                'domain' => '#dummy',
×
168
                                'range' => '@id',
×
169
                            ],
×
170
                            'hydra:title' => 'description',
×
171
                            'hydra:required' => false,
×
172
                            'hydra:readable' => true,
×
173
                            'hydra:writeable' => true,
×
174
                            'hydra:description' => 'description',
×
175
                        ],
×
176
                        [
×
177
                            '@type' => 'hydra:SupportedProperty',
×
178
                            'hydra:property' => [
×
179
                                '@id' => '#dummy/name_converted',
×
180
                                '@type' => 'rdf:Property',
×
181
                                'rdfs:label' => 'name_converted',
×
182
                                'domain' => '#dummy',
×
183
                                'range' => 'xmls:string',
×
184
                            ],
×
185
                            'hydra:title' => 'name_converted',
×
186
                            'hydra:required' => false,
×
187
                            'hydra:readable' => true,
×
188
                            'hydra:writeable' => true,
×
189
                            'hydra:description' => 'name converted',
×
190
                        ],
×
191
                        [
×
192
                            '@type' => 'hydra:SupportedProperty',
×
193
                            'hydra:property' => [
×
194
                                '@id' => '#dummy/relatedDummy',
×
195
                                '@type' => 'rdf:Property',
×
196
                                'rdfs:label' => 'relatedDummy',
×
197
                                'domain' => '#dummy',
×
198
                                'range' => '#relatedDummy',
×
199
                            ],
×
200
                            'hydra:title' => 'relatedDummy',
×
201
                            'hydra:required' => false,
×
202
                            'hydra:readable' => true,
×
203
                            'hydra:writeable' => true,
×
204
                            'hydra:description' => 'This is a name.',
×
205
                        ],
×
206
                        [
×
207
                            '@type' => 'hydra:SupportedProperty',
×
208
                            'hydra:property' => [
×
209
                                '@id' => 'https://schema.org/Dummy',
×
210
                                '@type' => 'rdf:Property',
×
211
                                'rdfs:label' => 'iri',
×
212
                                'domain' => '#dummy',
×
213
                            ],
×
214
                            'hydra:title' => 'iri',
×
215
                            'hydra:required' => null,
×
216
                            'hydra:readable' => null,
×
217
                            'hydra:writeable' => false,
×
218
                        ],
×
219
                    ],
×
220
                    'hydra:supportedOperation' => [
×
221
                        [
×
222
                            '@type' => ['hydra:Operation', 'schema:FindAction'],
×
223
                            'hydra:method' => 'GET',
×
224
                            'hydra:title' => 'foobar',
×
225
                            'rdfs:label' => 'foobar',
×
226
                            'returns' => 'dummy',
×
227
                            'hydra:foo' => 'bar',
×
228
                        ],
×
229
                        [
×
230
                            '@type' => ['hydra:Operation', 'schema:ReplaceAction'],
×
231
                            'expects' => 'dummy',
×
232
                            'hydra:method' => 'PUT',
×
233
                            'hydra:title' => 'Replaces the dummy resource.',
×
234
                            'rdfs:label' => 'Replaces the dummy resource.',
×
235
                            'returns' => 'dummy',
×
236
                        ],
×
237
                        [
×
238
                            '@type' => ['hydra:Operation', 'schema:FindAction'],
×
239
                            'hydra:method' => 'GET',
×
240
                            'hydra:title' => 'Retrieves a relatedDummy resource.',
×
241
                            'rdfs:label' => 'Retrieves a relatedDummy resource.',
×
242
                            'returns' => 'relatedDummy',
×
243
                        ],
×
244
                    ],
×
245
                ],
×
246
                [
×
247
                    '@id' => '#Entrypoint',
×
248
                    '@type' => 'hydra:Class',
×
249
                    'hydra:title' => 'The API entrypoint',
×
250
                    'hydra:supportedProperty' => [
×
251
                        [
×
252
                            '@type' => 'hydra:SupportedProperty',
×
253
                            'hydra:property' => [
×
254
                                '@id' => '#Entrypoint/dummy',
×
255
                                '@type' => 'hydra:Link',
×
256
                                'rdfs:label' => 'The collection of dummy resources',
×
257
                                'domain' => '#Entrypoint',
×
258
                                'rdfs:range' => [
×
259
                                    ['@id' => 'hydra:Collection'],
×
260
                                    [
×
261
                                        'owl:equivalentClass' => [
×
262
                                            'owl:onProperty' => ['@id' => 'hydra:member'],
×
263
                                            'owl:allValuesFrom' => ['@id' => '#dummy'],
×
264
                                        ],
×
265
                                    ],
×
266
                                ],
×
267
                                'hydra:supportedOperation' => [
×
268
                                    [
×
269
                                        '@type' => ['hydra:Operation', 'schema:FindAction'],
×
270
                                        'hydra:method' => 'GET',
×
271
                                        'hydra:title' => 'Retrieves the collection of dummy resources.',
×
272
                                        'rdfs:label' => 'Retrieves the collection of dummy resources.',
×
273
                                        'returns' => 'hydra:Collection',
×
274
                                    ],
×
275
                                    [
×
276
                                        '@type' => ['hydra:Operation', 'schema:CreateAction'],
×
277
                                        'expects' => 'dummy',
×
278
                                        'hydra:method' => 'POST',
×
279
                                        'hydra:title' => 'Creates a dummy resource.',
×
280
                                        'rdfs:label' => 'Creates a dummy resource.',
×
281
                                        'returns' => 'dummy',
×
282
                                    ],
×
283
                                ],
×
284
                            ],
×
285
                            'hydra:title' => 'The collection of dummy resources',
×
286
                            'hydra:readable' => true,
×
287
                            'hydra:writeable' => false,
×
288
                        ],
×
289
                    ],
×
290
                    'hydra:supportedOperation' => [
×
291
                        '@type' => 'hydra:Operation',
×
292
                        'hydra:method' => 'GET',
×
293
                        'rdfs:label' => 'The API entrypoint.',
×
294
                        'returns' => 'EntryPoint',
×
295
                    ],
×
296
                ],
×
297
                [
×
298
                    '@id' => '#ConstraintViolation',
×
299
                    '@type' => 'hydra:Class',
×
300
                    'hydra:title' => 'A constraint violation',
×
301
                    'hydra:supportedProperty' => [
×
302
                        [
×
303
                            '@type' => 'hydra:SupportedProperty',
×
304
                            'hydra:property' => [
×
305
                                '@id' => '#ConstraintViolation/propertyPath',
×
306
                                '@type' => 'rdf:Property',
×
307
                                'rdfs:label' => 'propertyPath',
×
308
                                'domain' => '#ConstraintViolation',
×
309
                                'range' => 'xmls:string',
×
310
                            ],
×
311
                            'hydra:title' => 'propertyPath',
×
312
                            'hydra:description' => 'The property path of the violation',
×
313
                            'hydra:readable' => true,
×
314
                            'hydra:writeable' => false,
×
315
                        ],
×
316
                        [
×
317
                            '@type' => 'hydra:SupportedProperty',
×
318
                            'hydra:property' => [
×
319
                                '@id' => '#ConstraintViolation/message',
×
320
                                '@type' => 'rdf:Property',
×
321
                                'rdfs:label' => 'message',
×
322
                                'domain' => '#ConstraintViolation',
×
323
                                'range' => 'xmls:string',
×
324
                            ],
×
325
                            'hydra:title' => 'message',
×
326
                            'hydra:description' => 'The message associated with the violation',
×
327
                            'hydra:readable' => true,
×
328
                            'hydra:writeable' => false,
×
329
                        ],
×
330
                    ],
×
331
                ],
×
332
                [
×
333
                    '@id' => '#ConstraintViolationList',
×
334
                    '@type' => 'hydra:Class',
×
335
                    'subClassOf' => 'hydra:Error',
×
336
                    'hydra:title' => 'A constraint violation list',
×
337
                    'hydra:supportedProperty' => [
×
338
                        [
×
339
                            '@type' => 'hydra:SupportedProperty',
×
340
                            'hydra:property' => [
×
341
                                '@id' => '#ConstraintViolationList/violations',
×
342
                                '@type' => 'rdf:Property',
×
343
                                'rdfs:label' => 'violations',
×
344
                                'domain' => '#ConstraintViolationList',
×
345
                                'range' => '#ConstraintViolation',
×
346
                            ],
×
347
                            'hydra:title' => 'violations',
×
348
                            'hydra:description' => 'The violations',
×
349
                            'hydra:readable' => true,
×
350
                            'hydra:writeable' => false,
×
351
                        ],
×
352
                    ],
×
353
                ],
×
354
            ],
×
355
            'hydra:entrypoint' => '/',
×
356
        ];
×
357

358
        $this->assertEquals($expected, $documentationNormalizer->normalize($documentation));
×
359
        $this->assertTrue($documentationNormalizer->supportsNormalization($documentation, 'jsonld'));
×
UNCOV
360
        $this->assertFalse($documentationNormalizer->supportsNormalization($documentation, 'hal'));
×
361
        $this->assertEmpty($documentationNormalizer->getSupportedTypes('json'));
×
362
        $this->assertSame([Documentation::class => true], $documentationNormalizer->getSupportedTypes($documentationNormalizer::FORMAT));
×
363
    }
364

365
    public function testNormalizeInputOutputClass(): void
366
    {
UNCOV
367
        $title = 'Test Api';
×
UNCOV
368
        $desc = 'test ApiGerard';
×
UNCOV
369
        $version = '0.0.0';
×
370
        $documentation = new Documentation(new ResourceNameCollection(['dummy' => 'dummy']), $title, $desc, $version);
×
371

372
        $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
×
373
        $propertyNameCollectionFactoryProphecy->create('inputClass', Argument::type('array'))->shouldBeCalled()->willReturn(new PropertyNameCollection(['a', 'b']));
×
UNCOV
374
        $propertyNameCollectionFactoryProphecy->create('outputClass', Argument::type('array'))->shouldBeCalled()->willReturn(new PropertyNameCollection(['c', 'd']));
×
375
        $propertyNameCollectionFactoryProphecy->create('dummy', Argument::type('array'))->shouldBeCalled()->willReturn(new PropertyNameCollection([]));
×
376

377
        $resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
×
378
        $resourceMetadataFactoryProphecy->create('dummy')->shouldBeCalled()->willReturn(new ResourceMetadataCollection('dummy', [
×
UNCOV
379
            (new ApiResource())->withShortName('dummy')->withDescription('dummy')->withTypes(['#dummy'])->withOperations(new Operations([
×
380
                'get' => (new Get())->withTypes(['#dummy'])->withShortName('dummy')->withInput(['class' => 'inputClass'])->withOutput(['class' => 'outputClass']),
×
381
                'put' => (new Put())->withShortName('dummy')->withInput(['class' => null])->withOutput(['class' => 'outputClass']),
×
382
                'get_collection' => (new GetCollection())->withShortName('dummy')->withInput(['class' => 'inputClass'])->withOutput(['class' => 'outputClass']),
×
383
                'post' => (new Post())->withShortName('dummy')->withOutput(['class' => null])->withInput(['class' => 'inputClass']),
×
384
            ])),
×
385
        ]));
×
386

387
        $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
×
388
        $propertyMetadataFactoryProphecy->create('inputClass', 'a', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('a')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
×
UNCOV
389
        $propertyMetadataFactoryProphecy->create('inputClass', 'b', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('b')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
×
390
        $propertyMetadataFactoryProphecy->create('outputClass', 'c', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('c')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
×
391
        $propertyMetadataFactoryProphecy->create('outputClass', 'd', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('d')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
×
392

393
        $resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
×
394
        $resourceClassResolverProphecy->isResourceClass(Argument::type('string'))->willReturn(true);
×
395

396
        $urlGenerator = $this->prophesize(UrlGeneratorInterface::class);
×
397
        $urlGenerator->generate('api_entrypoint')->willReturn('/')->shouldBeCalledTimes(1);
×
UNCOV
398
        $urlGenerator->generate('api_doc', ['_format' => 'jsonld'])->willReturn('/doc')->shouldBeCalledTimes(1);
×
399
        $urlGenerator->generate('api_doc', ['_format' => 'jsonld'], 0)->willReturn('/doc')->shouldBeCalledTimes(1);
×
400

401
        $documentationNormalizer = new DocumentationNormalizer(
×
402
            $resourceMetadataFactoryProphecy->reveal(),
×
UNCOV
403
            $propertyNameCollectionFactoryProphecy->reveal(),
×
404
            $propertyMetadataFactoryProphecy->reveal(),
×
405
            $resourceClassResolverProphecy->reveal(),
×
406
            $urlGenerator->reveal()
×
407
        );
×
408

409
        $expected = [
×
410
            '@context' => [
×
UNCOV
411
                HYDRA_CONTEXT,
×
412
                [
×
413
                    '@vocab' => '/doc#',
×
414
                    'hydra' => 'http://www.w3.org/ns/hydra/core#',
×
415
                    'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
×
416
                    'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
×
417
                    'xmls' => 'http://www.w3.org/2001/XMLSchema#',
×
418
                    'owl' => 'http://www.w3.org/2002/07/owl#',
×
419
                    'schema' => 'https://schema.org/',
×
420
                    'domain' => [
×
421
                        '@id' => 'rdfs:domain',
×
422
                        '@type' => '@id',
×
423
                    ],
×
424
                    'range' => [
×
425
                        '@id' => 'rdfs:range',
×
426
                        '@type' => '@id',
×
427
                    ],
×
428
                    'subClassOf' => [
×
429
                        '@id' => 'rdfs:subClassOf',
×
430
                        '@type' => '@id',
×
431
                    ],
×
432
                ],
×
433
            ],
×
434
            '@id' => '/doc',
×
435
            '@type' => 'hydra:ApiDocumentation',
×
436
            'hydra:title' => 'Test Api',
×
437
            'hydra:description' => 'test ApiGerard',
×
438
            'hydra:entrypoint' => '/',
×
439
            'hydra:supportedClass' => [
×
440
                [
×
441
                    '@id' => '#dummy',
×
442
                    '@type' => 'hydra:Class',
×
443
                    'rdfs:label' => 'dummy',
×
444
                    'hydra:title' => 'dummy',
×
445
                    'hydra:supportedProperty' => [
×
446
                        [
×
447
                            '@type' => 'hydra:SupportedProperty',
×
448
                            'hydra:property' => [
×
449
                                '@id' => '#dummy/a',
×
450
                                '@type' => 'rdf:Property',
×
451
                                'rdfs:label' => 'a',
×
452
                                'domain' => '#dummy',
×
453
                                'range' => 'xmls:string',
×
454
                            ],
×
455
                            'hydra:title' => 'a',
×
456
                            'hydra:required' => false,
×
457
                            'hydra:readable' => true,
×
458
                            'hydra:writeable' => true,
×
459
                            'hydra:description' => 'a',
×
460
                        ],
×
461
                        [
×
462
                            '@type' => 'hydra:SupportedProperty',
×
463
                            'hydra:property' => [
×
464
                                '@id' => '#dummy/b',
×
465
                                '@type' => 'rdf:Property',
×
466
                                'rdfs:label' => 'b',
×
467
                                'domain' => '#dummy',
×
468
                                'range' => 'xmls:string',
×
469
                            ],
×
470
                            'hydra:title' => 'b',
×
471
                            'hydra:required' => false,
×
472
                            'hydra:readable' => true,
×
473
                            'hydra:writeable' => true,
×
474
                            'hydra:description' => 'b',
×
475
                        ],
×
476
                        [
×
477
                            '@type' => 'hydra:SupportedProperty',
×
478
                            'hydra:property' => [
×
479
                                '@id' => '#dummy/c',
×
480
                                '@type' => 'rdf:Property',
×
481
                                'rdfs:label' => 'c',
×
482
                                'domain' => '#dummy',
×
483
                                'range' => 'xmls:string',
×
484
                            ],
×
485
                            'hydra:title' => 'c',
×
486
                            'hydra:required' => false,
×
487
                            'hydra:readable' => true,
×
488
                            'hydra:writeable' => true,
×
489
                            'hydra:description' => 'c',
×
490
                        ],
×
491
                        [
×
492
                            '@type' => 'hydra:SupportedProperty',
×
493
                            'hydra:property' => [
×
494
                                '@id' => '#dummy/d',
×
495
                                '@type' => 'rdf:Property',
×
496
                                'rdfs:label' => 'd',
×
497
                                'domain' => '#dummy',
×
498
                                'range' => 'xmls:string',
×
499
                            ],
×
500
                            'hydra:title' => 'd',
×
501
                            'hydra:required' => false,
×
502
                            'hydra:readable' => true,
×
503
                            'hydra:writeable' => true,
×
504
                            'hydra:description' => 'd',
×
505
                        ],
×
506
                    ],
×
507
                    'hydra:supportedOperation' => [
×
508
                        [
×
509
                            '@type' => [
×
510
                                'hydra:Operation',
×
511
                                'schema:FindAction',
×
512
                            ],
×
513
                            'hydra:method' => 'GET',
×
514
                            'hydra:title' => 'Retrieves a dummy resource.',
×
515
                            'rdfs:label' => 'Retrieves a dummy resource.',
×
516
                            'returns' => 'dummy',
×
517
                        ],
×
518
                        [
×
519
                            '@type' => [
×
520
                                'hydra:Operation',
×
521
                                'schema:ReplaceAction',
×
522
                            ],
×
523
                            'expects' => 'owl:Nothing',
×
524
                            'hydra:method' => 'PUT',
×
525
                            'hydra:title' => 'Replaces the dummy resource.',
×
526
                            'rdfs:label' => 'Replaces the dummy resource.',
×
527
                            'returns' => 'dummy',
×
528
                        ],
×
529
                    ],
×
530
                    'hydra:description' => 'dummy',
×
531
                ],
×
532
                [
×
533
                    '@id' => '#Entrypoint',
×
534
                    '@type' => 'hydra:Class',
×
535
                    'hydra:title' => 'The API entrypoint',
×
536
                    'hydra:supportedProperty' => [
×
537
                        [
×
538
                            '@type' => 'hydra:SupportedProperty',
×
539
                            'hydra:property' => [
×
540
                                '@id' => '#Entrypoint/dummy',
×
541
                                '@type' => 'hydra:Link',
×
542
                                'domain' => '#Entrypoint',
×
543
                                'rdfs:label' => 'The collection of dummy resources',
×
544
                                'rdfs:range' => [
×
545
                                    [
×
546
                                        '@id' => 'hydra:Collection',
×
547
                                    ],
×
548
                                    [
×
549
                                        'owl:equivalentClass' => [
×
550
                                            'owl:onProperty' => [
×
551
                                                '@id' => 'hydra:member',
×
552
                                            ],
×
553
                                            'owl:allValuesFrom' => [
×
554
                                                '@id' => '#dummy',
×
555
                                            ],
×
556
                                        ],
×
557
                                    ],
×
558
                                ],
×
559
                                'hydra:supportedOperation' => [
×
560
                                    [
×
561
                                        '@type' => [
×
562
                                            'hydra:Operation',
×
563
                                            'schema:FindAction',
×
564
                                        ],
×
565
                                        'hydra:method' => 'GET',
×
566
                                        'hydra:title' => 'Retrieves the collection of dummy resources.',
×
567
                                        'rdfs:label' => 'Retrieves the collection of dummy resources.',
×
568
                                        'returns' => 'hydra:Collection',
×
569
                                    ],
×
570
                                    [
×
571
                                        '@type' => [
×
572
                                            'hydra:Operation',
×
573
                                            'schema:CreateAction',
×
574
                                        ],
×
575
                                        'expects' => 'dummy',
×
576
                                        'hydra:method' => 'POST',
×
577
                                        'hydra:title' => 'Creates a dummy resource.',
×
578
                                        'rdfs:label' => 'Creates a dummy resource.',
×
579
                                        'returns' => 'owl:Nothing',
×
580
                                    ],
×
581
                                ],
×
582
                            ],
×
583
                            'hydra:title' => 'The collection of dummy resources',
×
584
                            'hydra:readable' => true,
×
585
                            'hydra:writeable' => false,
×
586
                        ],
×
587
                    ],
×
588
                    'hydra:supportedOperation' => [
×
589
                        '@type' => 'hydra:Operation',
×
590
                        'hydra:method' => 'GET',
×
591
                        'rdfs:label' => 'The API entrypoint.',
×
592
                        'returns' => 'EntryPoint',
×
593
                    ],
×
594
                ],
×
595
                2 => [
×
596
                    '@id' => '#ConstraintViolation',
×
597
                    '@type' => 'hydra:Class',
×
598
                    'hydra:title' => 'A constraint violation',
×
599
                    'hydra:supportedProperty' => [
×
600
                        [
×
601
                            '@type' => 'hydra:SupportedProperty',
×
602
                            'hydra:property' => [
×
603
                                '@id' => '#ConstraintViolation/propertyPath',
×
604
                                '@type' => 'rdf:Property',
×
605
                                'rdfs:label' => 'propertyPath',
×
606
                                'domain' => '#ConstraintViolation',
×
607
                                'range' => 'xmls:string',
×
608
                            ],
×
609
                            'hydra:title' => 'propertyPath',
×
610
                            'hydra:description' => 'The property path of the violation',
×
611
                            'hydra:readable' => true,
×
612
                            'hydra:writeable' => false,
×
613
                        ],
×
614
                        [
×
615
                            '@type' => 'hydra:SupportedProperty',
×
616
                            'hydra:property' => [
×
617
                                '@id' => '#ConstraintViolation/message',
×
618
                                '@type' => 'rdf:Property',
×
619
                                'rdfs:label' => 'message',
×
620
                                'domain' => '#ConstraintViolation',
×
621
                                'range' => 'xmls:string',
×
622
                            ],
×
623
                            'hydra:title' => 'message',
×
624
                            'hydra:description' => 'The message associated with the violation',
×
625
                            'hydra:readable' => true,
×
626
                            'hydra:writeable' => false,
×
627
                        ],
×
628
                    ],
×
629
                ],
×
630
                [
×
631
                    '@id' => '#ConstraintViolationList',
×
632
                    '@type' => 'hydra:Class',
×
633
                    'subClassOf' => 'hydra:Error',
×
634
                    'hydra:title' => 'A constraint violation list',
×
635
                    'hydra:supportedProperty' => [
×
636
                        [
×
637
                            '@type' => 'hydra:SupportedProperty',
×
638
                            'hydra:property' => [
×
639
                                '@id' => '#ConstraintViolationList/violations',
×
640
                                '@type' => 'rdf:Property',
×
641
                                'rdfs:label' => 'violations',
×
642
                                'domain' => '#ConstraintViolationList',
×
643
                                'range' => '#ConstraintViolation',
×
644
                            ],
×
645
                            'hydra:title' => 'violations',
×
646
                            'hydra:description' => 'The violations',
×
647
                            'hydra:readable' => true,
×
648
                            'hydra:writeable' => false,
×
649
                        ],
×
650
                    ],
×
651
                ],
×
652
            ],
×
653
        ];
×
654

655
        $this->assertEquals($expected, $documentationNormalizer->normalize($documentation));
×
656
    }
657

658
    public function testHasHydraContext(): void
659
    {
660
        $title = 'Test Api';
×
661
        $desc = 'test ApiGerard';
×
UNCOV
662
        $version = '0.0.0';
×
663
        $documentation = new Documentation(new ResourceNameCollection(['dummy' => 'dummy']), $title, $desc, $version);
×
664

UNCOV
665
        $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
×
UNCOV
666
        $propertyNameCollectionFactoryProphecy->create('dummy', Argument::type('array'))->shouldBeCalled()->willReturn(new PropertyNameCollection(['name']));
×
667

668
        $resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
×
669
        $resourceMetadataFactoryProphecy->create('dummy')->shouldBeCalled()->willReturn(new ResourceMetadataCollection('dummy', [
×
670
            (new ApiResource())->withShortName('dummy')->withDescription('dummy')->withTypes(['#dummy'])->withOperations(new Operations([
×
671
                'get' => (new Get())->withTypes(['#dummy'])->withShortName('dummy')->withInput(['class' => 'inputClass'])->withOutput(['class' => 'outputClass']),
×
UNCOV
672
            ])),
×
673
        ]));
×
674

UNCOV
675
        $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
×
676
        $propertyMetadataFactoryProphecy->create('dummy', 'name', Argument::type('array'))->shouldBeCalled()->willReturn(
×
677
            (new ApiProperty())
×
678
                ->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])
×
679
                ->withDescription('b')
×
680
                ->withReadable(true)
×
681
                ->withWritable(true)
×
UNCOV
682
                ->withJsonldContext([
×
683
                    'hydra:property' => [
×
684
                        '@type' => 'https://schema.org/Enumeration',
×
685
                    ],
×
686
                ])
×
687
        );
×
688

689
        $resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
×
690
        $resourceClassResolverProphecy->isResourceClass(Argument::type('string'))->willReturn(true);
×
691

692
        $urlGenerator = $this->prophesize(UrlGeneratorInterface::class);
×
693
        $urlGenerator->generate('api_entrypoint')->willReturn('/')->shouldBeCalledTimes(1);
×
694
        $urlGenerator->generate('api_doc', ['_format' => 'jsonld'])->willReturn('/doc')->shouldBeCalledTimes(1);
×
695
        $urlGenerator->generate('api_doc', ['_format' => 'jsonld'], 0)->willReturn('/doc')->shouldBeCalledTimes(1);
×
696

697
        $documentationNormalizer = new DocumentationNormalizer(
×
698
            $resourceMetadataFactoryProphecy->reveal(),
×
UNCOV
699
            $propertyNameCollectionFactoryProphecy->reveal(),
×
700
            $propertyMetadataFactoryProphecy->reveal(),
×
701
            $resourceClassResolverProphecy->reveal(),
×
702
            $urlGenerator->reveal()
×
703
        );
×
704

705
        $this->assertEquals([
×
706
            '@id' => '#dummy/name',
×
707
            '@type' => 'https://schema.org/Enumeration',
×
708
            'rdfs:label' => 'name',
×
709
            'domain' => '#dummy',
×
710
            'range' => 'xmls:string',
×
711
        ], $documentationNormalizer->normalize($documentation)['hydra:supportedClass'][0]['hydra:supportedProperty'][0]['hydra:property']);
×
712
    }
713

714
    public function testNormalizeWithoutPrefix(): void
715
    {
716
        $resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataCollectionFactoryInterface::class);
×
717
        $resourceMetadataFactoryProphecy->create('dummy')->shouldBeCalled()->willReturn(new ResourceMetadataCollection('dummy', [
×
718
            (new ApiResource())->withShortName('dummy')->withDescription('dummy')->withTypes(['#dummy'])->withOperations(new Operations([
×
719
                'get' => (new Get())->withHydraContext(['foo' => 'bar', 'title' => 'foobar'])->withTypes(['#dummy'])->withShortName('dummy'),
×
UNCOV
720
                'put' => (new Put())->withShortName('dummy'),
×
UNCOV
721
                'get_collection' => (new GetCollection())->withShortName('dummy'),
×
UNCOV
722
                'post' => (new Post())->withShortName('dummy'),
×
UNCOV
723
            ])),
×
724
            (new ApiResource())->withShortName('relatedDummy')->withOperations(new Operations(['get' => (new Get())->withTypes(['#relatedDummy'])->withShortName('relatedDummy')])),
×
725
        ]));
×
726
        $resourceMetadataFactoryProphecy->create('relatedDummy')->shouldBeCalled()->willReturn(new ResourceMetadataCollection('relatedDummy', [
×
727
            (new ApiResource())->withShortName('relatedDummy')->withOperations(new Operations(['get' => (new Get())->withShortName('relatedDummy')])),
×
728
        ]));
×
729

730
        $title = 'Test Api';
×
731
        $desc = 'test ApiGerard';
×
732
        $version = '0.0.0';
×
733
        $documentation = new Documentation(new ResourceNameCollection(['dummy' => 'dummy']), $title, $desc, $version);
×
734

735
        $propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
×
736
        $propertyNameCollectionFactoryProphecy->create('dummy', [])->shouldBeCalled()->willReturn(new PropertyNameCollection(['name', 'description', 'nameConverted', 'relatedDummy', 'iri']));
×
737

738
        $propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
×
739
        $propertyMetadataFactoryProphecy->create('dummy', 'name', Argument::type('array'))->shouldBeCalled()->willReturn(
×
740
            (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('name')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)
×
741
        );
×
UNCOV
742
        $propertyMetadataFactoryProphecy->create('dummy', 'description', Argument::type('array'))->shouldBeCalled()->willReturn(
×
743
            (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('description')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)->withJsonldContext(['@type' => '@id'])
×
744
        );
×
UNCOV
745
        $propertyMetadataFactoryProphecy->create('dummy', 'nameConverted', Argument::type('array'))->shouldBeCalled()->willReturn(
×
746
            (new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_STRING)])->withDescription('name converted')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true)
×
747
        );
×
748
        $propertyMetadataFactoryProphecy->create('dummy', 'relatedDummy', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withBuiltinTypes([new Type(Type::BUILTIN_TYPE_OBJECT, false, 'dummy', true, null, new Type(Type::BUILTIN_TYPE_OBJECT, false, 'relatedDummy'))])->withDescription('This is a name.')->withReadable(true)->withWritable(true)->withReadableLink(true)->withWritableLink(true));
×
749
        $propertyMetadataFactoryProphecy->create('dummy', 'iri', Argument::type('array'))->shouldBeCalled()->willReturn((new ApiProperty())->withIris(['https://schema.org/Dummy']));
×
750

751
        $resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
×
752
        $resourceClassResolverProphecy->isResourceClass(Argument::type('string'))->willReturn(true);
×
753

754
        $urlGenerator = $this->prophesize(UrlGeneratorInterface::class);
×
755
        $urlGenerator->generate('api_entrypoint')->willReturn('/')->shouldBeCalledTimes(1);
×
756
        $urlGenerator->generate('api_doc', ['_format' => 'jsonld'])->willReturn('/doc')->shouldBeCalledTimes(1);
×
757

UNCOV
758
        $urlGenerator->generate('api_doc', ['_format' => 'jsonld'], 0)->willReturn('/doc')->shouldBeCalledTimes(1);
×
759

760
        $documentationNormalizer = new DocumentationNormalizer(
×
UNCOV
761
            $resourceMetadataFactoryProphecy->reveal(),
×
762
            $propertyNameCollectionFactoryProphecy->reveal(),
×
763
            $propertyMetadataFactoryProphecy->reveal(),
×
764
            $resourceClassResolverProphecy->reveal(),
×
UNCOV
765
            $urlGenerator->reveal(),
×
766
            new CustomConverter()
×
UNCOV
767
        );
×
768

769
        $expected = [
×
770
            '@context' => [
×
771
                HYDRA_CONTEXT,
×
772
                [
×
773
                    '@vocab' => '/doc#',
×
774
                    'hydra' => 'http://www.w3.org/ns/hydra/core#',
×
775
                    'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
×
UNCOV
776
                    'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
×
777
                    'xmls' => 'http://www.w3.org/2001/XMLSchema#',
×
778
                    'owl' => 'http://www.w3.org/2002/07/owl#',
×
779
                    'schema' => 'https://schema.org/',
×
780
                    'domain' => [
×
781
                        '@id' => 'rdfs:domain',
×
782
                        '@type' => '@id',
×
783
                    ],
×
784
                    'range' => [
×
785
                        '@id' => 'rdfs:range',
×
786
                        '@type' => '@id',
×
787
                    ],
×
788
                    'subClassOf' => [
×
789
                        '@id' => 'rdfs:subClassOf',
×
790
                        '@type' => '@id',
×
791
                    ],
×
792
                ],
×
793
            ],
×
794
            '@id' => '/doc',
×
795
            '@type' => 'ApiDocumentation',
×
796
            'title' => 'Test Api',
×
797
            'description' => 'test ApiGerard',
×
798
            'supportedClass' => [
×
799
                [
×
800
                    '@id' => '#dummy',
×
801
                    '@type' => 'Class',
×
802
                    'rdfs:label' => 'dummy',
×
803
                    'title' => 'dummy',
×
804
                    'description' => 'dummy',
×
805
                    'supportedProperty' => [
×
806
                        [
×
807
                            '@type' => 'SupportedProperty',
×
808
                            'property' => [
×
809
                                '@id' => '#dummy/name',
×
810
                                '@type' => 'rdf:Property',
×
811
                                'rdfs:label' => 'name',
×
812
                                'domain' => '#dummy',
×
813
                                'range' => 'xmls:string',
×
814
                            ],
×
815
                            'title' => 'name',
×
816
                            'required' => false,
×
817
                            'readable' => true,
×
818
                            'writeable' => true,
×
819
                            'description' => 'name',
×
820
                        ],
×
821
                        [
×
822
                            '@type' => 'SupportedProperty',
×
823
                            'property' => [
×
824
                                '@id' => '#dummy/description',
×
825
                                '@type' => 'rdf:Property',
×
826
                                'rdfs:label' => 'description',
×
827
                                'domain' => '#dummy',
×
828
                                'range' => '@id',
×
829
                            ],
×
830
                            'title' => 'description',
×
831
                            'required' => false,
×
832
                            'readable' => true,
×
833
                            'writeable' => true,
×
834
                            'description' => 'description',
×
835
                        ],
×
836
                        [
×
837
                            '@type' => 'SupportedProperty',
×
838
                            'property' => [
×
839
                                '@id' => '#dummy/name_converted',
×
840
                                '@type' => 'rdf:Property',
×
841
                                'rdfs:label' => 'name_converted',
×
842
                                'domain' => '#dummy',
×
843
                                'range' => 'xmls:string',
×
844
                            ],
×
845
                            'title' => 'name_converted',
×
846
                            'required' => false,
×
847
                            'readable' => true,
×
848
                            'writeable' => true,
×
849
                            'description' => 'name converted',
×
850
                        ],
×
851
                        [
×
852
                            '@type' => 'SupportedProperty',
×
853
                            'property' => [
×
854
                                '@id' => '#dummy/relatedDummy',
×
855
                                '@type' => 'rdf:Property',
×
856
                                'rdfs:label' => 'relatedDummy',
×
857
                                'domain' => '#dummy',
×
858
                                'range' => '#relatedDummy',
×
859
                            ],
×
860
                            'title' => 'relatedDummy',
×
861
                            'required' => false,
×
862
                            'readable' => true,
×
863
                            'writeable' => true,
×
864
                            'description' => 'This is a name.',
×
865
                        ],
×
866
                        [
×
867
                            '@type' => 'SupportedProperty',
×
868
                            'property' => [
×
869
                                '@id' => 'https://schema.org/Dummy',
×
870
                                '@type' => 'rdf:Property',
×
871
                                'rdfs:label' => 'iri',
×
872
                                'domain' => '#dummy',
×
873
                            ],
×
874
                            'title' => 'iri',
×
875
                            'required' => null,
×
876
                            'readable' => null,
×
877
                            'writeable' => false,
×
878
                        ],
×
879
                    ],
×
880
                    'supportedOperation' => [
×
881
                        [
×
882
                            '@type' => ['Operation', 'schema:FindAction'],
×
883
                            'method' => 'GET',
×
884
                            'title' => 'foobar',
×
885
                            'rdfs:label' => 'foobar',
×
886
                            'returns' => 'dummy',
×
887
                            'foo' => 'bar',
×
888
                        ],
×
889
                        [
×
890
                            '@type' => ['Operation', 'schema:ReplaceAction'],
×
891
                            'expects' => 'dummy',
×
892
                            'method' => 'PUT',
×
893
                            'title' => 'Replaces the dummy resource.',
×
894
                            'rdfs:label' => 'Replaces the dummy resource.',
×
895
                            'returns' => 'dummy',
×
896
                        ],
×
897
                        [
×
898
                            '@type' => ['Operation', 'schema:FindAction'],
×
899
                            'method' => 'GET',
×
900
                            'title' => 'Retrieves a relatedDummy resource.',
×
901
                            'rdfs:label' => 'Retrieves a relatedDummy resource.',
×
902
                            'returns' => 'relatedDummy',
×
903
                        ],
×
904
                    ],
×
905
                ],
×
906
                [
×
907
                    '@id' => '#Entrypoint',
×
908
                    '@type' => 'Class',
×
909
                    'title' => 'The API entrypoint',
×
910
                    'supportedProperty' => [
×
911
                        [
×
912
                            '@type' => 'SupportedProperty',
×
913
                            'property' => [
×
914
                                '@id' => '#Entrypoint/dummy',
×
915
                                '@type' => 'Link',
×
916
                                'rdfs:label' => 'The collection of dummy resources',
×
917
                                'domain' => '#Entrypoint',
×
918
                                'rdfs:range' => [
×
919
                                    ['@id' => 'Collection'],
×
920
                                    [
×
921
                                        'owl:equivalentClass' => [
×
922
                                            'owl:onProperty' => ['@id' => 'member'],
×
923
                                            'owl:allValuesFrom' => ['@id' => '#dummy'],
×
924
                                        ],
×
925
                                    ],
×
926
                                ],
×
927
                                'supportedOperation' => [
×
928
                                    [
×
929
                                        '@type' => ['Operation', 'schema:FindAction'],
×
930
                                        'method' => 'GET',
×
931
                                        'title' => 'Retrieves the collection of dummy resources.',
×
932
                                        'rdfs:label' => 'Retrieves the collection of dummy resources.',
×
933
                                        'returns' => 'Collection',
×
934
                                    ],
×
935
                                    [
×
936
                                        '@type' => ['Operation', 'schema:CreateAction'],
×
937
                                        'expects' => 'dummy',
×
938
                                        'method' => 'POST',
×
939
                                        'title' => 'Creates a dummy resource.',
×
940
                                        'rdfs:label' => 'Creates a dummy resource.',
×
941
                                        'returns' => 'dummy',
×
942
                                    ],
×
943
                                ],
×
944
                            ],
×
945
                            'title' => 'The collection of dummy resources',
×
946
                            'readable' => true,
×
947
                            'writeable' => false,
×
948
                        ],
×
949
                    ],
×
950
                    'supportedOperation' => [
×
951
                        '@type' => 'Operation',
×
952
                        'method' => 'GET',
×
953
                        'rdfs:label' => 'The API entrypoint.',
×
954
                        'returns' => 'EntryPoint',
×
955
                    ],
×
956
                ],
×
957
                [
×
958
                    '@id' => '#ConstraintViolation',
×
959
                    '@type' => 'Class',
×
960
                    'title' => 'A constraint violation',
×
961
                    'supportedProperty' => [
×
962
                        [
×
963
                            '@type' => 'SupportedProperty',
×
964
                            'property' => [
×
965
                                '@id' => '#ConstraintViolation/propertyPath',
×
966
                                '@type' => 'rdf:Property',
×
967
                                'rdfs:label' => 'propertyPath',
×
968
                                'domain' => '#ConstraintViolation',
×
969
                                'range' => 'xmls:string',
×
970
                            ],
×
971
                            'title' => 'propertyPath',
×
972
                            'description' => 'The property path of the violation',
×
973
                            'readable' => true,
×
974
                            'writeable' => false,
×
975
                        ],
×
976
                        [
×
977
                            '@type' => 'SupportedProperty',
×
978
                            'property' => [
×
979
                                '@id' => '#ConstraintViolation/message',
×
980
                                '@type' => 'rdf:Property',
×
981
                                'rdfs:label' => 'message',
×
982
                                'domain' => '#ConstraintViolation',
×
983
                                'range' => 'xmls:string',
×
984
                            ],
×
985
                            'title' => 'message',
×
986
                            'description' => 'The message associated with the violation',
×
987
                            'readable' => true,
×
988
                            'writeable' => false,
×
989
                        ],
×
990
                    ],
×
991
                ],
×
992
                [
×
993
                    '@id' => '#ConstraintViolationList',
×
994
                    '@type' => 'Class',
×
995
                    'subClassOf' => 'Error',
×
996
                    'title' => 'A constraint violation list',
×
997
                    'supportedProperty' => [
×
998
                        [
×
999
                            '@type' => 'SupportedProperty',
×
1000
                            'property' => [
×
1001
                                '@id' => '#ConstraintViolationList/violations',
×
1002
                                '@type' => 'rdf:Property',
×
1003
                                'rdfs:label' => 'violations',
×
1004
                                'domain' => '#ConstraintViolationList',
×
1005
                                'range' => '#ConstraintViolation',
×
1006
                            ],
×
1007
                            'title' => 'violations',
×
1008
                            'description' => 'The violations',
×
1009
                            'readable' => true,
×
1010
                            'writeable' => false,
×
1011
                        ],
×
1012
                    ],
×
1013
                ],
×
1014
            ],
×
1015
            'entrypoint' => '/',
×
1016
        ];
×
1017

1018
        $this->assertEquals($expected, $documentationNormalizer->normalize($documentation, null, [ContextBuilder::HYDRA_CONTEXT_HAS_PREFIX => false]));
×
1019
    }
1020
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc