Skip to content

Commit 62ffeae

Browse files
Merge pull request #1447 from meyerbaptiste/merge_2.1
Merge branch '2.1'
2 parents 4b3d1ab + d5447b3 commit 62ffeae

File tree

164 files changed

+951
-655
lines changed

Some content is hidden

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

164 files changed

+951
-655
lines changed

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ matrix:
1515
include:
1616
- php: '7.0'
1717
- php: '7.1'
18+
- php: '7.2'
1819
env: coverage=1 lint=1
19-
- php: '7.1'
20+
- php: '7.2'
2021
env: deps='low'
21-
- php: '7.1'
22+
- php: '7.2'
2223
env: SYMFONY_DEPRECATIONS_HELPER=0
2324
allow_failures:
2425
env: SYMFONY_DEPRECATIONS_HELPER=0
@@ -31,11 +32,11 @@ before_install:
3132
- if [[ $coverage = 1 ]]; then mkdir -p build/logs build/cov; fi
3233
- if [[ $coverage = 1 ]]; then wget https://phar.phpunit.de/phpcov.phar; fi
3334
- if [[ $coverage = 1 ]]; then wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi
34-
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.4.0/php-cs-fixer.phar; fi
35+
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.7.1/php-cs-fixer.phar; fi
3536
- if [[ $lint = 1 ]]; then composer global require --dev 'phpstan/phpstan:^0.8'; fi
3637

3738
install:
38-
- if [[ $coverage = 1 ]]; then composer require --dev --no-update 'phpunit/php-code-coverage:^4.0.1'; fi
39+
- if [[ $coverage = 1 ]]; then composer require --dev --no-update 'phpunit/php-code-coverage:^5.2.2'; fi
3940
- if [[ ! $deps ]]; then composer update --prefer-dist --no-progress --no-suggest --ansi; fi
4041
- if [[ $deps = 'low' ]]; then composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi; fi
4142

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ It natively supports popular open formats including [JSON for Linked Data (JSON-
99
Build a working and fully-featured CRUD API in minutes. Leverage the awesome features of the tool to develop complex and
1010
high performance API-first projects. Extend or override everything you want.
1111

12-
[![JSON-LD enabled](http://json-ld.org/images/json-ld-button-88.png)](http://json-ld.org)
13-
[![Join the chat at https://gitter.im/api-platform/api-platform](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/api-platform/api-platform?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
1412
[![Build Status](https://travis-ci.org/api-platform/core.svg?branch=master)](https://travis-ci.org/api-platform/core)
1513
[![Build status](https://ci.appveyor.com/api/projects/status/grwuyprts3wdqx5l?svg=true)](https://ci.appveyor.com/project/dunglas/dunglasapibundle)
1614
[![Coverage Status](https://coveralls.io/repos/github/api-platform/core/badge.svg)](https://coveralls.io/github/api-platform/core)

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
"guzzlehttp/guzzle": "^6.0",
4040
"justinrainbow/json-schema": "^1.5",
4141
"nelmio/api-doc-bundle": "^2.11.2",
42-
"php-mock/php-mock-phpunit": "^1.1",
42+
"php-mock/php-mock-phpunit": "^2.0",
4343
"phpdocumentor/reflection-docblock": "^3.0",
44-
"phpdocumentor/type-resolver": "^0.2",
45-
"phpunit/phpunit": "^5.6.8",
44+
"phpdocumentor/type-resolver": "^0.2.1",
45+
"phpunit/phpunit": "^6.1",
4646
"psr/log": "^1.0",
4747
"sensio/framework-extra-bundle": "^3.0.11 || ^4.0",
4848
"symfony/asset": "^3.3 || ^4.0",

features/bootstrap/CoverageContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* @author Kévin Dunglas <dunglas@gmail.com>
2525
* @copyright Adapted from https://gist.github.com/eliecharra/9c8b3ba57998b50e14a6
2626
*/
27-
class CoverageContext implements Context
27+
final class CoverageContext implements Context
2828
{
2929
/**
3030
* @var CodeCoverage

features/bootstrap/FeatureContext.php

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -45,34 +45,21 @@
4545
use Behat\Behat\Context\SnippetAcceptingContext;
4646
use Behatch\HttpCall\Request;
4747
use Doctrine\Common\Persistence\ManagerRegistry;
48-
use Doctrine\Common\Persistence\ObjectManager;
48+
use Doctrine\ORM\EntityManagerInterface;
4949
use Doctrine\ORM\Tools\SchemaTool;
5050

5151
/**
5252
* Defines application features from the specific context.
5353
*/
54-
class FeatureContext implements Context, SnippetAcceptingContext
54+
final class FeatureContext implements Context, SnippetAcceptingContext
5555
{
56-
private $doctrine;
57-
5856
/**
59-
* @var ObjectManager
57+
* @var EntityManagerInterface
6058
*/
6159
private $manager;
62-
63-
/**
64-
* @var SchemaTool
65-
*/
60+
private $doctrine;
6661
private $schemaTool;
67-
68-
/**
69-
* @var array
70-
*/
7162
private $classes;
72-
73-
/**
74-
* @var Request
75-
*/
7663
private $request;
7764

7865
/**
@@ -121,7 +108,7 @@ public function dropDatabase()
121108
/**
122109
* @Given there is :nb dummy objects
123110
*/
124-
public function thereIsDummyObjects($nb)
111+
public function thereIsDummyObjects(int $nb)
125112
{
126113
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
127114

@@ -141,7 +128,7 @@ public function thereIsDummyObjects($nb)
141128
/**
142129
* @Given there are :nb foo objects with fake names
143130
*/
144-
public function thereAreFooObjectsWithFakeNames($nb)
131+
public function thereAreFooObjectsWithFakeNames(int $nb)
145132
{
146133
$names = ['Hawsepipe', 'Sthenelus', 'Ephesian', 'Separativeness', 'Balbo'];
147134
$bars = ['Lorem', 'Dolor', 'Dolor', 'Sit', 'Amet'];
@@ -160,7 +147,7 @@ public function thereAreFooObjectsWithFakeNames($nb)
160147
/**
161148
* @Given there is :nb dummy group objects
162149
*/
163-
public function thereIsDummyGroupObjects($nb)
150+
public function thereIsDummyGroupObjects(int $nb)
164151
{
165152
for ($i = 1; $i <= $nb; ++$i) {
166153
$dummyGroup = new DummyGroup();
@@ -178,7 +165,7 @@ public function thereIsDummyGroupObjects($nb)
178165
/**
179166
* @Given there is :nb dummy property objects
180167
*/
181-
public function thereIsDummyPropertyObjects($nb)
168+
public function thereIsDummyPropertyObjects(int $nb)
182169
{
183170
for ($i = 1; $i <= $nb; ++$i) {
184171
$dummyProperty = new DummyProperty();
@@ -200,7 +187,7 @@ public function thereIsDummyPropertyObjects($nb)
200187
/**
201188
* @Given there are :nb embedded dummy objects
202189
*/
203-
public function thereIsEmbeddedDummyObjects($nb)
190+
public function thereIsEmbeddedDummyObjects(int $nb)
204191
{
205192
for ($i = 1; $i <= $nb; ++$i) {
206193
$dummy = new EmbeddedDummy();
@@ -219,7 +206,7 @@ public function thereIsEmbeddedDummyObjects($nb)
219206
/**
220207
* @Given there is :nb dummy objects with relatedDummy
221208
*/
222-
public function thereIsDummyObjectsWithRelatedDummy($nb)
209+
public function thereIsDummyObjectsWithRelatedDummy(int $nb)
223210
{
224211
for ($i = 1; $i <= $nb; ++$i) {
225212
$relatedDummy = new RelatedDummy();
@@ -240,7 +227,7 @@ public function thereIsDummyObjectsWithRelatedDummy($nb)
240227
/**
241228
* @Given there is :nb dummy objects with relatedDummy and its thirdLevel
242229
*/
243-
public function thereIsDummyObjectsWithRelatedDummyAndItsThirdLevel($nb)
230+
public function thereIsDummyObjectsWithRelatedDummyAndItsThirdLevel(int $nb)
244231
{
245232
for ($i = 1; $i <= $nb; ++$i) {
246233
$thirdLevel = new ThirdLevel();
@@ -265,7 +252,7 @@ public function thereIsDummyObjectsWithRelatedDummyAndItsThirdLevel($nb)
265252
/**
266253
* @Given there is :nb dummy objects with embeddedDummy
267254
*/
268-
public function thereIsDummyObjectsWithEmbeddedDummy($nb)
255+
public function thereIsDummyObjectsWithEmbeddedDummy(int $nb)
269256
{
270257
for ($i = 1; $i <= $nb; ++$i) {
271258
$embeddableDummy = new EmbeddableDummy();
@@ -284,7 +271,7 @@ public function thereIsDummyObjectsWithEmbeddedDummy($nb)
284271
/**
285272
* @Given there is :nb dummy objects having each :nbrelated relatedDummies
286273
*/
287-
public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
274+
public function thereIsDummyObjectsWithRelatedDummies(int $nb, int $nbrelated)
288275
{
289276
for ($i = 1; $i <= $nb; ++$i) {
290277
$dummy = new Dummy();
@@ -294,11 +281,12 @@ public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
294281
for ($j = 1; $j <= $nbrelated; ++$j) {
295282
$relatedDummy = new RelatedDummy();
296283
$relatedDummy->setName('RelatedDummy'.$j.$i);
284+
297285
$this->manager->persist($relatedDummy);
286+
298287
$dummy->addRelatedDummy($relatedDummy);
299288
}
300289

301-
$this->manager->persist($relatedDummy);
302290
$this->manager->persist($dummy);
303291
}
304292

@@ -308,7 +296,7 @@ public function thereIsDummyObjectsWithRelatedDummies($nb, $nbrelated)
308296
/**
309297
* @Given there is :nb dummy objects with dummyDate
310298
*/
311-
public function thereIsDummyObjectsWithDummyDate($nb)
299+
public function thereIsDummyObjectsWithDummyDate(int $nb)
312300
{
313301
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
314302

@@ -334,7 +322,7 @@ public function thereIsDummyObjectsWithDummyDate($nb)
334322
/**
335323
* @Given there is :nb dummy objects with dummyDate and dummyBoolean :bool
336324
*/
337-
public function thereIsDummyObjectsWithDummyDateAndDummyBoolean($nb, $bool)
325+
public function thereIsDummyObjectsWithDummyDateAndDummyBoolean(int $nb, string $bool)
338326
{
339327
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
340328

@@ -370,7 +358,7 @@ public function thereIsDummyObjectsWithDummyDateAndDummyBoolean($nb, $bool)
370358
/**
371359
* @Given there is :nb dummy objects with dummyDate and relatedDummy
372360
*/
373-
public function thereIsDummyObjectsWithDummyDateAndRelatedDummy($nb)
361+
public function thereIsDummyObjectsWithDummyDateAndRelatedDummy(int $nb)
374362
{
375363
for ($i = 1; $i <= $nb; ++$i) {
376364
$date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC'));
@@ -398,7 +386,7 @@ public function thereIsDummyObjectsWithDummyDateAndRelatedDummy($nb)
398386
/**
399387
* @Given there is :nb embedded dummy objects with dummyDate and embeddedDummy
400388
*/
401-
public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy($nb)
389+
public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy(int $nb)
402390
{
403391
for ($i = 1; $i <= $nb; ++$i) {
404392
$date = new \DateTime(sprintf('2015-04-%d', $i), new \DateTimeZone('UTC'));
@@ -424,7 +412,7 @@ public function thereIsDummyObjectsWithDummyDateAndEmbeddedDummy($nb)
424412
/**
425413
* @Given there is :nb dummy objects with dummyPrice
426414
*/
427-
public function thereIsDummyObjectsWithDummyPrice($nb)
415+
public function thereIsDummyObjectsWithDummyPrice(int $nb)
428416
{
429417
$descriptions = ['Smart dummy.', 'Not so smart dummy.'];
430418
$prices = ['9.99', '12.99', '15.99', '19.99'];
@@ -445,7 +433,7 @@ public function thereIsDummyObjectsWithDummyPrice($nb)
445433
/**
446434
* @Given there is :nb dummy objects with dummyBoolean :bool
447435
*/
448-
public function thereIsDummyObjectsWithDummyBoolean($nb, $bool)
436+
public function thereIsDummyObjectsWithDummyBoolean(int $nb, string $bool)
449437
{
450438
if (in_array($bool, ['true', '1', 1], true)) {
451439
$bool = true;
@@ -473,7 +461,7 @@ public function thereIsDummyObjectsWithDummyBoolean($nb, $bool)
473461
/**
474462
* @Given there is :nb embedded dummy objects with embeddedDummy.dummyBoolean :bool
475463
*/
476-
public function thereIsDummyObjectsWithEmbeddedDummyBoolean($nb, $bool)
464+
public function thereIsDummyObjectsWithEmbeddedDummyBoolean(int $nb, string $bool)
477465
{
478466
if (in_array($bool, ['true', '1', 1], true)) {
479467
$bool = true;
@@ -500,7 +488,7 @@ public function thereIsDummyObjectsWithEmbeddedDummyBoolean($nb, $bool)
500488
/**
501489
* @Given there is :nb embedded dummy objects with relatedDummy.embeddedDummy.dummyBoolean :bool
502490
*/
503-
public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean($nb, $bool)
491+
public function thereIsDummyObjectsWithRelationEmbeddedDummyBoolean(int $nb, string $bool)
504492
{
505493
if (in_array($bool, ['true', '1', 1], true)) {
506494
$bool = true;
@@ -640,7 +628,7 @@ public function thereIsAFooEntityWithRelatedBars()
640628
/**
641629
* @Given there is a RelatedDummy with :nb friends
642630
*/
643-
public function thereIsARelatedDummyWithFriends($nb)
631+
public function thereIsARelatedDummyWithFriends(int $nb)
644632
{
645633
$relatedDummy = new RelatedDummy();
646634
$relatedDummy->setName('RelatedDummy with friends');
@@ -669,7 +657,7 @@ public function thereIsARelatedDummyWithFriends($nb)
669657
}
670658

671659
/**
672-
* @Given there is an answer ":answer" to the question ":question"
660+
* @Given there is an answer :answer to the question :question
673661
*/
674662
public function thereIsAnAnswerToTheQuestion(string $a, string $q)
675663
{
@@ -690,7 +678,7 @@ public function thereIsAnAnswerToTheQuestion(string $a, string $q)
690678
/**
691679
* @Given there are :nb nodes in a container :uuid
692680
*/
693-
public function thereAreNodesInAContainer($nb, $uuid)
681+
public function thereAreNodesInAContainer(int $nb, string $uuid)
694682
{
695683
$container = new Container();
696684
$container->setId($uuid);
@@ -709,10 +697,9 @@ public function thereAreNodesInAContainer($nb, $uuid)
709697
/**
710698
* @Then the password :password for user :user should be hashed
711699
*/
712-
public function thePasswordForUserShouldBeHashed($password, $user)
700+
public function thePasswordForUserShouldBeHashed(string $password, string $user)
713701
{
714-
$repository = $this->doctrine->getRepository(User::class);
715-
$user = $repository->find($user);
702+
$user = $this->doctrine->getRepository(User::class)->find($user);
716703

717704
if (!password_verify($password, $user->getPassword())) {
718705
throw new \Exception('User password mismatch');

features/bootstrap/GraphqlContext.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @author Alan Poulain <contact@alanpoulain.eu>
2525
*/
26-
class GraphqlContext implements Context
26+
final class GraphqlContext implements Context
2727
{
2828
/**
2929
* @var RestContext
@@ -43,15 +43,13 @@ class GraphqlContext implements Context
4343
/**
4444
* Gives access to the Behatch context.
4545
*
46-
* @param BeforeScenarioScope $scope
47-
*
4846
* @BeforeScenario
4947
*/
5048
public function gatherContexts(BeforeScenarioScope $scope)
5149
{
5250
/** @var InitializedContextEnvironment $environment */
5351
$environment = $scope->getEnvironment();
54-
$this->restContext = $environment->getContext('Behatch\Context\RestContext');
52+
$this->restContext = $environment->getContext(RestContext::class);
5553
}
5654

5755
/**

features/bootstrap/HttpCacheContext.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
declare(strict_types=1);
1313

1414
use Behat\Symfony2Extension\Context\KernelAwareContext;
15+
use PHPUnit\Framework\ExpectationFailedException;
1516
use Symfony\Component\HttpKernel\KernelInterface;
1617

1718
/**
1819
* @author Kévin Dunglas <dunglas@gmail.com>
1920
*/
20-
class HttpCacheContext implements KernelAwareContext
21+
final class HttpCacheContext implements KernelAwareContext
2122
{
2223
/**
2324
* @var KernelInterface
@@ -30,7 +31,7 @@ public function setKernel(KernelInterface $kernel)
3031
}
3132

3233
/**
33-
* @Then ":iris" IRIs should be purged
34+
* @Then :iris IRIs should be purged
3435
*/
3536
public function irisShouldBePurged(string $iris)
3637
{
@@ -40,9 +41,7 @@ public function irisShouldBePurged(string $iris)
4041
$purger->clear();
4142

4243
if ($iris !== $purgedIris) {
43-
throw new \PHPUnit_Framework_ExpectationFailedException(
44-
sprintf('IRIs "%s" does not match expected "%s".', $purgedIris, $iris)
45-
);
44+
throw new ExpectationFailedException(sprintf('IRIs "%s" does not match expected "%s".', $purgedIris, $iris));
4645
}
4746
}
4847
}

0 commit comments

Comments
 (0)