Skip to content

Commit de07dfb

Browse files
committed
Merge branch 'alexander-schranz-feature/github-actions'
2 parents c7d4ef5 + 9b90b9d commit de07dfb

14 files changed

+82
-53
lines changed
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test application
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- 'master'
8+
9+
jobs:
10+
test:
11+
name: 'PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}'
12+
runs-on: ubuntu-20.04
13+
env:
14+
SYMFONY_DEPRECATIONS_HELPER: weak
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- php-version: '7.2'
21+
dependencies: 'lowest'
22+
- php-version: '7.3'
23+
- php-version: '7.4'
24+
- php-version: '8.0'
25+
26+
steps:
27+
- name: Checkout project
28+
uses: actions/checkout@v2
29+
30+
- name: Install and configure PHP
31+
uses: shivammathur/setup-php@v2
32+
with:
33+
php-version: ${{ matrix.php-version }}
34+
tools: 'composer:v2'
35+
36+
- name: Install dependencies with Composer
37+
uses: ramsey/composer-install@v1
38+
with:
39+
dependency-versions: ${{ matrix.dependencies }}
40+
composer-options: --prefer-dist
41+
42+
- name: Execute test cases
43+
run: vendor/bin/phpunit

.travis.yml

-29
This file was deleted.

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Changelog
2+
=========
3+
4+
1.3.0
5+
-----
6+
7+
* Support PHP 8.

composer.json

+6-5
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
}
1010
],
1111
"require": {
12+
"php": "^7.2|^8.0",
1213
"phpcr/phpcr": "^2.1",
13-
"symfony/finder": "^2.8 || ^3.4 || ^4.0 || ^5.0",
14-
"symfony/console": "^2.8 || ^3.4 || ^4.0 || ^5.0"
14+
"symfony/finder": "^4.4 || ^5.0",
15+
"symfony/console": "^4.4 || ^5.0"
1516
},
1617
"require-dev": {
17-
"symfony/phpunit-bridge": "^5.0.4",
1818
"jackalope/jackalope-fs": "0.0.*",
19-
"handcraftedinthealps/zendsearch": "^2.0"
19+
"handcraftedinthealps/zendsearch": "^2.0",
20+
"phpunit/phpunit": "^8.5 || ^9.4"
2021
},
2122
"autoload": {
2223
"psr-4": {
@@ -25,7 +26,7 @@
2526
},
2627
"autoload-dev": {
2728
"psr-4": {
28-
"PHPCR\\Migrations\\": "tests"
29+
"PHPCR\\Migrations\\Tests\\": "tests"
2930
}
3031
},
3132
"extra": {

lib/Migrator.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public function initialize()
5757
* If $to is 0 then all migrations will be reverted.
5858
* If $to is null then all migrations will be executed.
5959
*
60-
* @param string $to Version to run until
60+
* @param string|null $to Version to run until
6161
* @param OutputInterface $output
6262
*
6363
* @return VersionInterface[] Executed migrations
6464
*/
65-
public function migrate($to = null, OutputInterface $output)
65+
public function migrate($to, OutputInterface $output)
6666
{
6767
if (false === $to) {
6868
return array();
@@ -79,7 +79,6 @@ public function migrate($to = null, OutputInterface $output)
7979
return array();
8080
}
8181

82-
$start = microtime(true);
8382
$position = 0;
8483
$output->writeln(sprintf('<comment>%s</comment> %d version(s):', ($direction == 'up' ? 'Upgrading' : 'Reverting'), count($versionsToExecute)));
8584
foreach ($versionsToExecute as $timestamp => $version) {

lib/MigratorUtil.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function getClassNameFromFile($file)
4747
for (;$i < count($tokens);$i++) {
4848
if ($tokens[$i][0] === T_NAMESPACE) {
4949
for ($j = $i + 1;$j < count($tokens); $j++) {
50-
if ($tokens[$j][0] === T_STRING) {
50+
if (\defined('T_NAME_QUALIFIED') && $tokens[$j][0] === T_NAME_QUALIFIED || $tokens[$j][0] === T_STRING) {
5151
$namespace .= '\\' . $tokens[$j][1];
5252
} elseif ($tokens[$j] === '{' || $tokens[$j] === ';') {
5353
break;

lib/VersionFinder.php

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace PHPCR\Migrations;
1313

14+
use PHPCR\Migrations\Exception\MigratorException;
1415
use Symfony\Component\Finder\Finder;
1516

1617
class VersionFinder

phpunit.xml.dist

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</testsuites>
1919

2020
<filter>
21+
2122
<whitelist addUncoveredFilesFromWhitelist="true">
2223
<directory>.</directory>
2324
<exclude>

tests/BaseTestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations;
12+
namespace PHPCR\Migrations\Tests;
1313

1414
use Jackalope\RepositoryFactoryFilesystem;
1515
use PHPCR\SimpleCredentials;

tests/Functional/MigrationTest.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Functional;
12+
namespace PHPCR\Migrations\Tests\Functional;
1313

14-
use PHPCR\Migrations\BaseTestCase;
1514
use PHPCR\Migrations\Exception\MigratorException;
1615
use PHPCR\Migrations\Migrator;
16+
use PHPCR\Migrations\Tests\BaseTestCase;
1717
use PHPCR\Migrations\VersionFinder;
1818
use PHPCR\Migrations\VersionStorage;
1919
use Symfony\Component\Console\Output\BufferedOutput;
@@ -27,10 +27,11 @@ class MigrationTest extends BaseTestCase
2727

2828
private $output;
2929
private $filesystem;
30+
private $migrationDistDir;
3031
private $migrationDir;
3132
private $storage;
3233

33-
public function setUp()
34+
public function setUp(): void
3435
{
3536
$this->initPhpcr();
3637
$this->migrationDir = __DIR__ . '/../migrations';
@@ -63,9 +64,9 @@ public function testMigration()
6364
$nodes = $this->session->getNode('/phpcrmig:versions')->getNodes();
6465
$names = array_keys((array) $nodes);
6566

66-
$this->assertContains('201501011200', $names);
67-
$this->assertContains('201501011212', $names);
68-
$this->assertContains('201501011215', $names);
67+
$this->assertContains(201501011200, $names);
68+
$this->assertContains(201501011212, $names);
69+
$this->assertContains(201501011215, $names);
6970
}
7071

7172
/**
@@ -201,6 +202,7 @@ public function testMigratePrevious()
201202
$this->addVersion(self::VERSION2);
202203
$this->addVersion(self::VERSION3);
203204
$migratedVersions = $this->getMigrator()->migrate(null, $this->output);
205+
$this->assertCount(3, $migratedVersions);
204206
$this->assertEquals(self::VERSION3, $this->storage->getCurrentVersion());
205207

206208
$migratedVersions = $this->getMigrator()->migrate('down', $this->output);
@@ -256,8 +258,7 @@ private function getMigrator()
256258
$this->storage = new VersionStorage($this->session);
257259
$finder = new VersionFinder(array($this->migrationDir));
258260
$versions = $finder->getCollection();
259-
$migrator = new Migrator($this->session, $versions, $this->storage);
260261

261-
return $migrator;
262+
return new Migrator($this->session, $versions, $this->storage);
262263
}
263264
}

tests/Unit/MigratorFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Unit;
12+
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\Migrator;
1515
use PHPCR\Migrations\MigratorFactory;

tests/Unit/MigratorUtilTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Unit;
12+
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\MigratorUtil;
1515
use PHPUnit\Framework\TestCase;

tests/Unit/VersionCollectionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Unit;
12+
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\VersionCollection;
1515
use PHPCR\Migrations\VersionInterface;
@@ -21,7 +21,7 @@ class VersionCollectionTest extends TestCase
2121
const VERSION2 = '201501020000';
2222
const VERSION3 = '201501030000';
2323

24-
public function setUp()
24+
public function setUp(): void
2525
{
2626
$this->version1 = $this->prophesize('PHPCR\Migrations\VersionInterface');
2727
$this->version2 = $this->prophesize('PHPCR\Migrations\VersionInterface');

tests/Unit/VersionFinderTest.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace PHPCR\Migrations\tests\Unit;
12+
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\VersionCollection;
1515
use PHPCR\Migrations\VersionFinder;
1616
use PHPUnit\Framework\TestCase;
1717

1818
class VersionFinderTest extends TestCase
1919
{
20-
public function setUp()
20+
/**
21+
* @var VersionFinder
22+
*/
23+
private $finder;
24+
25+
public function setUp(): void
2126
{
2227
$this->finder = new VersionFinder(array(
2328
__DIR__ . '/../migrations',

0 commit comments

Comments
 (0)