Skip to content

Commit 6cd53cd

Browse files
committed
Switch to a resource attribute to manage URL generation strategy
1 parent 3102fa5 commit 6cd53cd

Some content is hidden

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

47 files changed

+485
-346
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 & 20 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:
@@ -135,22 +135,6 @@ elasticsearch-no-legacy:
135135
filters:
136136
tags: '@elasticsearch&&~@legacy'
137137

138-
network-path:
139-
suites:
140-
default: false
141-
network-path:
142-
paths:
143-
- '%paths.base%/features/network_path'
144-
contexts:
145-
- 'DoctrineContext':
146-
doctrine: '@doctrine'
147-
passwordEncoder: '@security.password_encoder'
148-
- 'JsonContext'
149-
- 'Behatch\Context\RestContext'
150-
- 'Behat\MinkExtension\Context\MinkContext'
151-
filters:
152-
tags: '@networkPath'
153-
154138
default-coverage:
155139
suites:
156140
default:

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: 11 additions & 12 deletions
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
@@ -13,11 +12,11 @@ Feature: IRI should contain Absolute URL
1312
{
1413
"_links": {
1514
"self": {
16-
"href": "http:\/\/example.com\/absolute_url_dummies"
15+
"href": "http://example.com/absolute_url_dummies"
1716
},
1817
"item": [
1918
{
20-
"href": "http:\/\/example.com\/absolute_url_dummies\/1"
19+
"href": "http://example.com/absolute_url_dummies/1"
2120
}
2221
]
2322
},
@@ -28,10 +27,10 @@ Feature: IRI should contain Absolute URL
2827
{
2928
"_links": {
3029
"self": {
31-
"href": "http:\/\/example.com\/absolute_url_dummies\/1"
30+
"href": "http://example.com/absolute_url_dummies/1"
3231
},
3332
"absoluteUrlRelationDummy": {
34-
"href": "http:\/\/example.com\/absolute_url_relation_dummies\/1"
33+
"href": "http://example.com/absolute_url_relation_dummies/1"
3534
}
3635
},
3736
"id": 1
@@ -56,7 +55,7 @@ Feature: IRI should contain Absolute URL
5655
{
5756
"_links": {
5857
"self": {
59-
"href": "http:\/\/example.com\/absolute_url_relation_dummies\/2"
58+
"href": "http://example.com/absolute_url_relation_dummies/2"
6059
}
6160
},
6261
"id": 2
@@ -72,10 +71,10 @@ Feature: IRI should contain Absolute URL
7271
{
7372
"_links": {
7473
"self": {
75-
"href": "http:\/\/example.com\/absolute_url_dummies\/1"
74+
"href": "http://example.com/absolute_url_dummies/1"
7675
},
7776
"absoluteUrlRelationDummy": {
78-
"href": "http:\/\/example.com\/absolute_url_relation_dummies\/1"
77+
"href": "http://example.com/absolute_url_relation_dummies/1"
7978
}
8079
},
8180
"id": 1
@@ -91,11 +90,11 @@ Feature: IRI should contain Absolute URL
9190
{
9291
"_links": {
9392
"self": {
94-
"href": "http:\/\/example.com\/absolute_url_relation_dummies\/1\/absolute_url_dummies"
93+
"href": "http://example.com/absolute_url_relation_dummies/1/absolute_url_dummies"
9594
},
9695
"item": [
9796
{
98-
"href": "http:\/\/example.com\/absolute_url_dummies\/1"
97+
"href": "http://example.com/absolute_url_dummies/1"
9998
}
10099
]
101100
},
@@ -106,10 +105,10 @@ Feature: IRI should contain Absolute URL
106105
{
107106
"_links": {
108107
"self": {
109-
"href": "http:\/\/example.com\/absolute_url_dummies\/1"
108+
"href": "http://example.com/absolute_url_dummies/1"
110109
},
111110
"absoluteUrlRelationDummy": {
112-
"href": "http:\/\/example.com\/absolute_url_relation_dummies\/1"
111+
"href": "http://example.com/absolute_url_relation_dummies/1"
113112
}
114113
},
115114
"id": 1

0 commit comments

Comments
 (0)