From e438be5acddbc1c2f75199c17822005d3d036997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20L=C3=A9v=C3=AAque?= Date: Thu, 19 Oct 2017 09:52:32 +0200 Subject: [PATCH 1/4] Update symfony 4 compatibility --- .travis.yml | 4 +++- composer.json | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e60f9466..2eef4d0d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,8 @@ matrix: # bleeding edge (unreleased dev versions where failures are allowed) - php: 7.1 env: SYMFONY_VERSION="3.4.*" + - php: 7.1 + env: SYMFONY_VERSION="4.0.*" - php: nightly env: SYMFONY_VERSION="4.0.*" allow_failures: @@ -46,7 +48,7 @@ cache: before_install: - if [[ "$ENABLE_CODE_COVERAGE" != "yes" ]]; then phpenv config-rm xdebug.ini || true; fi; - if [[ "$SYMFONY_VERSION" != "" ]]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi; - - if [[ "$TRAVIS_PHP_VERSION" == "nightly" ]]; then composer remove "friendsofphp/php-cs-fixer" --no-update --no-interaction --dev; fi; + - if [[ "$CHECK_PHP_SYNTAX" != "yes" ]]; then composer remove "friendsofphp/php-cs-fixer" --no-update --no-interaction --dev; fi; install: - composer update --prefer-dist --no-interaction --optimize-autoloader --prefer-stable --no-progress $COMPOSER_FLAGS diff --git a/composer.json b/composer.json index 4ecc1668..001291e1 100644 --- a/composer.json +++ b/composer.json @@ -41,10 +41,12 @@ "symfony/phpunit-bridge": "^3.2|^4.0", "symfony/browser-kit": "^2.8|^3.1|^4.0", "symfony/css-selector": "^2.8|^3.1|^4.0", + "symfony/console": "^2.8|^3.0|^4.0", "symfony/dependency-injection": "^2.8|^3.1|^4.0", "symfony/doctrine-bridge": "^2.8|^3.1|^4.0", "symfony/dom-crawler": "^2.8.1|^3.1|^4.0", "symfony/filesystem": "^2.8|^3.1|^4.0", + "symfony/finder": "^2.8|^3.1|^4.0", "symfony/form": "^2.8.5|^3.1|^4.0", "symfony/framework-bundle": "^2.8|^3.1|^4.0", "symfony/http-foundation": "^2.8|^3.1|^4.0", From 46e775cf0f8196cbf2a6670d0599b417438792a1 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Tue, 7 Nov 2017 22:25:03 +0100 Subject: [PATCH 2/4] Moar travis changes - remove 3.2 - merge cs-fix with 3.4 build - merge 2.8 && deps=low build - sf 3.4 & 4.0 are not allowed to fail - php 7.2 with sf 4.0 - php 7.3 kept in allowed failures --- .travis.yml | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2eef4d0d..a53f2c5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,27 +19,20 @@ matrix: env: ENABLE_CODE_COVERAGE="yes" # oldest supported versions - php: 7.0 - env: COMPOSER_FLAGS="--prefer-lowest" + env: SYMFONY_VERSION="2.8.*" COMPOSER_FLAGS="--prefer-lowest" # common versions: - - php: 7.1 - env: SYMFONY_VERSION="2.8.*" - - php: 7.1 - env: SYMFONY_VERSION="3.2.*" - php: 7.1 env: SYMFONY_VERSION="3.3.*" # most recent versions - php: 7.1 - env: CHECK_PHP_SYNTAX="yes" - # bleeding edge (unreleased dev versions where failures are allowed) - - php: 7.1 - env: SYMFONY_VERSION="3.4.*" - - php: 7.1 + env: SYMFONY_VERSION="3.4.*" CHECK_PHP_SYNTAX="yes" + - php: 7.2 env: SYMFONY_VERSION="4.0.*" + # bleeding edge (unreleased dev versions where failures are allowed) - php: nightly env: SYMFONY_VERSION="4.0.*" allow_failures: - php: nightly - - env: SYMFONY_VERSION="3.4.*" cache: directories: From a4705a51b6e1fbe2b3004573b793bd1852c854d5 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 8 Nov 2017 16:18:21 +0100 Subject: [PATCH 3/4] Inject a NullLogger for integration tests --- tests/Fixtures/Integration/Symfony/app/config/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Fixtures/Integration/Symfony/app/config/config.yml b/tests/Fixtures/Integration/Symfony/app/config/config.yml index 7ab24307..d08d4454 100644 --- a/tests/Fixtures/Integration/Symfony/app/config/config.yml +++ b/tests/Fixtures/Integration/Symfony/app/config/config.yml @@ -22,3 +22,8 @@ doctrine: orm: auto_generate_proxy_classes: '%kernel.debug%' auto_mapping: true + +services: + logger: + class: Psr\Log\NullLogger + public: false From 64fc69d5b0f8e43535b88bc7fae269a73ef5f79e Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 8 Nov 2017 16:34:32 +0100 Subject: [PATCH 4/4] Use new PhpUnit namespaces --- .travis.yml | 5 ++++- .../Bridge/Faker/Provider/EnumProviderTest.php | 3 ++- tests/Unit/AutoDiscoveredValuesTraitTest.php | 3 ++- tests/Unit/Bridge/Doctrine/DBAL/Types/EnumTypeTest.php | 3 ++- .../Bridge/Doctrine/DBAL/Types/IntegerEnumTypeTest.php | 3 ++- tests/Unit/Bridge/Faker/Provider/EnumProviderTest.php | 3 ++- .../BitmaskToBitFlagsValueTransformerTest.php | 3 ++- .../SingleToCollectionFlagEnumTransformerTest.php | 3 ++- .../Serializer/Normalizer/EnumNormalizerTest.php | 3 ++- .../Constraint/ConstraintValidatorTestCase.php | 10 +++++++--- .../Bridge/Symfony/Validator/Constraint/EnumTest.php | 3 ++- .../Bridge/Symfony/VarDumper/Caster/EnumCasterTest.php | 3 ++- tests/Unit/EnumTest.php | 3 ++- tests/Unit/FlaggedEnumTest.php | 3 ++- tests/Unit/ReadableEnumTest.php | 3 ++- 15 files changed, 37 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index a53f2c5c..6a695aeb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,10 @@ matrix: env: ENABLE_CODE_COVERAGE="yes" # oldest supported versions - php: 7.0 - env: SYMFONY_VERSION="2.8.*" COMPOSER_FLAGS="--prefer-lowest" + env: + - SYMFONY_VERSION="2.8.*" + - COMPOSER_FLAGS="--prefer-lowest" + - SYMFONY_PHPUNIT_VERSION=5.7 # common versions: - php: 7.1 env: SYMFONY_VERSION="3.3.*" diff --git a/tests/Integration/Bridge/Faker/Provider/EnumProviderTest.php b/tests/Integration/Bridge/Faker/Provider/EnumProviderTest.php index f612f72d..490abf63 100644 --- a/tests/Integration/Bridge/Faker/Provider/EnumProviderTest.php +++ b/tests/Integration/Bridge/Faker/Provider/EnumProviderTest.php @@ -17,8 +17,9 @@ use Faker\Factory as FakerGeneratorFactory; use Faker\Generator as FakerGenerator; use Nelmio\Alice\Loader\NativeLoader; +use PHPUnit\Framework\TestCase; -class EnumProviderTest extends \PHPUnit_Framework_TestCase +class EnumProviderTest extends TestCase { public function testEnumProvider() { diff --git a/tests/Unit/AutoDiscoveredValuesTraitTest.php b/tests/Unit/AutoDiscoveredValuesTraitTest.php index 1ed82d2e..7d6eb84c 100644 --- a/tests/Unit/AutoDiscoveredValuesTraitTest.php +++ b/tests/Unit/AutoDiscoveredValuesTraitTest.php @@ -14,8 +14,9 @@ use Elao\Enum\Enum; use Elao\Enum\FlaggedEnum; use Elao\Enum\Tests\Fixtures\Enum\Php71AutoDiscoveredEnum; +use PHPUnit\Framework\TestCase; -class AutoDiscoveredValuesTraitTest extends \PHPUnit_Framework_TestCase +class AutoDiscoveredValuesTraitTest extends TestCase { public function testItAutoDiscoveredValuesBasedOnAvailableConstants() { diff --git a/tests/Unit/Bridge/Doctrine/DBAL/Types/EnumTypeTest.php b/tests/Unit/Bridge/Doctrine/DBAL/Types/EnumTypeTest.php index ecd72362..abfc392d 100644 --- a/tests/Unit/Bridge/Doctrine/DBAL/Types/EnumTypeTest.php +++ b/tests/Unit/Bridge/Doctrine/DBAL/Types/EnumTypeTest.php @@ -14,8 +14,9 @@ use Doctrine\DBAL\Types\Type; use Elao\Enum\Tests\Fixtures\Bridge\Doctrine\DBAL\Types\GenderEnumType; use Elao\Enum\Tests\Fixtures\Enum\Gender; +use PHPUnit\Framework\TestCase; -class EnumTypeTest extends \PHPUnit_Framework_TestCase +class EnumTypeTest extends TestCase { /** @var AbstractPlatform */ protected $platform; diff --git a/tests/Unit/Bridge/Doctrine/DBAL/Types/IntegerEnumTypeTest.php b/tests/Unit/Bridge/Doctrine/DBAL/Types/IntegerEnumTypeTest.php index d4f259d5..833719b8 100644 --- a/tests/Unit/Bridge/Doctrine/DBAL/Types/IntegerEnumTypeTest.php +++ b/tests/Unit/Bridge/Doctrine/DBAL/Types/IntegerEnumTypeTest.php @@ -14,8 +14,9 @@ use Doctrine\DBAL\Types\Type; use Elao\Enum\Tests\Fixtures\Bridge\Doctrine\DBAL\Types\SimpleEnumType; use Elao\Enum\Tests\Fixtures\Enum\SimpleEnum; +use PHPUnit\Framework\TestCase; -class IntegerEnumTypeTest extends \PHPUnit_Framework_TestCase +class IntegerEnumTypeTest extends TestCase { /** @var AbstractPlatform */ protected $platform; diff --git a/tests/Unit/Bridge/Faker/Provider/EnumProviderTest.php b/tests/Unit/Bridge/Faker/Provider/EnumProviderTest.php index 4d59fe5d..35cead99 100644 --- a/tests/Unit/Bridge/Faker/Provider/EnumProviderTest.php +++ b/tests/Unit/Bridge/Faker/Provider/EnumProviderTest.php @@ -13,8 +13,9 @@ use Elao\Enum\Bridge\Faker\Provider\EnumProvider; use Elao\Enum\Tests\Fixtures\Enum\Permissions; use Elao\Enum\Tests\Fixtures\Enum\SimpleEnum; +use PHPUnit\Framework\TestCase; -class EnumProviderTest extends \PHPUnit_Framework_TestCase +class EnumProviderTest extends TestCase { public function testEnumMethodShouldReturnExpectedEnums() { diff --git a/tests/Unit/Bridge/Symfony/Form/DataTransformer/BitmaskToBitFlagsValueTransformerTest.php b/tests/Unit/Bridge/Symfony/Form/DataTransformer/BitmaskToBitFlagsValueTransformerTest.php index 67747659..2b6d2175 100644 --- a/tests/Unit/Bridge/Symfony/Form/DataTransformer/BitmaskToBitFlagsValueTransformerTest.php +++ b/tests/Unit/Bridge/Symfony/Form/DataTransformer/BitmaskToBitFlagsValueTransformerTest.php @@ -13,8 +13,9 @@ use Elao\Enum\Bridge\Symfony\Form\DataTransformer\BitmaskToBitFlagsValueTransformer; use Elao\Enum\Tests\Fixtures\Enum\Gender; use Elao\Enum\Tests\Fixtures\Enum\Permissions; +use PHPUnit\Framework\TestCase; -class BitmaskToBitFlagsValueTransformerTest extends \PHPUnit_Framework_TestCase +class BitmaskToBitFlagsValueTransformerTest extends TestCase { /** * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException diff --git a/tests/Unit/Bridge/Symfony/Form/DataTransformer/SingleToCollectionFlagEnumTransformerTest.php b/tests/Unit/Bridge/Symfony/Form/DataTransformer/SingleToCollectionFlagEnumTransformerTest.php index e54b0e39..6769cd69 100644 --- a/tests/Unit/Bridge/Symfony/Form/DataTransformer/SingleToCollectionFlagEnumTransformerTest.php +++ b/tests/Unit/Bridge/Symfony/Form/DataTransformer/SingleToCollectionFlagEnumTransformerTest.php @@ -13,8 +13,9 @@ use Elao\Enum\Bridge\Symfony\Form\DataTransformer\SingleToCollectionFlagEnumTransformer; use Elao\Enum\Tests\Fixtures\Enum\Gender; use Elao\Enum\Tests\Fixtures\Enum\Permissions; +use PHPUnit\Framework\TestCase; -class SingleToCollectionFlagEnumTransformerTest extends \PHPUnit_Framework_TestCase +class SingleToCollectionFlagEnumTransformerTest extends TestCase { /** * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException diff --git a/tests/Unit/Bridge/Symfony/Serializer/Normalizer/EnumNormalizerTest.php b/tests/Unit/Bridge/Symfony/Serializer/Normalizer/EnumNormalizerTest.php index 38cdd211..a4c2a0e9 100644 --- a/tests/Unit/Bridge/Symfony/Serializer/Normalizer/EnumNormalizerTest.php +++ b/tests/Unit/Bridge/Symfony/Serializer/Normalizer/EnumNormalizerTest.php @@ -12,8 +12,9 @@ use Elao\Enum\Bridge\Symfony\Serializer\Normalizer\EnumNormalizer; use Elao\Enum\Tests\Fixtures\Enum\Gender; +use PHPUnit\Framework\TestCase; -class EnumNormalizerTest extends \PHPUnit_Framework_TestCase +class EnumNormalizerTest extends TestCase { /** @var EnumNormalizer */ private $normalizer; diff --git a/tests/Unit/Bridge/Symfony/Validator/Constraint/ConstraintValidatorTestCase.php b/tests/Unit/Bridge/Symfony/Validator/Constraint/ConstraintValidatorTestCase.php index c6569537..3ecd8904 100644 --- a/tests/Unit/Bridge/Symfony/Validator/Constraint/ConstraintValidatorTestCase.php +++ b/tests/Unit/Bridge/Symfony/Validator/Constraint/ConstraintValidatorTestCase.php @@ -10,6 +10,8 @@ namespace Elao\Enum\Tests\Unit\Bridge\Symfony\Validator\Constraint; +use PHPUnit\Framework\Assert; +use PHPUnit\Framework\TestCase; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraints\NotNull; use Symfony\Component\Validator\ConstraintValidatorInterface; @@ -29,11 +31,13 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. * + * To be removed when <3.2 support is dropped. + * * @see https://github.com/symfony/symfony/blob/3.2/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php * * @author Bernhard Schussek */ -abstract class ConstraintValidatorTestCase extends \PHPUnit_Framework_TestCase +abstract class ConstraintValidatorTestCase extends TestCase { /** * @var ExecutionContextInterface @@ -321,12 +325,12 @@ public function assertRaised() $violations = iterator_to_array($this->context->getViolations()); - \PHPUnit_Framework_Assert::assertSame($expectedCount = count($expected), $violationsCount = count($violations), sprintf('%u violation(s) expected. Got %u.', $expectedCount, $violationsCount)); + Assert::assertSame($expectedCount = count($expected), $violationsCount = count($violations), sprintf('%u violation(s) expected. Got %u.', $expectedCount, $violationsCount)); reset($violations); foreach ($expected as $violation) { - \PHPUnit_Framework_Assert::assertEquals($violation, current($violations)); + Assert::assertEquals($violation, current($violations)); next($violations); } } diff --git a/tests/Unit/Bridge/Symfony/Validator/Constraint/EnumTest.php b/tests/Unit/Bridge/Symfony/Validator/Constraint/EnumTest.php index 30e079da..1cb4e40e 100644 --- a/tests/Unit/Bridge/Symfony/Validator/Constraint/EnumTest.php +++ b/tests/Unit/Bridge/Symfony/Validator/Constraint/EnumTest.php @@ -12,8 +12,9 @@ use Elao\Enum\Bridge\Symfony\Validator\Constraint\Enum; use Elao\Enum\Tests\Fixtures\Enum\SimpleEnum; +use PHPUnit\Framework\TestCase; -class EnumTest extends \PHPUnit_Framework_TestCase +class EnumTest extends TestCase { public function testDefaultValueIsEnumClass() { diff --git a/tests/Unit/Bridge/Symfony/VarDumper/Caster/EnumCasterTest.php b/tests/Unit/Bridge/Symfony/VarDumper/Caster/EnumCasterTest.php index 94d0d2ad..6bb4dd68 100644 --- a/tests/Unit/Bridge/Symfony/VarDumper/Caster/EnumCasterTest.php +++ b/tests/Unit/Bridge/Symfony/VarDumper/Caster/EnumCasterTest.php @@ -14,12 +14,13 @@ use Elao\Enum\Tests\Fixtures\Enum\Gender; use Elao\Enum\Tests\Fixtures\Enum\Permissions; use Elao\Enum\Tests\Fixtures\Enum\SimpleEnum; +use PHPUnit\Framework\TestCase; use Symfony\Component\VarDumper\Cloner\VarCloner; use Symfony\Component\VarDumper\Dumper\AbstractDumper; use Symfony\Component\VarDumper\Dumper\HtmlDumper; use Symfony\Component\VarDumper\Test\VarDumperTestTrait; -class EnumCasterTest extends \PHPUnit_Framework_TestCase +class EnumCasterTest extends TestCase { use VarDumperTestTrait; diff --git a/tests/Unit/EnumTest.php b/tests/Unit/EnumTest.php index d906e960..e9519914 100644 --- a/tests/Unit/EnumTest.php +++ b/tests/Unit/EnumTest.php @@ -12,8 +12,9 @@ use Elao\Enum\Tests\Fixtures\Enum\ExtendedSimpleEnum; use Elao\Enum\Tests\Fixtures\Enum\SimpleEnum; +use PHPUnit\Framework\TestCase; -class EnumTest extends \PHPUnit_Framework_TestCase +class EnumTest extends TestCase { public function enumValuesProvider() { diff --git a/tests/Unit/FlaggedEnumTest.php b/tests/Unit/FlaggedEnumTest.php index 4b230eb8..27b27827 100644 --- a/tests/Unit/FlaggedEnumTest.php +++ b/tests/Unit/FlaggedEnumTest.php @@ -13,8 +13,9 @@ use Elao\Enum\Tests\Fixtures\Enum\AlarmScheduleType; use Elao\Enum\Tests\Fixtures\Enum\InvalidFlagsEnum; use Elao\Enum\Tests\Fixtures\Enum\Permissions; +use PHPUnit\Framework\TestCase; -class FlaggedEnumTest extends \PHPUnit_Framework_TestCase +class FlaggedEnumTest extends TestCase { /** * @expectedException \Elao\Enum\Exception\InvalidValueException diff --git a/tests/Unit/ReadableEnumTest.php b/tests/Unit/ReadableEnumTest.php index 23308b64..7a5283ef 100644 --- a/tests/Unit/ReadableEnumTest.php +++ b/tests/Unit/ReadableEnumTest.php @@ -11,8 +11,9 @@ namespace Elao\Enum\Tests\Unit; use Elao\Enum\Tests\Fixtures\Enum\Gender; +use PHPUnit\Framework\TestCase; -class ReadableEnumTest extends \PHPUnit_Framework_TestCase +class ReadableEnumTest extends TestCase { public function enumValuesProvider() {