Skip to content

Commit 6ed91c3

Browse files
authored
Merge pull request #1445 from meyerbaptiste/php72
Support & compatibility for PHP7.2
2 parents 6a5c9ab + b8d54d8 commit 6ed91c3

File tree

101 files changed

+224
-122
lines changed

Some content is hidden

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

101 files changed

+224
-122
lines changed

.travis.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ matrix:
1111
include:
1212
- php: '7.0'
1313
- php: '7.1'
14+
- php: '7.2'
1415
env: coverage=1 lint=1
15-
- php: '7.1'
16+
- php: '7.2'
1617
env: deps='low'
1718

1819
before_install:
@@ -22,12 +23,12 @@ before_install:
2223
- if [[ $coverage = 1 ]]; then mkdir -p build/logs build/cov; fi
2324
- if [[ $coverage = 1 ]]; then wget https://phar.phpunit.de/phpcov.phar; fi
2425
- if [[ $coverage = 1 ]]; then wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi
25-
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.6.0/php-cs-fixer.phar; fi
26+
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.7.1/php-cs-fixer.phar; fi
2627
- if [[ $lint = 1 ]]; then composer global require --dev 'phpstan/phpstan:^0.8'; fi
2728
- export PATH="$PATH:$HOME/.composer/vendor/bin"
2829

2930
install:
30-
- if [[ $coverage = 1 ]]; then composer require --dev --no-update 'phpunit/php-code-coverage:^4.0.1'; fi
31+
- if [[ $coverage = 1 ]]; then composer require --dev --no-update 'phpunit/php-code-coverage:^5.2.2'; fi
3132
- if [[ ! $deps ]]; then composer update --prefer-dist --no-progress --no-suggest --ansi; fi
3233
- if [[ $deps = 'low' ]]; then composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi; fi
3334

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@
3636
"doctrine/annotations": "^1.2",
3737
"friendsofsymfony/user-bundle": "^2.0",
3838
"nelmio/api-doc-bundle": "^2.11.2",
39-
"php-mock/php-mock-phpunit": "^1.1",
39+
"php-mock/php-mock-phpunit": "^2.0",
4040
"phpdocumentor/reflection-docblock": "^3.0",
41-
"phpdocumentor/type-resolver": "^0.2",
42-
"phpunit/phpunit": "^5.6.8",
41+
"phpdocumentor/type-resolver": "^0.2.1",
42+
"phpunit/phpunit": "^6.1",
4343
"psr/log": "^1.0",
4444
"symfony/asset": "^2.7 || ^3.0",
4545
"symfony/cache": "^3.1",
4646
"symfony/config": "^3.2",
4747
"symfony/dependency-injection": "^2.7 || ^3.0",
4848
"symfony/doctrine-bridge": "^2.8 || ^3.0",
4949
"symfony/finder": "^2.7 || ^3.0",
50-
"symfony/framework-bundle": "^3.1",
50+
"symfony/framework-bundle": "^3.2.5",
5151
"symfony/phpunit-bridge": "^2.7 || ^3.0",
5252
"symfony/security": "^2.7 || ^3.0",
5353
"symfony/twig-bundle": "^2.8 || ^3.1",

features/bootstrap/HydraContext.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
1616
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
1717
use Behatch\Context\RestContext;
18+
use PHPUnit\Framework\Assert;
19+
use PHPUnit\Framework\ExpectationFailedException;
1820
use Symfony\Component\PropertyAccess\PropertyAccess;
1921

2022
final class HydraContext implements Context
@@ -50,7 +52,7 @@ public function assertTheHydraClassExist(string $className)
5052
try {
5153
$this->getClassInfo($className);
5254
} catch (\InvalidArgumentException $e) {
53-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('The class "%s" doesn\'t exist.', $className), null, $e);
55+
throw new ExpectationFailedException(sprintf('The class "%s" doesn\'t exist.', $className), null, $e);
5456
}
5557
}
5658

@@ -65,15 +67,15 @@ public function assertTheHydraClassNotExist(string $className)
6567
return;
6668
}
6769

68-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('The class "%s" exists.', $className));
70+
throw new ExpectationFailedException(sprintf('The class "%s" exists.', $className));
6971
}
7072

7173
/**
7274
* @Then the value of the node :node of the Hydra class :class is :value
7375
*/
7476
public function assertNodeValueIs(string $nodeName, string $className, string $value)
7577
{
76-
\PHPUnit_Framework_Assert::assertEquals(
78+
Assert::assertEquals(
7779
$this->propertyAccessor->getValue($this->getClassInfo($className), $nodeName),
7880
$value
7981
);
@@ -84,7 +86,7 @@ public function assertNodeValueIs(string $nodeName, string $className, string $v
8486
*/
8587
public function assertPropertyNodeValueIs(string $nodeName, string $propertyName, string $className, string $value)
8688
{
87-
\PHPUnit_Framework_Assert::assertEquals(
89+
Assert::assertEquals(
8890
$this->propertyAccessor->getValue($this->getPropertyInfo($propertyName, $className), $nodeName),
8991
$value
9092
);
@@ -95,7 +97,7 @@ public function assertPropertyNodeValueIs(string $nodeName, string $propertyName
9597
*/
9698
public function assertOperationNodeValueIs(string $nodeName, string $operationMethod, string $className, string $value)
9799
{
98-
\PHPUnit_Framework_Assert::assertEquals(
100+
Assert::assertEquals(
99101
$this->propertyAccessor->getValue($this->getOperation($operationMethod, $className), $nodeName),
100102
$value
101103
);
@@ -106,15 +108,15 @@ public function assertOperationNodeValueIs(string $nodeName, string $operationMe
106108
*/
107109
public function assertNbOperationsExist(int $nb, string $className)
108110
{
109-
\PHPUnit_Framework_Assert::assertEquals($nb, count($this->getOperations($className)));
111+
Assert::assertEquals($nb, count($this->getOperations($className)));
110112
}
111113

112114
/**
113115
* @Then :nb properties are available for Hydra class :class
114116
*/
115117
public function assertNbPropertiesExist(int $nb, string $className)
116118
{
117-
\PHPUnit_Framework_Assert::assertEquals($nb, count($this->getProperties($className)));
119+
Assert::assertEquals($nb, count($this->getProperties($className)));
118120
}
119121

120122
/**
@@ -128,7 +130,7 @@ public function assertPropertyNotExist(string $propertyName, string $className)
128130
return;
129131
}
130132

131-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('Property "%s" of class "%s" exists.', $propertyName, $className));
133+
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" exists.', $propertyName, $className));
132134
}
133135

134136
/**
@@ -137,7 +139,7 @@ public function assertPropertyNotExist(string $propertyName, string $className)
137139
public function assertPropertyIsReadable(string $propertyName, string $className)
138140
{
139141
if (!$this->getPropertyInfo($propertyName, $className)->{'hydra:readable'}) {
140-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('Property "%s" of class "%s" is not readable', $propertyName, $className));
142+
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is not readable', $propertyName, $className));
141143
}
142144
}
143145

@@ -147,7 +149,7 @@ public function assertPropertyIsReadable(string $propertyName, string $className
147149
public function assertPropertyIsNotReadable(string $propertyName, string $className)
148150
{
149151
if ($this->getPropertyInfo($propertyName, $className)->{'hydra:readable'}) {
150-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('Property "%s" of class "%s" is readable', $propertyName, $className));
152+
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is readable', $propertyName, $className));
151153
}
152154
}
153155

@@ -157,7 +159,7 @@ public function assertPropertyIsNotReadable(string $propertyName, string $classN
157159
public function assertPropertyIsWritable(string $propertyName, string $className)
158160
{
159161
if (!$this->getPropertyInfo($propertyName, $className)->{'hydra:writable'}) {
160-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('Property "%s" of class "%s" is not writable', $propertyName, $className));
162+
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is not writable', $propertyName, $className));
161163
}
162164
}
163165

@@ -167,7 +169,7 @@ public function assertPropertyIsWritable(string $propertyName, string $className
167169
public function assertPropertyIsRequired(string $propertyName, string $className)
168170
{
169171
if (!$this->getPropertyInfo($propertyName, $className)->{'hydra:required'}) {
170-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('Property "%s" of class "%s" is not required', $propertyName, $className));
172+
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is not required', $propertyName, $className));
171173
}
172174
}
173175

@@ -177,7 +179,7 @@ public function assertPropertyIsRequired(string $propertyName, string $className
177179
public function assertPropertyIsNotRequired(string $propertyName, string $className)
178180
{
179181
if ($this->getPropertyInfo($propertyName, $className)->{'hydra:required'}) {
180-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('Property "%s" of class "%s" is required', $propertyName, $className));
182+
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" is required', $propertyName, $className));
181183
}
182184
}
183185

features/bootstrap/SwaggerContext.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
1616
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
1717
use Behatch\Context\RestContext;
18+
use PHPUnit\Framework\Assert;
19+
use PHPUnit\Framework\ExpectationFailedException;
1820
use Symfony\Component\PropertyAccess\PropertyAccess;
1921

2022
final class SwaggerContext implements Context
@@ -50,7 +52,7 @@ public function assertTheSwaggerClassExist(string $className)
5052
try {
5153
$this->getClassInfo($className);
5254
} catch (\InvalidArgumentException $e) {
53-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('The class "%s" doesn\'t exist.', $className), null, $e);
55+
throw new ExpectationFailedException(sprintf('The class "%s" doesn\'t exist.', $className), null, $e);
5456
}
5557
}
5658

@@ -65,7 +67,7 @@ public function assertTheSwaggerClassNotExist(string $className)
6567
return;
6668
}
6769

68-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('The class "%s" exists.', $className));
70+
throw new ExpectationFailedException(sprintf('The class "%s" exists.', $className));
6971
}
7072

7173
/**
@@ -75,7 +77,7 @@ public function assertThePathExist(string $path)
7577
{
7678
$json = $this->getLastJsonResponse();
7779

78-
\PHPUnit_Framework_Assert::assertTrue(isset($json->paths) && isset($json->paths->{$path}));
80+
Assert::assertTrue(isset($json->paths) && isset($json->paths->{$path}));
7981
}
8082

8183
/**
@@ -86,7 +88,7 @@ public function assertPropertyExist(string $propertyName, string $className)
8688
try {
8789
$this->getPropertyInfo($propertyName, $className);
8890
} catch (\InvalidArgumentException $e) {
89-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('Property "%s" of class "%s" exists.', $propertyName, $className), null, $e);
91+
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" exists.', $propertyName, $className), null, $e);
9092
}
9193
}
9294

@@ -96,7 +98,7 @@ public function assertPropertyExist(string $propertyName, string $className)
9698
public function assertPropertyIsRequired(string $propertyName, string $className)
9799
{
98100
if (!in_array($propertyName, $this->getClassInfo($className)->required, true)) {
99-
throw new \PHPUnit_Framework_ExpectationFailedException(sprintf('Property "%s" of class "%s" should be required', $propertyName, $className));
101+
throw new ExpectationFailedException(sprintf('Property "%s" of class "%s" should be required', $propertyName, $className));
100102
}
101103
}
102104

tests/Action/EntrypointActionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
use ApiPlatform\Core\Api\Entrypoint;
1818
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
1919
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;
20+
use PHPUnit\Framework\TestCase;
2021

2122
/**
2223
* @author Amrouche Hamza <[email protected]>
2324
*/
24-
class EntrypointActionTest extends \PHPUnit_Framework_TestCase
25+
class EntrypointActionTest extends TestCase
2526
{
2627
public function testGetEntrypoint()
2728
{

tests/Action/ExceptionActionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use ApiPlatform\Core\Action\ExceptionAction;
1717
use ApiPlatform\Core\Exception\InvalidArgumentException;
18+
use PHPUnit\Framework\TestCase;
1819
use Symfony\Component\Debug\Exception\FlattenException;
1920
use Symfony\Component\HttpFoundation\Request;
2021
use Symfony\Component\HttpFoundation\Response;
@@ -25,7 +26,7 @@
2526
* @author Amrouche Hamza <[email protected]>
2627
* @author Baptiste Meyer <[email protected]>
2728
*/
28-
class ExceptionActionTest extends \PHPUnit_Framework_TestCase
29+
class ExceptionActionTest extends TestCase
2930
{
3031
public function testActionWithCatchableException()
3132
{

tests/Action/PlaceholderActionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
namespace ApiPlatform\Core\Tests\Action;
1515

1616
use ApiPlatform\Core\Action\PlaceholderAction;
17+
use PHPUnit\Framework\TestCase;
1718

1819
/**
1920
* @author Kévin Dunglas <[email protected]>
2021
*/
21-
class PlaceholderActionTest extends \PHPUnit_Framework_TestCase
22+
class PlaceholderActionTest extends TestCase
2223
{
2324
public function testAction()
2425
{

tests/Annotation/ApiResourceTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515

1616
use ApiPlatform\Core\Annotation\ApiResource;
1717
use Doctrine\Common\Annotations\AnnotationReader;
18+
use PHPUnit\Framework\TestCase;
1819

1920
/**
2021
* @author Kévin Dunglas <[email protected]>
2122
*/
22-
class ApiResourceTest extends \PHPUnit_Framework_TestCase
23+
class ApiResourceTest extends TestCase
2324
{
2425
public function testAssignation()
2526
{

tests/Annotation/PropertyTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
namespace ApiPlatform\Core\Tests\Annotation;
1515

1616
use ApiPlatform\Core\Annotation\ApiProperty;
17+
use PHPUnit\Framework\TestCase;
1718

1819
/**
1920
* @author Kévin Dunglas <[email protected]>
2021
*/
21-
class PropertyTest extends \PHPUnit_Framework_TestCase
22+
class PropertyTest extends TestCase
2223
{
2324
public function testAssignation()
2425
{

tests/Api/EntrypointTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
use ApiPlatform\Core\Api\Entrypoint;
1717
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;
1818
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
19+
use PHPUnit\Framework\TestCase;
1920

2021
/**
2122
* @author Amrouche Hamza <[email protected]>
2223
*/
23-
class EntrypointTest extends \PHPUnit_Framework_TestCase
24+
class EntrypointTest extends TestCase
2425
{
2526
public function testGetResourceNameCollection()
2627
{

tests/Api/FilterCollectionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
namespace ApiPlatform\Core\Tests\Api;
1515

1616
use ApiPlatform\Core\Api\FilterCollection;
17+
use PHPUnit\Framework\TestCase;
1718

1819
/**
1920
* @author Kévin Dunglas <[email protected]>
2021
*/
21-
class FilterCollectionTest extends \PHPUnit_Framework_TestCase
22+
class FilterCollectionTest extends TestCase
2223
{
2324
public function testIsArrayObject()
2425
{

tests/Api/ResourceClassResolverTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@
2020
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
2121
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyTableInheritance;
2222
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\DummyTableInheritanceChild;
23+
use PHPUnit\Framework\TestCase;
2324

2425
/**
2526
* @author Amrouche Hamza <[email protected]>
2627
*/
27-
class ResourceClassResolverTest extends \PHPUnit_Framework_TestCase
28+
class ResourceClassResolverTest extends TestCase
2829
{
2930
public function testGetResourceClassWithIntendedClassName()
3031
{

tests/Bridge/Doctrine/EventListener/WriteListenerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@
1717
use ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Dummy;
1818
use Doctrine\Common\Persistence\ManagerRegistry;
1919
use Doctrine\Common\Persistence\ObjectManager;
20+
use PHPUnit\Framework\TestCase;
2021
use Symfony\Component\HttpFoundation\Request;
2122
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
2223
use Symfony\Component\HttpKernel\HttpKernelInterface;
2324

2425
/**
2526
* @author Amrouche Hamza <[email protected]>
2627
*/
27-
class WriteListenerTest extends \PHPUnit_Framework_TestCase
28+
class WriteListenerTest extends TestCase
2829
{
2930
public function testOnKernelViewWithControllerResultAndPostMethod()
3031
{

tests/Bridge/Doctrine/Orm/CollectionDataProviderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
use Doctrine\ORM\AbstractQuery;
2525
use Doctrine\ORM\EntityRepository;
2626
use Doctrine\ORM\QueryBuilder;
27+
use PHPUnit\Framework\TestCase;
2728
use Prophecy\Argument;
2829

2930
/**
3031
* @author Kévin Dunglas <[email protected]>
3132
*/
32-
class CollectionDataProviderTest extends \PHPUnit_Framework_TestCase
33+
class CollectionDataProviderTest extends TestCase
3334
{
3435
public function testGetCollection()
3536
{

tests/Bridge/Doctrine/Orm/Extension/EagerLoadingExtensionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
use Doctrine\ORM\EntityManager;
3333
use Doctrine\ORM\Mapping\ClassMetadata;
3434
use Doctrine\ORM\QueryBuilder;
35+
use PHPUnit\Framework\TestCase;
3536
use Prophecy\Argument;
3637
use Symfony\Component\HttpFoundation\Request;
3738
use Symfony\Component\HttpFoundation\RequestStack;
@@ -40,7 +41,7 @@
4041
* @author Amrouche Hamza <[email protected]>
4142
* @author Antoine Bluchet <[email protected]>
4243
*/
43-
class EagerLoadingExtensionTest extends \PHPUnit_Framework_TestCase
44+
class EagerLoadingExtensionTest extends TestCase
4445
{
4546
public function testApplyToCollection()
4647
{

0 commit comments

Comments
 (0)