Skip to content

Commit 293d722

Browse files
authored
Merge 592af01 into d4cfd02
2 parents d4cfd02 + 592af01 commit 293d722

38 files changed

+918
-643
lines changed

.circleci/config.yml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
version: 2
2+
3+
reusable-steps:
4+
- &clear-test-app-cache
5+
run:
6+
name: Clear test app cache
7+
command: tests/Fixtures/app/console cache:clear
8+
- &disable-php-memory-limit
9+
run:
10+
name: Disable PHP memory limit
11+
command: echo 'memory_limit=-1' | sudo tee -a /usr/local/etc/php/php.ini
12+
- &disable-xdebug-php-extension
13+
run:
14+
name: Disable Xdebug PHP extension
15+
command: sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
16+
- &restore-composer-cache
17+
restore_cache:
18+
keys:
19+
- composer-cache-{{ .Revision }}
20+
- composer-cache-{{ .Branch }}
21+
- composer-cache
22+
- &restore-npm-cache
23+
restore_cache:
24+
keys:
25+
- npm-cache-{{ .Revision }}
26+
- npm-cache-{{ .Branch }}
27+
- npm-cache
28+
- &save-composer-cache-by-branch
29+
save_cache:
30+
paths:
31+
- ~/.composer/cache
32+
key: composer-cache-{{ .Branch }}-{{ .BuildNum }}
33+
- &save-composer-cache-by-revision
34+
save_cache:
35+
paths:
36+
- ~/.composer/cache
37+
key: composer-cache-{{ .Revision }}-{{ .BuildNum }}
38+
- &save-npm-cache-by-branch
39+
save_cache:
40+
paths:
41+
- ~/.npm
42+
key: npm-cache-{{ .Branch }}-{{ .BuildNum }}
43+
- &save-npm-cache-by-revision
44+
save_cache:
45+
paths:
46+
- ~/.npm
47+
key: npm-cache-{{ .Revision }}-{{ .BuildNum }}
48+
- &update-composer
49+
run:
50+
name: Update Composer
51+
command: composer self-update
52+
- &update-project-dependencies
53+
run:
54+
name: Update project dependencies
55+
command: composer update --prefer-dist --no-progress --no-suggest --ansi
56+
57+
jobs:
58+
phpunit-php-7.2-coverage:
59+
docker:
60+
- image: circleci/php:7.2-node-browsers
61+
environment:
62+
SYMFONY_DEPRECATIONS_HELPER: weak_vendors
63+
APP_ENV: test
64+
parallelism: 2
65+
working_directory: ~/api-platform/core
66+
steps:
67+
- checkout
68+
- *restore-composer-cache
69+
- *restore-npm-cache
70+
- *disable-xdebug-php-extension
71+
- *disable-php-memory-limit
72+
- *update-composer
73+
- *update-project-dependencies
74+
- *save-composer-cache-by-revision
75+
- *save-composer-cache-by-branch
76+
- *clear-test-app-cache
77+
- run:
78+
name: Run PHPUnit tests
79+
command: |-
80+
mkdir -p build/logs/tmp build/cov
81+
find tests -name '*Test.php' | circleci tests split --split-by=timings | parallel -j10% --rpl '{_} s/\//_/g;' \
82+
phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-{_}.cov --log-junit build/logs/tmp/{_}.xml --colors=always {}
83+
- run:
84+
name: Merge PHPUnit test reports
85+
command: |-
86+
mkdir -p build/logs/phpunit
87+
npx junit-merge --out build/logs/phpunit/junit.xml --dir build/logs/tmp
88+
rm -r build/logs/tmp
89+
- store_test_results:
90+
path: build/logs
91+
- store_artifacts:
92+
path: build/logs/phpunit/junit.xml
93+
destination: build/logs/phpunit/junit.xml
94+
- persist_to_workspace:
95+
root: build
96+
paths:
97+
- cov
98+
- *save-npm-cache-by-revision
99+
- *save-npm-cache-by-branch
100+
101+
behat-php-7.2-coverage:
102+
docker:
103+
- image: circleci/php:7.2-node-browsers
104+
environment:
105+
SYMFONY_DEPRECATIONS_HELPER: weak_vendors
106+
APP_ENV: test
107+
parallelism: 2
108+
working_directory: ~/api-platform/core
109+
steps:
110+
- checkout
111+
- *restore-composer-cache
112+
- *restore-npm-cache
113+
- *disable-xdebug-php-extension
114+
- *disable-php-memory-limit
115+
- *update-composer
116+
- *update-project-dependencies
117+
- *save-composer-cache-by-revision
118+
- *save-composer-cache-by-branch
119+
- *clear-test-app-cache
120+
- run:
121+
name: Run Behat tests
122+
command: |-
123+
mkdir -p build/logs/tmp build/cov
124+
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature' | circleci tests split --split-by=timings); do
125+
_f=${f//\//_}
126+
FEATURE="${_f}" phpdbg -qrr vendor/bin/behat --profile=coverage --suite=default --tags=~@postgres --format=progress --out=std --format=junit --out=build/logs/tmp/"${_f}" "$f"
127+
done
128+
- run:
129+
name: Merge Behat test reports
130+
command: |-
131+
mkdir -p build/logs/behat
132+
npx junit-merge --out build/logs/behat/junit.xml --dir build/logs/tmp --recursive
133+
rm -r build/logs/tmp
134+
- store_test_results:
135+
path: build/logs
136+
- store_artifacts:
137+
path: build/logs/behat/junit.xml
138+
destination: build/logs/behat/junit.xml
139+
- persist_to_workspace:
140+
root: build
141+
paths:
142+
- cov
143+
- *save-npm-cache-by-revision
144+
- *save-npm-cache-by-branch
145+
146+
merge-and-upload-coverage:
147+
docker:
148+
- image: circleci/php:7.2-node-browsers
149+
working_directory: ~/api-platform/core
150+
steps:
151+
- checkout
152+
- *restore-npm-cache
153+
- *disable-xdebug-php-extension
154+
- *disable-php-memory-limit
155+
- run:
156+
name: Download phpcov
157+
command: wget https://phar.phpunit.de/phpcov.phar
158+
- attach_workspace:
159+
at: build
160+
- run:
161+
name: Merge code coverage reports
162+
command: |-
163+
mkdir -p build/logs
164+
phpdbg -qrr phpcov.phar merge --clover build/logs/clover.xml build/cov
165+
- store_artifacts:
166+
path: build/logs/clover.xml
167+
destination: build/logs/clover.xml
168+
- run:
169+
name: Upload code coverage report to Coveralls
170+
command: |-
171+
if [ ! -z "$COVERALLS_REPO_TOKEN" ]; then
172+
npx @cedx/coveralls build/logs/clover.xml
173+
else
174+
echo 'Skipped'
175+
fi
176+
- run:
177+
name: Upload code coverage report to Codecov
178+
command: npx codecov --file=build/logs/clover.xml --disable=gcov
179+
- *save-npm-cache-by-revision
180+
- *save-npm-cache-by-branch
181+
182+
workflows:
183+
version: 2
184+
test-with-coverage:
185+
jobs:
186+
- phpunit-php-7.2-coverage
187+
- behat-php-7.2-coverage
188+
- merge-and-upload-coverage:
189+
requires:
190+
- phpunit-php-7.2-coverage
191+
- behat-php-7.2-coverage

.editorconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ indent_style = space
3939
indent_size = 4
4040
trim_trailing_whitespace = false
4141

42+
[.circleci/config.yml]
43+
indent_style = space
44+
indent_size = 2
45+
4246
[.gitmodules]
4347
indent_style = tab
4448

.travis.yml

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
language: php
2-
32
sudo: false
43

54
cache:
@@ -17,8 +16,6 @@ matrix:
1716
- php: '7.0'
1817
- php: '7.1'
1918
- php: '7.2'
20-
- php: '7.2'
21-
env: coverage=1
2219
- php: '7.2'
2320
env: lint=1
2421
- php: '7.2'
@@ -43,18 +40,6 @@ matrix:
4340
before_install:
4441
- phpenv config-rm xdebug.ini || echo "xdebug not available"
4542
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
46-
- if [[ $coverage != 1 && $lint != 1 ]]; then
47-
npm install -g swagger-cli;
48-
fi
49-
- if [[ $coverage = 1 ]]; then
50-
mkdir -p build/logs build/cov;
51-
fi
52-
- if [[ $coverage = 1 ]]; then
53-
wget https://phar.phpunit.de/phpcov.phar;
54-
fi
55-
- if [[ $coverage = 1 ]]; then
56-
wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar;
57-
fi
5843
- if [[ $lint = 1 ]]; then
5944
wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.8.4/php-cs-fixer.phar;
6045
fi
@@ -64,47 +49,36 @@ before_install:
6449
- export PATH="$PATH:$HOME/.composer/vendor/bin"
6550

6651
install:
67-
- if [[ $coverage = 1 ]]; then
68-
composer require --dev --no-update 'phpunit/php-code-coverage:^5.2.2';
69-
fi
7052
- if [[ $deps = 'low' ]]; then
7153
composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi;
7254
else
7355
composer update --prefer-dist --no-progress --no-suggest --ansi;
7456
fi
7557

7658
script:
77-
- if [[ $coverage = 1 ]]; then
78-
APP_ENV=test_phpunit phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-phpunit.cov;
79-
elif [[ $lint != 1 ]]; then
80-
APP_ENV=test_phpunit vendor/bin/phpunit;
59+
- if [[ $lint != 1 ]]; then
60+
tests/Fixtures/app/console cache:clear;
61+
fi
62+
- if [[ $lint != 1 ]]; then
63+
vendor/bin/phpunit;
64+
fi
65+
- if [[ $lint != 1 ]]; then
66+
tests/Fixtures/app/console cache:clear;
8167
fi
82-
- if [[ $coverage = 1 ]]; then
83-
for f in $(find features -name '*.feature' -not -path 'features/main/exposed_state.feature'); do
84-
FEATURE=${f//\//_} phpdbg -qrr vendor/bin/behat --profile=coverage --suite=default --tags=~@postgress --format=progress $f || exit $?;
85-
done;
86-
elif [[ $APP_ENV = 'postgres' ]]; then
68+
- if [[ $APP_ENV = 'postgres' ]]; then
8769
vendor/bin/behat --suite=postgres --format=progress;
8870
elif [[ $lint != 1 ]]; then
8971
vendor/bin/behat --suite=default --format=progress;
9072
fi
91-
- if [[ $coverage = 1 ]]; then
92-
phpdbg -qrr phpcov.phar merge --clover build/logs/clover.xml build/cov;
73+
- if [[ $lint != 1 ]]; then
74+
tests/Fixtures/app/console api:swagger:export > swagger.json && npx swagger-cli validate swagger.json && rm swagger.json;
9375
fi
94-
- if [[ $coverage != 1 && $lint != 1 ]]; then
95-
tests/Fixtures/app/console api:swagger:export > swagger.json && swagger-cli validate swagger.json && rm swagger.json;
96-
fi
97-
- if [[ $coverage != 1 && $lint != 1 ]]; then
98-
tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && swagger-cli validate --no-schema swagger.yaml && rm swagger.yaml;
76+
- if [[ $lint != 1 ]]; then
77+
tests/Fixtures/app/console api:swagger:export --yaml > swagger.yaml && npx swagger-cli validate --no-schema swagger.yaml && rm swagger.yaml;
9978
fi
10079
- if [[ $lint = 1 ]]; then
10180
php php-cs-fixer.phar fix --dry-run --diff --no-ansi;
10281
fi
10382
- if [[ $lint = 1 ]]; then
10483
phpstan analyse -c phpstan.neon -l5 --ansi src tests;
10584
fi
106-
107-
after_success:
108-
- if [[ $coverage = 1 ]]; then
109-
travis_retry php coveralls.phar;
110-
fi

features/bootstrap/FeatureContext.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FileConfigDummy;
3434
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Foo;
3535
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FooDummy;
36+
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\FourthLevel;
3637
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Node;
3738
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Person;
3839
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\PersonToPet;
@@ -732,6 +733,7 @@ public function thereIsARelatedDummyWithFriends(int $nb)
732733
$relatedDummy2->setName('RelatedDummy without friends');
733734
$this->manager->persist($relatedDummy2);
734735
$this->manager->flush();
736+
$this->manager->clear();
735737
}
736738

737739
/**
@@ -883,4 +885,38 @@ public function thereIsARamseyIdentifiedResource(string $uuid)
883885
$this->manager->persist($dummy);
884886
$this->manager->flush();
885887
}
888+
889+
/**
890+
* @Given there is a dummy object with a fourth level relation
891+
*/
892+
public function thereIsADummyObjectWithAFourthLevelRelation()
893+
{
894+
$fourthLevel = new FourthLevel();
895+
$fourthLevel->setLevel(4);
896+
$this->manager->persist($fourthLevel);
897+
898+
$thirdLevel = new ThirdLevel();
899+
$thirdLevel->setLevel(3);
900+
$thirdLevel->setFourthLevel($fourthLevel);
901+
$this->manager->persist($thirdLevel);
902+
903+
$namedRelatedDummy = new RelatedDummy();
904+
$namedRelatedDummy->setName('Hello');
905+
$namedRelatedDummy->setThirdLevel($thirdLevel);
906+
$this->manager->persist($namedRelatedDummy);
907+
908+
$relatedDummy = new RelatedDummy();
909+
$relatedDummy = new RelatedDummy();
910+
$relatedDummy->setThirdLevel($thirdLevel);
911+
$this->manager->persist($relatedDummy);
912+
913+
$dummy = new Dummy();
914+
$dummy->setName('Dummy with relations');
915+
$dummy->setRelatedDummy($namedRelatedDummy);
916+
$dummy->addRelatedDummy($namedRelatedDummy);
917+
$dummy->addRelatedDummy($relatedDummy);
918+
$this->manager->persist($dummy);
919+
920+
$this->manager->flush();
921+
}
886922
}

features/doctrine/search_filter.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Feature: Search filter on collections
1010
And I send a "GET" request to "/related_dummies?relatedToDummyFriend.dummyFriend=/dummy_friends/4"
1111
Then the response status code should be 200
1212
And the JSON node "_embedded.item" should have 1 element
13+
And the JSON node "_embedded.item[0].id" should be equal to the number 1
1314
And the JSON node "_embedded.item[0]._links.relatedToDummyFriend" should have 4 elements
1415
And the JSON node "_embedded.item[0]._embedded.relatedToDummyFriend" should have 4 elements
1516

features/main/non_resource.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Feature: Non-resources handling
1111
"@context": "/contexts/ContainNonResource",
1212
"@id": "/contain_non_resources/1",
1313
"@type": "ContainNonResource",
14-
"id": "1",
14+
"id": 1,
1515
"nested": {
1616
"@id": "/contain_non_resources/1-nested",
1717
"@type": "ContainNonResource",

0 commit comments

Comments
 (0)