From 055e2973d62950d3c5d5dd3438b4da8fe7c1f32e Mon Sep 17 00:00:00 2001 From: Pablo Lozano Date: Fri, 30 Oct 2020 00:39:52 +0100 Subject: [PATCH 1/3] Allow PHP 8 and fix some deprecations --- .travis.yml | 10 +++++----- composer.json | 11 ++++++----- lib/Migrator.php | 5 ++--- lib/MigratorUtil.php | 2 +- lib/VersionFinder.php | 1 + phpunit.xml.dist | 1 + tests/BaseTestCase.php | 2 +- tests/Functional/MigrationTest.php | 17 +++++++++-------- tests/Unit/MigratorFactoryTest.php | 2 +- tests/Unit/MigratorUtilTest.php | 2 +- tests/Unit/VersionCollectionTest.php | 4 ++-- tests/Unit/VersionFinderTest.php | 9 +++++++-- 12 files changed, 37 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5399df8..37f7bc8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: php php: - - 5.6 - - 7.1 - 7.2 - 7.3 @@ -13,12 +11,14 @@ sudo: false matrix: include: - - php: 5.6 - env: PACKAGE_VERSION=low - php: 7.4 env: - MINIMUM_STABILITY=dev - PACKAGE_VERSION=high + - php: nightly + env: + - MINIMUM_STABILITY=dev + - PACKAGE_VERSION=high before_script: - composer selfupdate @@ -26,4 +26,4 @@ before_script: - if [[ "$PACKAGE_VERSION" == "high" ]]; then composer update --prefer-dist; fi - if [[ "$PACKAGE_VERSION" == "low" ]]; then composer update --prefer-lowest --prefer-dist; fi -script: vendor/bin/simple-phpunit +script: vendor/bin/phpunit diff --git a/composer.json b/composer.json index d8e5018..136cce2 100644 --- a/composer.json +++ b/composer.json @@ -9,14 +9,15 @@ } ], "require": { + "php": "^7.2|^8.0", "phpcr/phpcr": "^2.1", - "symfony/finder": "^2.8 || ^3.4 || ^4.0 || ^5.0", - "symfony/console": "^2.8 || ^3.4 || ^4.0 || ^5.0" + "symfony/finder": "^4.4 || ^5.0", + "symfony/console": "^4.4 || ^5.0" }, "require-dev": { - "symfony/phpunit-bridge": "^5.0.4", "jackalope/jackalope-fs": "0.0.*", - "handcraftedinthealps/zendsearch": "^2.0" + "handcraftedinthealps/zendsearch": "^2.0", + "phpunit/phpunit": "^8.5 || ^9.4" }, "autoload": { "psr-4": { @@ -25,7 +26,7 @@ }, "autoload-dev": { "psr-4": { - "PHPCR\\Migrations\\": "tests" + "PHPCR\\Migrations\\Tests\\": "tests" } }, "extra": { diff --git a/lib/Migrator.php b/lib/Migrator.php index eac6d09..3452585 100644 --- a/lib/Migrator.php +++ b/lib/Migrator.php @@ -57,12 +57,12 @@ public function initialize() * If $to is 0 then all migrations will be reverted. * If $to is null then all migrations will be executed. * - * @param string $to Version to run until + * @param string|null $to Version to run until * @param OutputInterface $output * * @return VersionInterface[] Executed migrations */ - public function migrate($to = null, OutputInterface $output) + public function migrate($to, OutputInterface $output) { if (false === $to) { return array(); @@ -79,7 +79,6 @@ public function migrate($to = null, OutputInterface $output) return array(); } - $start = microtime(true); $position = 0; $output->writeln(sprintf('%s %d version(s):', ($direction == 'up' ? 'Upgrading' : 'Reverting'), count($versionsToExecute))); foreach ($versionsToExecute as $timestamp => $version) { diff --git a/lib/MigratorUtil.php b/lib/MigratorUtil.php index ced0ce4..8e5abae 100644 --- a/lib/MigratorUtil.php +++ b/lib/MigratorUtil.php @@ -47,7 +47,7 @@ public static function getClassNameFromFile($file) for (;$i < count($tokens);$i++) { if ($tokens[$i][0] === T_NAMESPACE) { for ($j = $i + 1;$j < count($tokens); $j++) { - if ($tokens[$j][0] === T_STRING) { + if (\defined('T_NAME_QUALIFIED') && $tokens[$j][0] === T_NAME_QUALIFIED || $tokens[$j][0] === T_STRING) { $namespace .= '\\' . $tokens[$j][1]; } elseif ($tokens[$j] === '{' || $tokens[$j] === ';') { break; diff --git a/lib/VersionFinder.php b/lib/VersionFinder.php index 7a364d0..c0dd048 100644 --- a/lib/VersionFinder.php +++ b/lib/VersionFinder.php @@ -11,6 +11,7 @@ namespace PHPCR\Migrations; +use PHPCR\Migrations\Exception\MigratorException; use Symfony\Component\Finder\Finder; class VersionFinder diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 462c2b2..f9e77c3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -18,6 +18,7 @@ + . diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 97aee90..aa8b91d 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace PHPCR\Migrations; +namespace PHPCR\Migrations\Tests; use Jackalope\RepositoryFactoryFilesystem; use PHPCR\SimpleCredentials; diff --git a/tests/Functional/MigrationTest.php b/tests/Functional/MigrationTest.php index afa9eda..7fdcdcb 100644 --- a/tests/Functional/MigrationTest.php +++ b/tests/Functional/MigrationTest.php @@ -9,11 +9,11 @@ * file that was distributed with this source code. */ -namespace PHPCR\Migrations\tests\Functional; +namespace PHPCR\Migrations\Tests\Functional; -use PHPCR\Migrations\BaseTestCase; use PHPCR\Migrations\Exception\MigratorException; use PHPCR\Migrations\Migrator; +use PHPCR\Migrations\Tests\BaseTestCase; use PHPCR\Migrations\VersionFinder; use PHPCR\Migrations\VersionStorage; use Symfony\Component\Console\Output\BufferedOutput; @@ -27,10 +27,11 @@ class MigrationTest extends BaseTestCase private $output; private $filesystem; + private $migrationDistDir; private $migrationDir; private $storage; - public function setUp() + public function setUp(): void { $this->initPhpcr(); $this->migrationDir = __DIR__ . '/../migrations'; @@ -63,9 +64,9 @@ public function testMigration() $nodes = $this->session->getNode('/phpcrmig:versions')->getNodes(); $names = array_keys((array) $nodes); - $this->assertContains('201501011200', $names); - $this->assertContains('201501011212', $names); - $this->assertContains('201501011215', $names); + $this->assertContains(201501011200, $names); + $this->assertContains(201501011212, $names); + $this->assertContains(201501011215, $names); } /** @@ -201,6 +202,7 @@ public function testMigratePrevious() $this->addVersion(self::VERSION2); $this->addVersion(self::VERSION3); $migratedVersions = $this->getMigrator()->migrate(null, $this->output); + $this->assertCount(3, $migratedVersions); $this->assertEquals(self::VERSION3, $this->storage->getCurrentVersion()); $migratedVersions = $this->getMigrator()->migrate('down', $this->output); @@ -256,8 +258,7 @@ private function getMigrator() $this->storage = new VersionStorage($this->session); $finder = new VersionFinder(array($this->migrationDir)); $versions = $finder->getCollection(); - $migrator = new Migrator($this->session, $versions, $this->storage); - return $migrator; + return new Migrator($this->session, $versions, $this->storage); } } diff --git a/tests/Unit/MigratorFactoryTest.php b/tests/Unit/MigratorFactoryTest.php index 8f4b1f7..1c8c38f 100644 --- a/tests/Unit/MigratorFactoryTest.php +++ b/tests/Unit/MigratorFactoryTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace PHPCR\Migrations\tests\Unit; +namespace PHPCR\Migrations\Tests\Unit; use PHPCR\Migrations\Migrator; use PHPCR\Migrations\MigratorFactory; diff --git a/tests/Unit/MigratorUtilTest.php b/tests/Unit/MigratorUtilTest.php index 826271e..d7e5b90 100644 --- a/tests/Unit/MigratorUtilTest.php +++ b/tests/Unit/MigratorUtilTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace PHPCR\Migrations\tests\Unit; +namespace PHPCR\Migrations\Tests\Unit; use PHPCR\Migrations\MigratorUtil; use PHPUnit\Framework\TestCase; diff --git a/tests/Unit/VersionCollectionTest.php b/tests/Unit/VersionCollectionTest.php index d772267..8fb0bf7 100644 --- a/tests/Unit/VersionCollectionTest.php +++ b/tests/Unit/VersionCollectionTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace PHPCR\Migrations\tests\Unit; +namespace PHPCR\Migrations\Tests\Unit; use PHPCR\Migrations\VersionCollection; use PHPCR\Migrations\VersionInterface; @@ -21,7 +21,7 @@ class VersionCollectionTest extends TestCase const VERSION2 = '201501020000'; const VERSION3 = '201501030000'; - public function setUp() + public function setUp(): void { $this->version1 = $this->prophesize('PHPCR\Migrations\VersionInterface'); $this->version2 = $this->prophesize('PHPCR\Migrations\VersionInterface'); diff --git a/tests/Unit/VersionFinderTest.php b/tests/Unit/VersionFinderTest.php index 9ca611a..b526d42 100644 --- a/tests/Unit/VersionFinderTest.php +++ b/tests/Unit/VersionFinderTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace PHPCR\Migrations\tests\Unit; +namespace PHPCR\Migrations\Tests\Unit; use PHPCR\Migrations\VersionCollection; use PHPCR\Migrations\VersionFinder; @@ -17,7 +17,12 @@ class VersionFinderTest extends TestCase { - public function setUp() + /** + * @var VersionFinder + */ + private $finder; + + public function setUp(): void { $this->finder = new VersionFinder(array( __DIR__ . '/../migrations', From 0dca2924cad19a774a164fa2dbbeeb0183d0cab8 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Tue, 19 Jan 2021 17:09:22 +0100 Subject: [PATCH 2/3] Migrate to github actions --- .github/workflows/test-application.yaml | 43 +++++++++++++++++++++++++ .travis.yml | 29 ----------------- 2 files changed, 43 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/test-application.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml new file mode 100644 index 0000000..4dda9b8 --- /dev/null +++ b/.github/workflows/test-application.yaml @@ -0,0 +1,43 @@ +name: Test application + +on: + pull_request: + push: + branches: + - 'master' + +jobs: + test: + name: 'PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}' + runs-on: ubuntu-20.04 + env: + SYMFONY_DEPRECATIONS_HELPER: weak + + strategy: + fail-fast: false + matrix: + include: + - php-version: '7.2' + dependencies: 'lowest' + - php-version: '7.3' + - php-version: '7.4' + - php-version: '8.0' + + steps: + - name: Checkout project + uses: actions/checkout@v2 + + - name: Install and configure PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + tools: 'composer:v2' + + - name: Install dependencies with Composer + uses: ramsey/composer-install@v1 + with: + dependency-versions: ${{ matrix.dependencies }} + composer-options: --prefer-dist + + - name: Execute test cases + run: vendor/bin/phpunit diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 37f7bc8..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: php - -php: - - 7.2 - - 7.3 - -env: - - PACKAGE_VERSION=high - -sudo: false - -matrix: - include: - - php: 7.4 - env: - - MINIMUM_STABILITY=dev - - PACKAGE_VERSION=high - - php: nightly - env: - - MINIMUM_STABILITY=dev - - PACKAGE_VERSION=high - -before_script: - - composer selfupdate - - if [[ "$MINIMUM_STABILITY" ]]; then composer config minimum-stability $MINIMUM_STABILITY ; fi - - if [[ "$PACKAGE_VERSION" == "high" ]]; then composer update --prefer-dist; fi - - if [[ "$PACKAGE_VERSION" == "low" ]]; then composer update --prefer-lowest --prefer-dist; fi - -script: vendor/bin/phpunit From 9b90b9dfa20cad44303c80005d3824141b814807 Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Fri, 22 Jan 2021 13:00:03 +0100 Subject: [PATCH 3/3] prepare release --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7d2e9c9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,7 @@ +Changelog +========= + +1.3.0 +----- + +* Support PHP 8.