Skip to content

Commit

Permalink
Merge branch 'alexander-schranz-feature/github-actions'
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Jan 22, 2021
2 parents c7d4ef5 + 9b90b9d commit de07dfb
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 53 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/test-application.yaml
Original file line number Diff line number Diff line change
@@ -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
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Changelog
=========

1.3.0
-----

* Support PHP 8.
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -25,7 +26,7 @@
},
"autoload-dev": {
"psr-4": {
"PHPCR\\Migrations\\": "tests"
"PHPCR\\Migrations\\Tests\\": "tests"
}
},
"extra": {
Expand Down
5 changes: 2 additions & 3 deletions lib/Migrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -79,7 +79,6 @@ public function migrate($to = null, OutputInterface $output)
return array();
}

$start = microtime(true);
$position = 0;
$output->writeln(sprintf('<comment>%s</comment> %d version(s):', ($direction == 'up' ? 'Upgrading' : 'Reverting'), count($versionsToExecute)));
foreach ($versionsToExecute as $timestamp => $version) {
Expand Down
2 changes: 1 addition & 1 deletion lib/MigratorUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions lib/VersionFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace PHPCR\Migrations;

use PHPCR\Migrations\Exception\MigratorException;
use Symfony\Component\Finder\Finder;

class VersionFinder
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</testsuites>

<filter>

<whitelist addUncoveredFilesFromWhitelist="true">
<directory>.</directory>
<exclude>
Expand Down
2 changes: 1 addition & 1 deletion tests/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions tests/Functional/MigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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';
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
2 changes: 1 addition & 1 deletion tests/Unit/MigratorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/MigratorUtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/VersionCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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');
Expand Down
9 changes: 7 additions & 2 deletions tests/Unit/VersionFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@
* 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;
use PHPUnit\Framework\TestCase;

class VersionFinderTest extends TestCase
{
public function setUp()
/**
* @var VersionFinder
*/
private $finder;

public function setUp(): void
{
$this->finder = new VersionFinder(array(
__DIR__ . '/../migrations',
Expand Down

0 comments on commit de07dfb

Please sign in to comment.