Skip to content

Commit 1384f52

Browse files
committed
Switch to a resource attribute to manage URL generation strategy
1 parent 8083e87 commit 1384f52

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+452
-283
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ jobs:
353353
name: Run Behat tests
354354
command: |
355355
mkdir -p build/logs/behat build/coverage
356-
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature' -not -path 'features/elasticsearch/*' -not -path 'features/mongodb/*' -not -path 'features/absolute_url/*' -not -path 'features/network_path/*' | circleci tests split --split-by=timings); do
356+
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature' -not -path 'features/elasticsearch/*' -not -path 'features/mongodb/*' | circleci tests split --split-by=timings); do
357357
_f=$(echo "$f" | tr / _)
358358
FEATURE="${_f}" vendor/bin/behat --format=progress --out=std --format=junit --out=build/logs/behat/"${_f}" --profile=default-coverage --no-interaction --colors "$f"
359359
done

.travis.yml

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -244,45 +244,4 @@ jobs:
244244
- *validate-openapi-v3-json
245245
- *validate-openapi-v3-yaml
246246

247-
- php: '7.3'
248-
env: APP_ENV=absolute_url
249-
before_install:
250-
- *enable-mongodb-php-extension
251-
- *disable-xdebug-php-extension
252-
- *disable-php-memory-limit
253-
- *add-composer-bin-dir-to-path
254-
install:
255-
- *update-project-dependencies
256-
before_script:
257-
- *clear-test-app-cache
258-
script:
259-
- *run-phpunit-tests
260-
- *clear-test-app-cache
261-
- vendor/bin/behat --format=progress --profile=absolute-url --no-interaction
262-
- *validate-openapi-v2-json
263-
- *validate-openapi-v2-yaml
264-
- *validate-openapi-v3-json
265-
- *validate-openapi-v3-yaml
266-
267-
268-
- php: '7.3'
269-
env: APP_ENV=network_path
270-
before_install:
271-
- *enable-mongodb-php-extension
272-
- *disable-xdebug-php-extension
273-
- *disable-php-memory-limit
274-
- *add-composer-bin-dir-to-path
275-
install:
276-
- *update-project-dependencies
277-
before_script:
278-
- *clear-test-app-cache
279-
script:
280-
- *run-phpunit-tests
281-
- *clear-test-app-cache
282-
- vendor/bin/behat --format=progress --profile=network-path --no-interaction
283-
- *validate-openapi-v2-json
284-
- *validate-openapi-v2-yaml
285-
- *validate-openapi-v3-json
286-
- *validate-openapi-v3-yaml
287-
288247
fast_finish: true

behat.yml.dist

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ default:
2020
- 'Behat\MinkExtension\Context\MinkContext'
2121
- 'Behatch\Context\RestContext'
2222
filters:
23-
tags: '~@postgres&&~@mongodb&&~@elasticsearch&&~@absoluteUrl&&~@networkPath'
23+
tags: '~@postgres&&~@mongodb&&~@elasticsearch'
2424
extensions:
2525
'Behat\Symfony2Extension':
2626
kernel:
@@ -40,7 +40,7 @@ default-no-legacy:
4040
suites:
4141
default:
4242
filters:
43-
tags: '~@postgres&&~@mongodb&&~@elasticsearch&&~@legacy&&~@absoluteUrl&&~@networkPath'
43+
tags: '~@postgres&&~@mongodb&&~@elasticsearch&&~@legacy'
4444

4545
postgres:
4646
suites:
@@ -65,7 +65,7 @@ postgres:
6565
- 'Behat\MinkExtension\Context\MinkContext'
6666
- 'Behatch\Context\RestContext'
6767
filters:
68-
tags: '~@sqlite&&~@mongodb&&~@elasticsearch&&~@absoluteUrl&&~@networkPath'
68+
tags: '~@sqlite&&~@mongodb&&~@elasticsearch'
6969

7070
postgres-no-legacy:
7171
suites:
@@ -98,7 +98,7 @@ mongodb:
9898
- 'Behat\MinkExtension\Context\MinkContext'
9999
- 'Behatch\Context\RestContext'
100100
filters:
101-
tags: '~@sqlite&&~@elasticsearch&&~@!mongodb&&~@absoluteUrl&&~@networkPath'
101+
tags: '~@sqlite&&~@elasticsearch&&~@!mongodb'
102102

103103
mongodb-no-legacy:
104104
suites:

features/absolute_url/hal/entrypoint.feature

Lines changed: 0 additions & 7 deletions
This file was deleted.

features/absolute_url/jsonapi/entrypoint.feature

Lines changed: 0 additions & 7 deletions
This file was deleted.

features/absolute_url/jsonld/entrypoint.feature

Lines changed: 0 additions & 25 deletions
This file was deleted.

features/absolute_url/jsonld/errors.feature

Lines changed: 0 additions & 16 deletions
This file was deleted.

features/bootstrap/DoctrineContext.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\FourthLevel as FourthLevelDocument;
5252
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Greeting as GreetingDocument;
5353
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\MaxDepthDummy as MaxDepthDummyDocument;
54+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\NetworkPathDummy as NetworkPathDummyDocument;
55+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\NetworkPathRelationDummy as NetworkPathRelationDummyDocument;
5456
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Order as OrderDocument;
5557
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\Person as PersonDocument;
5658
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Document\PersonToPet as PersonToPetDocument;
@@ -111,6 +113,8 @@
111113
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Greeting;
112114
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\InternalUser;
113115
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\MaxDepthDummy;
116+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\NetworkPathDummy;
117+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\NetworkPathRelationDummy;
114118
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Node;
115119
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Order;
116120
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Person;
@@ -1523,6 +1527,23 @@ public function thereAreAbsoluteUrlDummies(int $nb)
15231527
$this->manager->flush();
15241528
}
15251529

1530+
/**
1531+
* @Given there are :nb networkPathDummy objects with a related networkPathRelationDummy
1532+
*/
1533+
public function thereArenetworkPathDummies(int $nb)
1534+
{
1535+
for ($i = 1; $i <= $nb; ++$i) {
1536+
$networkPathRelationDummy = $this->buildNetworkPathRelationDummy();
1537+
$networkPathDummy = $this->buildNetworkPathDummy();
1538+
$networkPathDummy->networkPathRelationDummy = $networkPathRelationDummy;
1539+
1540+
$this->manager->persist($networkPathRelationDummy);
1541+
$this->manager->persist($networkPathDummy);
1542+
}
1543+
1544+
$this->manager->flush();
1545+
}
1546+
15261547
private function isOrm(): bool
15271548
{
15281549
return null !== $this->schemaTool;
@@ -1916,4 +1937,20 @@ private function buildAbsoluteUrlRelationDummy()
19161937
{
19171938
return $this->isOrm() ? new AbsoluteUrlRelationDummy() : new AbsoluteUrlRelationDummyDocument();
19181939
}
1940+
1941+
/**
1942+
* @return NetworkPathDummyDocument|NetworkPathDummy
1943+
*/
1944+
private function buildNetworkPathDummy()
1945+
{
1946+
return $this->isOrm() ? new NetworkPathDummy() : new NetworkPathDummyDocument();
1947+
}
1948+
1949+
/**
1950+
* @return NetworkPathRelationDummyDocument|NetworkPathRelationDummy
1951+
*/
1952+
private function buildNetworkPathRelationDummy()
1953+
{
1954+
return $this->isOrm() ? new NetworkPathRelationDummy() : new NetworkPathRelationDummyDocument();
1955+
}
19191956
}

features/absolute_url/hal/absolute_url.feature renamed to features/hal/absolute_url.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@absoluteUrl
21
Feature: IRI should contain Absolute URL
32
In order to add detail to IRIs
43
Include the absolute url

features/network_path/hal/network_path.feature renamed to features/hal/network_path.feature

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
1-
@networkPath
21
Feature: IRI should contain network path
32
In order to add detail to IRIs
43
Include the network path
54

65
@createSchema
76
Scenario: I should be able to GET a collection of objects with network paths
8-
Given there are 1 absoluteUrlDummy objects with a related absoluteUrlRelationDummy
7+
Given there are 1 networkPathDummy objects with a related networkPathRelationDummy
98
And I add "Accept" header equal to "application/hal+json"
10-
And I send a "GET" request to "/absolute_url_dummies"
9+
And I send a "GET" request to "/network_path_dummies"
1110
And the JSON should be equal to:
1211
"""
1312
{
1413
"_links": {
1514
"self": {
16-
"href": "\/\/example.com\/absolute_url_dummies"
15+
"href": "\/\/example.com\/network_path_dummies"
1716
},
1817
"item": [
1918
{
20-
"href": "\/\/example.com\/absolute_url_dummies\/1"
19+
"href": "\/\/example.com\/network_path_dummies\/1"
2120
}
2221
]
2322
},
@@ -28,10 +27,10 @@ Feature: IRI should contain network path
2827
{
2928
"_links": {
3029
"self": {
31-
"href": "\/\/example.com\/absolute_url_dummies\/1"
30+
"href": "\/\/example.com\/network_path_dummies\/1"
3231
},
33-
"absoluteUrlRelationDummy": {
34-
"href": "\/\/example.com\/absolute_url_relation_dummies\/1"
32+
"networkPathRelationDummy": {
33+
"href": "\/\/example.com\/network_path_relation_dummies\/1"
3534
}
3635
},
3736
"id": 1
@@ -44,10 +43,10 @@ Feature: IRI should contain network path
4443
Scenario: I should be able to POST an object using a network path
4544
Given I add "Accept" header equal to "application/hal+json"
4645
And I add "Content-Type" header equal to "application/json"
47-
And I send a "POST" request to "/absolute_url_relation_dummies" with body:
46+
And I send a "POST" request to "/network_path_relation_dummies" with body:
4847
"""
4948
{
50-
"absolute_url_dummies": "//example.com/absolute_url_dummies/1"
49+
"network_path_dummies": "//example.com/network_path_dummies/1"
5150
}
5251
"""
5352
Then the response status code should be 201
@@ -56,7 +55,7 @@ Feature: IRI should contain network path
5655
{
5756
"_links": {
5857
"self": {
59-
"href": "\/\/example.com\/absolute_url_relation_dummies\/2"
58+
"href": "\/\/example.com\/network_path_relation_dummies\/2"
6059
}
6160
},
6261
"id": 2
@@ -65,16 +64,16 @@ Feature: IRI should contain network path
6564

6665
Scenario: I should be able to GET an Item with network paths
6766
Given I add "Accept" header equal to "application/hal+json"
68-
And I send a "GET" request to "/absolute_url_dummies/1"
67+
And I send a "GET" request to "/network_path_dummies/1"
6968
And the JSON should be equal to:
7069
"""
7170
{
7271
"_links": {
7372
"self": {
74-
"href": "\/\/example.com\/absolute_url_dummies\/1"
73+
"href": "\/\/example.com\/network_path_dummies\/1"
7574
},
76-
"absoluteUrlRelationDummy": {
77-
"href": "\/\/example.com\/absolute_url_relation_dummies\/1"
75+
"networkPathRelationDummy": {
76+
"href": "\/\/example.com\/network_path_relation_dummies\/1"
7877
}
7978
},
8079
"id": 1
@@ -83,17 +82,17 @@ Feature: IRI should contain network path
8382

8483
Scenario: I should be able to GET subresources with network paths
8584
Given I add "Accept" header equal to "application/hal+json"
86-
And I send a "GET" request to "/absolute_url_relation_dummies/1/absolute_url_dummies"
85+
And I send a "GET" request to "/network_path_relation_dummies/1/network_path_dummies"
8786
And the JSON should be equal to:
8887
"""
8988
{
9089
"_links": {
9190
"self": {
92-
"href": "\/\/example.com\/absolute_url_relation_dummies\/1\/absolute_url_dummies"
91+
"href": "\/\/example.com\/network_path_relation_dummies\/1\/network_path_dummies"
9392
},
9493
"item": [
9594
{
96-
"href": "\/\/example.com\/absolute_url_dummies\/1"
95+
"href": "\/\/example.com\/network_path_dummies\/1"
9796
}
9897
]
9998
},
@@ -104,10 +103,10 @@ Feature: IRI should contain network path
104103
{
105104
"_links": {
106105
"self": {
107-
"href": "\/\/example.com\/absolute_url_dummies\/1"
106+
"href": "\/\/example.com\/network_path_dummies\/1"
108107
},
109-
"absoluteUrlRelationDummy": {
110-
"href": "\/\/example.com\/absolute_url_relation_dummies\/1"
108+
"networkPathRelationDummy": {
109+
"href": "\/\/example.com\/network_path_relation_dummies\/1"
111110
}
112111
},
113112
"id": 1

features/absolute_url/jsonapi/absolute_url.feature renamed to features/jsonapi/absolute_url.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@absoluteUrl
21
Feature: IRI should contain Absolute URL
32
In order to add detail to IRIs
43
Include the absolute url

0 commit comments

Comments
 (0)