Skip to content

Commit 20505da

Browse files
authored
Upgrade to PHPUnit 12 (#661)
1 parent be84422 commit 20505da

File tree

5 files changed

+17
-18
lines changed

5 files changed

+17
-18
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"phpstan/phpstan-phpunit": "^2",
4848
"phpstan/phpstan-strict-rules": "^2",
4949
"phpstan/phpstan-symfony": "^2",
50-
"phpunit/phpunit": "^11.5.45",
50+
"phpunit/phpunit": "^12.5",
5151
"symfony/var-exporter": "^6.4 || ^7 || ^8"
5252
},
5353
"autoload": {

tests/Collector/MigrationsFlattenerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public function testFlattenExecutedMigrations(): void
9292

9393
private function createAvailableMigrations(): AvailableMigrationsList
9494
{
95-
$migration = new Migration001($this->createMock(Connection::class), new NullLogger());
95+
$migration = new Migration001(self::createStub(Connection::class), new NullLogger());
9696

9797
return new AvailableMigrationsList([
9898
new AvailableMigration(new Version('012345'), $migration),

tests/DependencyInjection/DoctrineCommandsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use Doctrine\Migrations\Tools\Console\Command\UpToDateCommand;
2323
use Doctrine\Migrations\Tools\Console\Command\VersionCommand;
2424
use PHPUnit\Framework\Attributes\DataProvider;
25-
use PHPUnit\Framework\MockObject\MockObject;
25+
use PHPUnit\Framework\MockObject\Stub;
2626
use PHPUnit\Framework\TestCase;
2727
use Symfony\Bundle\FrameworkBundle\Console\Application;
2828
use Symfony\Component\Console\Command\LazyCommand;
@@ -70,9 +70,9 @@ public static function getCommands(): array
7070
];
7171
}
7272

73-
private function getKernel(ContainerBuilder $container): KernelInterface&MockObject
73+
private function getKernel(ContainerBuilder $container): KernelInterface&Stub
7474
{
75-
$kernel = $this->createMock(KernelInterface::class);
75+
$kernel = self::createStub(KernelInterface::class);
7676

7777
$kernel
7878
->method('getContainer')

tests/DependencyInjection/DoctrineMigrationsExtensionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function __invoke(): void
198198

199199
public function testServiceFactory(): void
200200
{
201-
$mockComparator = $this->createMock(Comparator::class);
201+
$mockComparator = self::createStub(Comparator::class);
202202
$config = [
203203
'factories' => [Comparator::class => 'my_sorter'],
204204
];
@@ -329,7 +329,7 @@ public function testCustomMetadataStorage(): void
329329

330330
$container = $this->getContainer($config);
331331

332-
$mockStorage = $this->createMock(MetadataStorage::class);
332+
$mockStorage = self::createStub(MetadataStorage::class);
333333
$container->set('mock_storage_service', $mockStorage);
334334

335335
$container->compile();

tests/MigrationsRepository/ServiceMigrationsRepositoryTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@
88
use Doctrine\Migrations\AbstractMigration;
99
use Doctrine\Migrations\Exception\MigrationClassNotFound;
1010
use Doctrine\Migrations\Version\Version;
11+
use PHPUnit\Framework\Attributes\TestWith;
1112
use PHPUnit\Framework\TestCase;
1213
use Symfony\Contracts\Service\ServiceProviderInterface;
1314

1415
class ServiceMigrationsRepositoryTest extends TestCase
1516
{
16-
/**
17-
* @testWith [true]
18-
* [false]
19-
*/
17+
#[TestWith([true])]
18+
#[TestWith([false])]
2019
public function testHasMigration(bool $expectedResult): void
2120
{
22-
$container = $this->createMock(ServiceProviderInterface::class);
21+
$container = self::createStub(ServiceProviderInterface::class);
2322
$container->method('has')
2423
->with('Version001')
2524
->willReturn($expectedResult);
@@ -31,9 +30,9 @@ public function testHasMigration(bool $expectedResult): void
3130

3231
public function testGetMigrationReturnsAvailableMigration(): void
3332
{
34-
$migration = $this->createMock(AbstractMigration::class);
33+
$migration = self::createStub(AbstractMigration::class);
3534

36-
$container = $this->createMock(ServiceProviderInterface::class);
35+
$container = self::createStub(ServiceProviderInterface::class);
3736
$container->method('has')
3837
->with('Version001')
3938
->willReturn(true);
@@ -52,7 +51,7 @@ public function testGetMigrationReturnsAvailableMigration(): void
5251

5352
public function testGetMigrationThrowsExceptionWhenMigrationNotFound(): void
5453
{
55-
$container = $this->createMock(ServiceProviderInterface::class);
54+
$container = self::createStub(ServiceProviderInterface::class);
5655
$container->method('has')
5756
->with('NonExistentVersion')
5857
->willReturn(false);
@@ -67,10 +66,10 @@ public function testGetMigrationThrowsExceptionWhenMigrationNotFound(): void
6766

6867
public function testGetMigrationsReturnsAvailableMigrationsSet(): void
6968
{
70-
$migration1 = $this->createMock(AbstractMigration::class);
71-
$migration2 = $this->createMock(AbstractMigration::class);
69+
$migration1 = self::createStub(AbstractMigration::class);
70+
$migration2 = self::createStub(AbstractMigration::class);
7271

73-
$container = $this->createMock(ServiceProviderInterface::class);
72+
$container = self::createStub(ServiceProviderInterface::class);
7473
$container->method('getProvidedServices')
7574
->willReturn(['Version001', 'Version002']);
7675
$container->method('has')

0 commit comments

Comments
 (0)