Skip to content

Commit c7f18ca

Browse files
authored
Merge pull request #20 from phpcr/symfony-7
allow installation with symfony 7
2 parents edc68cf + 89d15d3 commit c7f18ca

9 files changed

+72
-65
lines changed

Diff for: .github/workflows/test-application.yaml

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
include:
22-
- php-version: '7.2'
22+
- php-version: '8.1'
2323
dependencies: 'lowest'
24-
- php-version: '7.3'
25-
- php-version: '7.4'
26-
- php-version: '8.0'
2724
- php-version: '8.1'
2825
- php-version: '8.2'
2926
- php-version: '8.3'

Diff for: CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Changelog
22
=========
33

4+
1.4.0
5+
-----
6+
7+
* Allow installation with Symfony 7.
8+
* Test with PHP 8.2, 8.3
9+
* Drop support for PHP < 8.1
10+
411
1.3.1
512
-----
613

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use PHPCR\Migrations\VersionFinder;
2222
use PHPCR\Migrations\Migrator;
2323

2424
$storage = new VersionStorage($phpcrSession);
25-
$finder = new VersionFinder(array('/path/to/migrations'));
25+
$finder = new VersionFinder(['/path/to/migrations']);
2626

2727
$versions = $finder->getVersionCollection();
2828
$migrator = new Migrator($session, $versionCollection, $storage);

Diff for: composer.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,15 @@
99
}
1010
],
1111
"require": {
12-
"php": "^7.2|^8.0",
12+
"php": "^8.1",
1313
"phpcr/phpcr": "^2.1",
14-
"symfony/finder": "^4.4 || ^5.0 || ^6.0",
15-
"symfony/console": "^4.4 || ^5.0 || ^6.0"
14+
"symfony/finder": "^5.4 || ^6.0 || ^7.0",
15+
"symfony/console": "^5.4 || ^6.0 || ^7.0"
1616
},
1717
"require-dev": {
18-
"jackalope/jackalope-fs": "0.0.*",
18+
"jackalope/jackalope-fs": "^0.0.4",
1919
"handcraftedinthealps/zendsearch": "^2.0",
20-
"phpunit/phpunit": "^8.5 || ^9.4",
21-
"phpspec/prophecy": "^1.19"
20+
"phpunit/phpunit": "^9.4"
2221
},
2322
"autoload": {
2423
"psr-4": {

Diff for: tests/Functional/MigrationTest.php

+18-18
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ class MigrationTest extends BaseTestCase
2525
public const VERSION2 = '201501011212';
2626
public const VERSION3 = '201501011215';
2727

28-
private $output;
29-
private $filesystem;
30-
private $migrationDistDir;
31-
private $migrationDir;
32-
private $storage;
28+
private BufferedOutput $output;
29+
private Filesystem $filesystem;
30+
private string $migrationDistDir;
31+
private string $migrationDir;
32+
private VersionStorage $storage;
3333

3434
public function setUp(): void
3535
{
@@ -49,7 +49,7 @@ public function setUp(): void
4949
/**
5050
* It should execute all the migrations and populate the versions table.
5151
*/
52-
public function testMigration()
52+
public function testMigration(): void
5353
{
5454
$this->addVersion(self::VERSION1);
5555
$this->addVersion(self::VERSION2);
@@ -72,7 +72,7 @@ public function testMigration()
7272
/**
7373
* It should not run migrations that have already been executed.
7474
*/
75-
public function testMigrateAgain()
75+
public function testMigrateAgain(): void
7676
{
7777
$this->addVersion(self::VERSION1);
7878
$this->addVersion(self::VERSION2);
@@ -88,7 +88,7 @@ public function testMigrateAgain()
8888
/**
8989
* It should run new migrations.
9090
*/
91-
public function testMigrateAdd()
91+
public function testMigrateAdd(): void
9292
{
9393
$this->addVersion(self::VERSION1);
9494

@@ -105,7 +105,7 @@ public function testMigrateAdd()
105105
/**
106106
* It should run migrations backwards.
107107
*/
108-
public function testMigrateDown()
108+
public function testMigrateDown(): void
109109
{
110110
$this->addVersion(self::VERSION1);
111111
$this->addVersion(self::VERSION2);
@@ -136,7 +136,7 @@ public function testMigrateDown()
136136
/**
137137
* It should do nothing if target version is current version.
138138
*/
139-
public function testMigrateToCurrentVersionFromCurrent()
139+
public function testMigrateToCurrentVersionFromCurrent(): void
140140
{
141141
$this->addVersion(self::VERSION1);
142142
$this->addVersion(self::VERSION2);
@@ -150,7 +150,7 @@ public function testMigrateToCurrentVersionFromCurrent()
150150
/**
151151
* It should add all migrations.
152152
*/
153-
public function testInitialize()
153+
public function testInitialize(): void
154154
{
155155
$this->addVersion(self::VERSION1);
156156
$this->addVersion(self::VERSION2);
@@ -164,7 +164,7 @@ public function testInitialize()
164164
/**
165165
* It should throw an exception if trying to reiniitialize.
166166
*/
167-
public function testReinitialize()
167+
public function testReinitialize(): void
168168
{
169169
$this->addVersion(self::VERSION1);
170170
$this->addVersion(self::VERSION2);
@@ -179,7 +179,7 @@ public function testReinitialize()
179179
/**
180180
* It should migrate to the next version.
181181
*/
182-
public function testMigrateNext()
182+
public function testMigrateNext(): void
183183
{
184184
$this->addVersion(self::VERSION1);
185185
$this->addVersion(self::VERSION2);
@@ -196,7 +196,7 @@ public function testMigrateNext()
196196
/**
197197
* It should migrate to the previous version.
198198
*/
199-
public function testMigratePrevious()
199+
public function testMigratePrevious(): void
200200
{
201201
$this->addVersion(self::VERSION1);
202202
$this->addVersion(self::VERSION2);
@@ -223,7 +223,7 @@ public function testMigratePrevious()
223223
/**
224224
* It should migrate to the top.
225225
*/
226-
public function testMigrateTop()
226+
public function testMigrateTop(): void
227227
{
228228
$this->addVersion(self::VERSION1);
229229
$this->addVersion(self::VERSION2);
@@ -235,7 +235,7 @@ public function testMigrateTop()
235235
/**
236236
* It should migrate to the bottom.
237237
*/
238-
public function testMigrateBottom()
238+
public function testMigrateBottom(): void
239239
{
240240
$this->addVersion(self::VERSION1);
241241
$this->addVersion(self::VERSION2);
@@ -245,15 +245,15 @@ public function testMigrateBottom()
245245
$this->assertCount(3, $migratedVersions);
246246
}
247247

248-
private function addVersion($version)
248+
private function addVersion($version): void
249249
{
250250
$this->filesystem->copy(
251251
$this->migrationDistDir.'/Version'.$version.'.php',
252252
$this->migrationDir.'/Version'.$version.'.php'
253253
);
254254
}
255255

256-
private function getMigrator()
256+
private function getMigrator(): Migrator
257257
{
258258
$this->storage = new VersionStorage($this->session);
259259
$finder = new VersionFinder([$this->migrationDir]);

Diff for: tests/Unit/MigratorFactoryTest.php

+15-11
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,28 @@
1111

1212
namespace PHPCR\Migrations\Tests\Unit;
1313

14+
use PHPCR\Migrations\Migrator;
1415
use PHPCR\Migrations\MigratorFactory;
16+
use PHPCR\Migrations\VersionCollection;
17+
use PHPCR\Migrations\VersionFinder;
18+
use PHPCR\Migrations\VersionStorage;
19+
use PHPCR\SessionInterface;
1520
use PHPUnit\Framework\TestCase;
1621

1722
class MigratorFactoryTest extends TestCase
1823
{
19-
public function testFactory()
24+
public function testFactory(): void
2025
{
21-
$storage = $this->prophesize('PHPCR\Migrations\VersionStorage');
22-
$finder = $this->prophesize('PHPCR\Migrations\VersionFinder');
23-
$session = $this->prophesize('PHPCR\SessionInterface');
24-
$finder->getCollection()->willReturn($this->prophesize('PHPCR\Migrations\VersionCollection')->reveal());
26+
$storage = $this->createMock(VersionStorage::class);
27+
$finder = $this->createMock(VersionFinder::class);
28+
$finder->expects($this->once())
29+
->method('getCollection')
30+
->willReturn($this->createMock(VersionCollection::class))
31+
;
32+
$session = $this->createMock(SessionInterface::class);
2533

26-
$factory = new MigratorFactory(
27-
$storage->reveal(),
28-
$finder->reveal(),
29-
$session->reveal()
30-
);
34+
$factory = new MigratorFactory($storage, $finder, $session);
3135
$migrator = $factory->getMigrator();
32-
$this->assertInstanceOf('PHPCR\Migrations\Migrator', $migrator);
36+
$this->assertInstanceOf(Migrator::class, $migrator);
3337
}
3438
}

Diff for: tests/Unit/MigratorUtilTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313

1414
use PHPCR\Migrations\MigratorUtil;
1515
use PHPUnit\Framework\TestCase;
16+
use Sulu\Bundle\ContentBundle\Version201511240843;
1617

1718
class MigratorUtilTest extends TestCase
1819
{
1920
/**
2021
* It should return the classname of a file.
2122
*/
22-
public function testGetClassName()
23+
public function testGetClassName(): void
2324
{
2425
$className = MigratorUtil::getClassNameFromFile(__DIR__.'/migrations/Version201511240843.php');
25-
$this->assertEquals('\Sulu\Bundle\ContentBundle\Version201511240843', $className);
26+
$this->assertEquals('\\'.Version201511240843::class, $className);
2627
}
2728
}

Diff for: tests/Unit/VersionCollectionTest.php

+16-15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace PHPCR\Migrations\Tests\Unit;
1313

1414
use PHPCR\Migrations\VersionCollection;
15+
use PHPCR\Migrations\VersionInterface;
1516
use PHPUnit\Framework\TestCase;
1617

1718
class VersionCollectionTest extends TestCase
@@ -22,19 +23,19 @@ class VersionCollectionTest extends TestCase
2223

2324
public function setUp(): void
2425
{
25-
$this->version1 = $this->prophesize('PHPCR\Migrations\VersionInterface');
26-
$this->version2 = $this->prophesize('PHPCR\Migrations\VersionInterface');
27-
$this->version3 = $this->prophesize('PHPCR\Migrations\VersionInterface');
26+
$this->version1 = $this->createMock(VersionInterface::class);
27+
$this->version2 = $this->createMock(VersionInterface::class);
28+
$this->version3 = $this->createMock(VersionInterface::class);
2829
}
2930

3031
/**
3132
* It knows if it contains a version.
3233
*/
33-
public function testHas()
34+
public function testHas(): void
3435
{
3536
$collection = $this->createCollection([
36-
self::VERSION1 => $this->version1->reveal(),
37-
self::VERSION3 => $this->version3->reveal(),
37+
self::VERSION1 => $this->version1,
38+
self::VERSION3 => $this->version3,
3839
]);
3940
$this->assertTrue($collection->has(self::VERSION1));
4041
$this->assertTrue($collection->has(self::VERSION3));
@@ -44,12 +45,12 @@ public function testHas()
4445
/**
4546
* It returns the versions required to migrate from up from A to B.
4647
*/
47-
public function testFromAToBUp()
48+
public function testFromAToBUp(): void
4849
{
4950
$collection = $this->createCollection([
50-
self::VERSION1 => $this->version1->reveal(),
51-
self::VERSION2 => $this->version2->reveal(),
52-
self::VERSION3 => $this->version3->reveal(),
51+
self::VERSION1 => $this->version1,
52+
self::VERSION2 => $this->version2,
53+
self::VERSION3 => $this->version3,
5354
]);
5455

5556
$versions = $collection->getVersions(self::VERSION1, self::VERSION3);
@@ -62,12 +63,12 @@ public function testFromAToBUp()
6263
/**
6364
* It returns the versions required to migrate down from A to B.
6465
*/
65-
public function testDownFromAToBUp()
66+
public function testDownFromAToBUp(): void
6667
{
6768
$collection = $this->createCollection([
68-
self::VERSION1 => $this->version1->reveal(),
69-
self::VERSION2 => $this->version2->reveal(),
70-
self::VERSION3 => $this->version3->reveal(),
69+
self::VERSION1 => $this->version1,
70+
self::VERSION2 => $this->version2,
71+
self::VERSION3 => $this->version3,
7172
]);
7273

7374
$versions = $collection->getVersions(self::VERSION3, self::VERSION1);
@@ -77,7 +78,7 @@ public function testDownFromAToBUp()
7778
], array_map('strval', array_keys($versions)));
7879
}
7980

80-
private function createCollection($versions)
81+
private function createCollection(array $versions): VersionCollection
8182
{
8283
return new VersionCollection($versions);
8384
}

Diff for: tests/Unit/VersionFinderTest.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,13 @@
1111

1212
namespace PHPCR\Migrations\Tests\Unit;
1313

14+
use PHPCR\Migrations\VersionCollection;
1415
use PHPCR\Migrations\VersionFinder;
1516
use PHPUnit\Framework\TestCase;
1617

1718
class VersionFinderTest extends TestCase
1819
{
19-
/**
20-
* @var VersionFinder
21-
*/
22-
private $finder;
20+
private VersionFinder $finder;
2321

2422
public function setUp(): void
2523
{
@@ -33,21 +31,21 @@ public function setUp(): void
3331
*
3432
* @runInSeparateProcess
3533
*/
36-
public function testGetCollection()
34+
public function testGetCollection(): void
3735
{
3836
$collection = $this->finder->getCollection();
39-
$this->assertInstanceOf('PHPCR\Migrations\VersionCollection', $collection);
37+
$this->assertInstanceOf(VersionCollection::class, $collection);
4038
$versions = $collection->getAllVersions();
4139
$this->assertCount(3, $versions);
4240
}
4341

4442
/**
4543
* It should do nothing if no migrations paths are given.
4644
*/
47-
public function testNoMigrationPaths()
45+
public function testNoMigrationPaths(): void
4846
{
4947
$this->expectException(\RuntimeException::class);
5048
$this->expectExceptionMessage('No paths were provided');
51-
$versionFinder = new VersionFinder([]);
49+
new VersionFinder([]);
5250
}
5351
}

0 commit comments

Comments
 (0)