Skip to content

Commit ca48787

Browse files
antograssiotdunglas
authored andcommitted
hydra:view schema validation (#967)
* Fix Behatch namespace * Fix all hydra:view pattern check in json schema validation * Bump Behatch requirement
1 parent bcaf523 commit ca48787

12 files changed

+212
-101
lines changed

behat.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ default:
66
- 'HydraContext'
77
- 'SwaggerContext'
88
- 'Behat\MinkExtension\Context\MinkContext'
9-
- 'Sanpi\Behatch\Context\RestContext'
10-
- 'Sanpi\Behatch\Context\JsonContext'
9+
- 'Behatch\Context\RestContext'
10+
- 'Behatch\Context\JsonContext'
1111
extensions:
1212
'Behat\Symfony2Extension':
1313
kernel:
@@ -32,5 +32,5 @@ coverage:
3232
- 'SwaggerContext'
3333
- 'CoverageContext'
3434
- 'Behat\MinkExtension\Context\MinkContext'
35-
- 'Sanpi\Behatch\Context\RestContext'
36-
- 'Sanpi\Behatch\Context\JsonContext'
35+
- 'Behatch\Context\RestContext'
36+
- 'Behatch\Context\JsonContext'

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"behat/mink-browserkit-driver": "^1.3.1",
3030
"behat/mink-extension": "^2.2",
3131
"behat/symfony2-extension": "^2.1",
32-
"behatch/contexts": "^2.5",
32+
"behatch/contexts": "^2.6",
3333
"doctrine/doctrine-bundle": "^1.6.3",
3434
"doctrine/orm": "^2.5",
3535
"doctrine/annotations": "^1.2",

features/bootstrap/FeatureContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\UuidIdentifierDummy;
2020
use Behat\Behat\Context\Context;
2121
use Behat\Behat\Context\SnippetAcceptingContext;
22+
use Behatch\HttpCall\Request;
2223
use Doctrine\Common\Persistence\ManagerRegistry;
2324
use Doctrine\ORM\Tools\SchemaTool;
24-
use Sanpi\Behatch\HttpCall\Request;
2525

2626
/**
2727
* Defines application features from the specific context.

features/bootstrap/HydraContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function gatherContexts(BeforeScenarioScope $scope)
3737
{
3838
/** @var InitializedContextEnvironment $environment */
3939
$environment = $scope->getEnvironment();
40-
$this->restContext = $environment->getContext('Sanpi\Behatch\Context\RestContext');
40+
$this->restContext = $environment->getContext('Behatch\Context\RestContext');
4141
}
4242

4343
/**

features/bootstrap/SwaggerContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use Behat\Behat\Context\Context;
1313
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
1414
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
15-
use Sanpi\Behatch\Context\RestContext;
15+
use Behatch\Context\RestContext;
1616
use Symfony\Component\PropertyAccess\PropertyAccess;
1717

1818
final class SwaggerContext implements Context

features/doctrine/date_filter.feature

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Feature: Date filter on collections
7575
"hydra:view": {
7676
"type": "object",
7777
"properties": {
78-
"@id": {"pattern": "^/dummies\\?dummyDate%5Bbefore%5D=2015-04-05\\&page=1$"},
78+
"@id": {"pattern": "^/dummies\\?dummyDate%5Bbefore%5D=2015-04-05&page=1$"},
7979
"@type": {"pattern": "^hydra:PartialCollectionView$"}
8080
}
8181
}
@@ -152,7 +152,7 @@ Feature: Date filter on collections
152152
"hydra:view": {
153153
"type": "object",
154154
"properties": {
155-
"@id": {"pattern": "^/dummies\\?dummyDate%5Bbefore%5D=2015-04-05Z\\&page=1$"},
155+
"@id": {"pattern": "^/dummies\\?dummyDate%5Bbefore%5D=2015-04-05Z&page=1$"},
156156
"@type": {"pattern": "^hydra:PartialCollectionView$"}
157157
}
158158
}
@@ -191,7 +191,7 @@ Feature: Date filter on collections
191191
"hydra:view": {
192192
"type": "object",
193193
"properties": {
194-
"@id": {"pattern": "^/dummies\\?dummyDate%5Bbefore%5D=2015-04-05\\&dummyDate%5Bafter%5D=2015-04-05$"},
194+
"@id": {"pattern": "^/dummies\\?dummyDate%5Bbefore%5D=2015-04-05&dummyDate%5Bafter%5D=2015-04-05$"},
195195
"@type": {"pattern": "^hydra:PartialCollectionView$"}
196196
}
197197
}
@@ -256,7 +256,7 @@ Feature: Date filter on collections
256256
"hydra:view": {
257257
"type": "object",
258258
"properties": {
259-
"@id": {"pattern": "^/dummies\\?dummyDate%5Bafter%5D=2015-04-06\\&dummyDate%5Bbefore%5D=2015-04-04$"},
259+
"@id": {"pattern": "^/dummies\\?dummyDate%5Bafter%5D=2015-04-06&dummyDate%5Bbefore%5D=2015-04-04$"},
260260
"@type": {"pattern": "^hydra:PartialCollectionView$"}
261261
}
262262
}
@@ -296,8 +296,11 @@ Feature: Date filter on collections
296296
"maxItems": 3
297297
},
298298
"hydra:view": {
299-
"@id": {"pattern": "^/dummies\\?relatedDummy\\.dummyDate%5Bafter%5D=2015-04-28$"},
300-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
299+
"type": "object",
300+
"properties": {
301+
"@id": {"pattern": "^/dummies\\?relatedDummy\\.dummyDate%5Bafter%5D=2015-04-28$"},
302+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
303+
}
301304
}
302305
}
303306
}
@@ -334,7 +337,7 @@ Feature: Date filter on collections
334337
"hydra:view": {
335338
"type": "object",
336339
"properties": {
337-
"@id": {"pattern": "^/dummies\\?relatedDummy\\.dummyDate%5Bafter%5D=2015-04-28\\&relatedDummy_dummyDate%5Bafter%5D=2015-04-28$"},
340+
"@id": {"pattern": "^/dummies\\?relatedDummy\\.dummyDate%5Bafter%5D=2015-04-28&relatedDummy_dummyDate%5Bafter%5D=2015-04-28$"},
338341
"@type": {"pattern": "^hydra:PartialCollectionView$"}
339342
}
340343
}
@@ -371,8 +374,11 @@ Feature: Date filter on collections
371374
"maxItems": 3
372375
},
373376
"hydra:view": {
374-
"@id": {"pattern": "^/dummies\\?relatedDummy\\.dummyDate%5Bafter%5D=2015-04-28T00%3A00%3A00%2B00%3A00$"},
375-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
377+
"type": "object",
378+
"properties": {
379+
"@id": {"pattern": "^/dummies\\?relatedDummy\\.dummyDate%5Bafter%5D=2015-04-28T00%3A00%3A00%2B00%3A00$"},
380+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
381+
}
376382
}
377383
}
378384
}

features/doctrine/numeric_filter.feature

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ Feature: Numeric filter on collections
2323
"maxItems": 0
2424
},
2525
"hydra:view": {
26-
"@id": {"pattern": "^/dummies\\?id=9.99$"},
27-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
26+
"type": "object",
27+
"properties": {
28+
"@id": {"pattern": "^/dummies\\?id=9.99$"},
29+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
30+
}
2831
}
2932
}
3033
}
@@ -57,8 +60,11 @@ Feature: Numeric filter on collections
5760
}
5861
},
5962
"hydra:view": {
60-
"@id": {"pattern": "^/dummies\\?id=10"},
61-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
63+
"type": "object",
64+
"properties": {
65+
"@id": {"pattern": "^/dummies\\?id=10"},
66+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
67+
}
6268
}
6369
}
6470
}
@@ -95,8 +101,11 @@ Feature: Numeric filter on collections
95101
}
96102
},
97103
"hydra:view": {
98-
"@id": {"pattern": "^/dummies\\?unknown=0"},
99-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
104+
"type": "object",
105+
"properties": {
106+
"@id": {"pattern": "^/dummies\\?unknown=0"},
107+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
108+
}
100109
}
101110
}
102111
}
@@ -130,8 +139,11 @@ Feature: Numeric filter on collections
130139
}
131140
},
132141
"hydra:view": {
133-
"@id": {"pattern": "^/dummies\\?unknown=1$"},
134-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
142+
"type": "object",
143+
"properties": {
144+
"@id": {"pattern": "^/dummies\\?unknown=1"},
145+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
146+
}
135147
}
136148
}
137149
}

features/doctrine/order_filter.feature

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ Feature: Order filter on collections
5454
"minItems": 3
5555
},
5656
"hydra:view": {
57-
"@id": {"pattern": "^/dummies\\?order\\[id\\]=asc$"},
58-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
57+
"type": "object",
58+
"properties": {
59+
"@id": {"pattern": "^/dummies\\?order%5Bid%5D=asc"},
60+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
61+
}
5962
}
6063
}
6164
}
@@ -110,8 +113,11 @@ Feature: Order filter on collections
110113
"minItems": 3
111114
},
112115
"hydra:view": {
113-
"@id": {"pattern": "^/dummies\\?order\\[id\\]=desc"},
114-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
116+
"type": "object",
117+
"properties": {
118+
"@id": {"pattern": "^/dummies\\?order%5Bid%5D=desc"},
119+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
120+
}
115121
}
116122
}
117123
}
@@ -166,8 +172,11 @@ Feature: Order filter on collections
166172
"minItems": 3
167173
},
168174
"hydra:view": {
169-
"@id": {"pattern": "^/dummies\\?order\\[name\\]=asc$"},
170-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
175+
"type": "object",
176+
"properties": {
177+
"@id": {"pattern": "^/dummies\\?order%5Bname%5D=asc"},
178+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
179+
}
171180
}
172181
}
173182
}
@@ -222,8 +231,11 @@ Feature: Order filter on collections
222231
"minItems": 3
223232
},
224233
"hydra:view": {
225-
"@id": {"pattern": "^/dummies\\?order\\[name\\]=desc$"},
226-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
234+
"type": "object",
235+
"properties": {
236+
"@id": {"pattern": "^/dummies\\?order%5Bname%5D=desc"},
237+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
238+
}
227239
}
228240
}
229241
}
@@ -278,8 +290,11 @@ Feature: Order filter on collections
278290
"minItems": 3
279291
},
280292
"hydra:view": {
281-
"@id": {"pattern": "^/dummies\\?order\\[name\\]$"},
282-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
293+
"type": "object",
294+
"properties": {
295+
"@id": {"pattern": "^/dummies\\?order%5Bname%5D="},
296+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
297+
}
283298
}
284299
}
285300
}
@@ -335,8 +350,11 @@ Feature: Order filter on collections
335350
"minItems": 3
336351
},
337352
"hydra:view": {
338-
"@id": {"pattern": "^/dummies\\?order\\[relatedDummy\\]=asc$"},
339-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
353+
"type": "object",
354+
"properties": {
355+
"@id": {"pattern": "^/dummies\\?order%5BrelatedDummy%5D=asc"},
356+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
357+
}
340358
}
341359
}
342360
}
@@ -392,8 +410,11 @@ Feature: Order filter on collections
392410
"minItems": 3
393411
},
394412
"hydra:view": {
395-
"@id": {"pattern": "^/dummies\\?order\\[alias\\]=asc$"},
396-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
413+
"type": "object",
414+
"properties": {
415+
"@id": {"pattern": "^/dummies\\?order%5Balias%5D=asc"},
416+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
417+
}
397418
}
398419
}
399420
}
@@ -447,8 +468,11 @@ Feature: Order filter on collections
447468
"minItems": 3
448469
},
449470
"hydra:view": {
450-
"@id": {"pattern": "^/dummies\\?order\\[alias\\]=desc$"},
451-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
471+
"type": "object",
472+
"properties": {
473+
"@id": {"pattern": "^/dummies\\?order%5Balias%5D=desc"},
474+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
475+
}
452476
}
453477
}
454478
}
@@ -502,8 +526,11 @@ Feature: Order filter on collections
502526
"minItems": 3
503527
},
504528
"hydra:view": {
505-
"@id": {"pattern": "^/dummies\\?order\\[unknown\\]=asc$"},
506-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
529+
"type": "object",
530+
"properties": {
531+
"@id": {"pattern": "^/dummies\\?order%5Bunknown%5D=asc"},
532+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
533+
}
507534
}
508535
}
509536
}
@@ -557,8 +584,11 @@ Feature: Order filter on collections
557584
"minItems": 3
558585
},
559586
"hydra:view": {
560-
"@id": {"pattern": "^/dummies\\?order\\[unknown\\]=desc$"},
561-
"@type": {"pattern": "^hydra:PartialCollectionView$"}
587+
"type": "object",
588+
"properties": {
589+
"@id": {"pattern": "^/dummies\\?order%5Bunknown%5D=desc"},
590+
"@type": {"pattern": "^hydra:PartialCollectionView$"}
591+
}
562592
}
563593
}
564594
}

0 commit comments

Comments
 (0)