From ec06ac0f0fdb39c7f8e65b382aee1631b0ddbb27 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Wed, 22 Nov 2017 16:11:47 +0100 Subject: [PATCH] test with php 7.1 and 7.2 --- .travis.yml | 50 ++++++++++++------- composer.json | 16 +++--- lib/Doctrine/ODM/PHPCR/Id/IdException.php | 12 ++--- .../Functional/FindTypeValidationTest.php | 10 ++-- .../Versioning/VersioningTestAbstract.php | 3 +- .../ODM/PHPCR/Id/ParentIdGeneratorTest.php | 6 +-- .../DocumentConvertTranslationCommandTest.php | 5 ++ 7 files changed, 60 insertions(+), 42 deletions(-) diff --git a/.travis.yml b/.travis.yml index 705a6290a..b3f54988a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,8 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 + - 7.2 sudo: false @@ -13,40 +15,54 @@ cache: - $HOME/.composer/cache/files env: - - TRANSPORT=jackrabbit PACKAGE_VERSION=high - - TRANSPORT=doctrine_dbal PACKAGE_VERSION=high + global: + # on PHP 7.2 we get deprecations about using each. they come from old phpunit versions, but we don't update phpunit for the maintenance branch. + - SYMFONY_DEPRECATIONS_HELPER="/.*each.*/" + matrix: + - TRANSPORT=jackrabbit + - TRANSPORT=doctrine_dbal matrix: + fast_finish: true include: - php: 5.3 env: TRANSPORT=doctrine_dbal COMPOSER_FLAGS="--prefer-lowest" dist: precise -# composer fails to find a solution even though i think there should exist one -# - php: 5.3 -# env: TRANSPORT=jackrabbit COMPOSER_FLAGS="--prefer-lowest" - - php: 7.0 - env: TRANSPORT=doctrine_dbal SYMFONY_VERSION="2.7" - - php: 7.0 - env: TRANSPORT=jackrabbit SYMFONY_VERSION="2.7" - - php: 7.0 - env: TRANSPORT=doctrine_dbal SYMFONY_VERSION="2.8" PHPBENCH="yes" - - php: 7.0 - env: TRANSPORT=jackrabbit SYMFONY_VERSION="2.8" PHPBENCH="yes" + - php: 5.3 + # composer fails to find a solution for --prefer-lowest, even though i think there should exist one + env: TRANSPORT=jackrabbit + dist: precise + - php: 7.2 + env: TRANSPORT=doctrine_dbal DEPENDENCIES="symfony/lts:^2" + - php: 7.2 + env: TRANSPORT=jackrabbit DEPENDENCIES="symfony/lts:^2" + - php: 7.2 + env: TRANSPORT=doctrine_dbal DEPENDENCIES="symfony/lts:^3" PHPBENCH="yes" + - php: 7.2 + env: TRANSPORT=jackrabbit DEPENDENCIES="symfony/lts:^3" PHPBENCH="yes" + - php: 7.2 + env: TRANSPORT=doctrine_dbal STABILITY="dev" + - php: 7.2 + env: TRANSPORT=jackrabbit STABILITY="dev" - php: hhvm dist: trusty -before_script: - - composer self-update || true +before_install: - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi - - if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update symfony/symfony=$SYMFONY_VERSION; fi; + - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi + - if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; + - if ! [ -v "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi; - if [ "$PHPBENCH" = "yes" ]; then composer require --no-update phpbench/phpbench=~0.11; fi; + +install: + # this also does the composer update - ./tests/travis_${TRANSPORT}.sh script: + - composer validate --strict --no-check-lock - vendor/bin/phpunit -c tests/phpunit_${TRANSPORT}.xml.dist - if [ "$PHPBENCH" = "yes" ]; then php vendor/bin/phpbench run --report=all; fi; - notifications: irc: "irc.freenode.org#symfony-cmf" email: "symfony-cmf-devs@googlegroups.com" diff --git a/composer.json b/composer.json index 6aa7997c8..d325c6e65 100644 --- a/composer.json +++ b/composer.json @@ -13,26 +13,26 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": "^5.3.9|~7.0", + "php": "^5.3.9 || ^7.0", "doctrine/common": "^2.4", "doctrine/annotations": "^1.2", "doctrine/data-fixtures": "^1.0", "phpcr/phpcr": "^2.1.1", - "phpcr/phpcr-implementation": "^2.1.0", + "phpcr/phpcr-implementation": "^2.1", "phpcr/phpcr-utils": "^1.2.8", "doctrine/instantiator": "^1.0.1", "symfony/console": "^2.3|^3.0" }, "require-dev": { - "symfony/yaml": "^2.3|^3.0", - "symfony/phpunit-bridge": "^2.7|^3.0", - "liip/rmt": "~1.2", - "phpunit/phpunit": "^4.8|5.*" + "symfony/yaml": "^2.3 || ^3.0", + "symfony/phpunit-bridge": "^2.7 || ^3.0", + "liip/rmt": "^1.2", + "phpunit/phpunit": "^4.8 || ^5.0" }, "suggest": { "symfony/yaml": "^2.3|^3.0", - "jackalope/jackalope-doctrine-dbal": "^1.3.0", - "jackalope/jackalope-jackrabbit": "^1.3.0" + "jackalope/jackalope-doctrine-dbal": "^1.3", + "jackalope/jackalope-jackrabbit": "^1.3" }, "conflict": { "jackalope/jackalope-doctrine-dbal": "<1.1.5" diff --git a/lib/Doctrine/ODM/PHPCR/Id/IdException.php b/lib/Doctrine/ODM/PHPCR/Id/IdException.php index 39962fa3b..0b26db696 100644 --- a/lib/Doctrine/ODM/PHPCR/Id/IdException.php +++ b/lib/Doctrine/ODM/PHPCR/Id/IdException.php @@ -14,7 +14,7 @@ public static function noIdentificationParameters($document, $parent, $nodename) 'may not be empty in document of class "%s"', $parent, $nodename, - ClassUtils::getClass($document) + $document ? ClassUtils::getClass($document) : 'null' ); return new self($message); @@ -25,7 +25,7 @@ public static function noIdNoParent($document, $parent) $message = sprintf( 'Property "%s" mapped as ParentDocument may not be empty in document of class "%s"', $parent, - ClassUtils::getClass($document) + $document ? ClassUtils::getClass($document) : 'null' ); return new self($message); @@ -36,7 +36,7 @@ public static function noIdNoName($document, $fieldName) $message = sprintf( 'NodeName property "%s" may not be empty in document of class "%s"', $fieldName, - ClassUtils::getClass($document) + $document ? ClassUtils::getClass($document) : 'null' ); return new self($message); @@ -49,7 +49,7 @@ public static function parentIdCouldNotBeDetermined($document, $parent, $parentO 'ParentDocument property "%s" of document of class "%s" contains an ' . 'object for which no ID could be found', $parent, - ClassUtils::getClass($document), + $document ? ClassUtils::getClass($document) : 'null', $parentType ); @@ -61,7 +61,7 @@ public static function illegalName($document, $fieldName, $nodeName) $message = sprintf( 'NodeName property "%s" of document "%s" contains the illegal PHPCR value "%s".', $fieldName, - ClassUtils::getClass($document), + $document ? ClassUtils::getClass($document) : 'null', $nodeName ); @@ -78,7 +78,7 @@ public static function conflictingChildName( $message = sprintf( '%s discovered as new child of %s in field "%s" has a node name ' . 'mismatch. The mapping says "%s" but the child was assigned "%s".', - ClassUtils::getClass($childDocument), + $childDocument ? ClassUtils::getClass($childDocument) : 'null', $parentId, $parentFieldName, $fieldNodeName, diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/FindTypeValidationTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/FindTypeValidationTest.php index 201c7619b..6d3547d19 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/FindTypeValidationTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/FindTypeValidationTest.php @@ -2,9 +2,7 @@ namespace Doctrine\Tests\ODM\PHPCR\Functional; -use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -use Doctrine\ODM\PHPCR\DocumentRepository; -use Doctrine\ODM\PHPCR\Exception\InvalidArgumentException; +use Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase; use PHPCR\PropertyType; use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM; @@ -13,7 +11,7 @@ * * @group functional */ -class FindTypeValidationTest extends \Doctrine\Tests\ODM\PHPCR\PHPCRFunctionalTestCase +class FindTypeValidationTest extends PHPCRFunctionalTestCase { /** * @var \Doctrine\ODM\PHPCR\DocumentManager @@ -114,7 +112,7 @@ public function testNotInstanceOf() { $user = $this->dm->find('Doctrine\Tests\ODM\PHPCR\Functional\TypeTeamUser', '/functional/user'); - $this->assertTrue(null === $user, get_class($user)); + $this->assertTrue(null === $user, is_object($user) ? get_class($user) : $user); } /** @@ -126,7 +124,7 @@ public function testCacheNotInstanceOf() $this->assertInstanceOf($this->type, $user); $user = $this->dm->find('Doctrine\Tests\ODM\PHPCR\Functional\TypeTeamUser', '/functional/user'); - $this->assertTrue(null === $user, get_class($user)); + $this->assertTrue(null === $user, is_object($user) ? get_class($user) : $user); } /** diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTestAbstract.php b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTestAbstract.php index 3c67a6aa6..6c127e05e 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTestAbstract.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Functional/Versioning/VersioningTestAbstract.php @@ -135,8 +135,7 @@ public function testRestoreVersion() $this->dm->flush(); $versions = $this->dm->getAllLinearVersions($user); - each($versions); - list($dummy, $versionInfo) = each($versions); + $versionInfo = next($versions); $versionName = $versionInfo['name']; $versionDocument = $this->dm->findVersionByName($this->typeVersion, '/functional/versionTestObj', $versionName); $this->dm->restoreVersion($versionDocument); diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Id/ParentIdGeneratorTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Id/ParentIdGeneratorTest.php index ce1fbd841..ff7d6ae92 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Id/ParentIdGeneratorTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Id/ParentIdGeneratorTest.php @@ -8,7 +8,7 @@ class ParentIdGeneratorTest extends \PHPUnit_Framework_TestCase { /** - * @covers Doctrine\ODM\PHPCR\Id\ParentIdGenerator::generate + * @covers \Doctrine\ODM\PHPCR\Id\ParentIdGenerator::generate */ public function testGenerate() { @@ -34,7 +34,7 @@ public function testGenerate() } /** - * @covers Doctrine\ODM\PHPCR\Id\ParentIdGenerator::generate + * @covers \Doctrine\ODM\PHPCR\Id\ParentIdGenerator::generate */ public function testGenerateNoParent() { @@ -48,7 +48,7 @@ public function testGenerateNoParent() } /** - * @covers Doctrine\ODM\PHPCR\Id\ParentIdGenerator::generate + * @covers \Doctrine\ODM\PHPCR\Id\ParentIdGenerator::generate */ public function testGenerateNoName() { diff --git a/tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DocumentConvertTranslationCommandTest.php b/tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DocumentConvertTranslationCommandTest.php index 528df002d..59994fa84 100644 --- a/tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DocumentConvertTranslationCommandTest.php +++ b/tests/Doctrine/Tests/ODM/PHPCR/Tools/Command/DocumentConvertTranslationCommandTest.php @@ -60,6 +60,11 @@ public function testCommand() ->with('Document\MyClass', array('en'), array(), 'none') ->will($this->returnValue(false)) ; + $this->converter + ->expects($this->any()) + ->method('getLastNotices') + ->will($this->returnValue(array())) + ; $this->mockSession ->expects($this->once())