Skip to content

Commit

Permalink
Merge pull request #1342 from greg0ire/phpunit10
Browse files Browse the repository at this point in the history
Phpunit10
  • Loading branch information
greg0ire committed Jul 16, 2023
2 parents b14e0ac + 14fef62 commit dd84e71
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 31 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -45,7 +45,7 @@
"phpstan/phpstan-phpunit": "^1.1",
"phpstan/phpstan-strict-rules": "^1.1",
"phpstan/phpstan-symfony": "^1.1",
"phpunit/phpunit": "^9.5.24",
"phpunit/phpunit": "^10.2",
"symfony/cache": "^4.4 || ^5.4 || ^6.0",
"symfony/process": "^4.4 || ^5.4 || ^6.0",
"symfony/yaml": "^4.4 || ^5.4 || ^6.0"
Expand Down
1 change: 0 additions & 1 deletion phpcs.xml.dist
Expand Up @@ -44,7 +44,6 @@

<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming">
<exclude-pattern>lib/Doctrine/Migrations/AbstractMigration.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Migrations/Tests/Configuration/Loader/AbstractLoaderTest.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/Migrations/Configuration/Loader/AbstractFileLoader.php</exclude-pattern>
</rule>

Expand Down
5 changes: 2 additions & 3 deletions phpunit.xml.dist
Expand Up @@ -3,7 +3,6 @@
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
verbose="true"
beStrictAboutOutputDuringTests="true"
>
<php>
Expand All @@ -16,9 +15,9 @@
</testsuite>
</testsuites>

<coverage>
<source>
<include>
<directory>./lib/</directory>
</include>
</coverage>
</source>
</phpunit>
Expand Up @@ -8,7 +8,7 @@
use Doctrine\Migrations\Configuration\Migration\Exception\JsonNotValid;
use Doctrine\Migrations\Configuration\Migration\JsonFile;

class JsonLoaderTest extends LoaderTest
class JsonLoaderTest extends LoaderTestCase
{
public function load(string $prefix = ''): Configuration
{
Expand Down
Expand Up @@ -15,7 +15,7 @@

use const DIRECTORY_SEPARATOR;

abstract class LoaderTest extends TestCase
abstract class LoaderTestCase extends TestCase
{
abstract public function load(string $prefix = ''): Configuration;

Expand Down
Expand Up @@ -7,7 +7,7 @@
use Doctrine\Migrations\Configuration\Configuration;
use Doctrine\Migrations\Configuration\Migration\PhpFile;

class PhpLoaderTest extends LoaderTest
class PhpLoaderTest extends LoaderTestCase
{
public function load(string $prefix = ''): Configuration
{
Expand Down
Expand Up @@ -8,7 +8,7 @@
use Doctrine\Migrations\Configuration\Migration\Exception\XmlNotValid;
use Doctrine\Migrations\Configuration\Migration\XmlFile;

class XmlLoaderTest extends LoaderTest
class XmlLoaderTest extends LoaderTestCase
{
public function load(string $prefix = ''): Configuration
{
Expand Down
Expand Up @@ -8,7 +8,7 @@
use Doctrine\Migrations\Configuration\Migration\Exception\YamlNotValid;
use Doctrine\Migrations\Configuration\Migration\YamlFile;

class YamlLoaderTest extends LoaderTest
class YamlLoaderTest extends LoaderTestCase
{
public function load(string $prefix = ''): Configuration
{
Expand Down
Expand Up @@ -80,7 +80,7 @@ public function testWriteSql(bool $dryRun, $arg, ?string $path): void
}

/** @return mixed[] */
public function getWriteSqlValues(): array
public static function getWriteSqlValues(): array
{
return [
// dry-run, write-path, path
Expand Down
Expand Up @@ -76,7 +76,7 @@ public function testTargetUnknownVersion(): void
}

/** @return array<array<int, bool|int>> */
public function getMigrateWithMigrationsOrWithout(): array
public static function getMigrateWithMigrationsOrWithout(): array
{
return [
// migrations available, allow-no-migrations, expected exit code
Expand Down Expand Up @@ -120,7 +120,7 @@ public function testMigrateWhenNoMigrationsAvailable(bool $hasMigrations, bool $
}

/** @return array<array<bool|string|null>> */
public function getTargetAliases(): array
public static function getTargetAliases(): array
{
return [
['A', 'OK', 'A'], // already at A
Expand Down Expand Up @@ -250,7 +250,7 @@ public function testExecuteWriteSql(bool $dryRun, $arg, ?string $path): void
}

/** @return mixed[] */
public function getWriteSqlValues(): array
public static function getWriteSqlValues(): array
{
return [
// dry-run, write-path, path
Expand Down Expand Up @@ -381,7 +381,7 @@ public function testExecuteMigrateAllOrNothing(bool $default, array $input, bool
}

/** @psalm-return Generator<array{bool, array<string, bool|int|string|null>, bool}> */
public function allOrNothing(): Generator
public static function allOrNothing(): Generator
{
yield [false, ['--all-or-nothing' => false], false];
yield [false, ['--all-or-nothing' => 0], false];
Expand Down
Expand Up @@ -134,7 +134,7 @@ public function testMigrationList(): void
}

/** @return mixed[][] */
public function dataIsUpToDate(): array
public static function dataIsUpToDate(): array
{
return [
'up-to-date' => [
Expand Down
Expand Up @@ -103,7 +103,7 @@ public function testNoDependencyFactoryWhenNoCliConfig(): void
}

/** @return array<int,array<string>> */
public function getDependencyFactoryTestDirectories(): array
public static function getDependencyFactoryTestDirectories(): array
{
return [
[__DIR__],
Expand Down
4 changes: 2 additions & 2 deletions tests/Doctrine/Migrations/Tests/Version/AliasResolverTest.php
Expand Up @@ -97,7 +97,7 @@ public function testAliasesWithNoExecuted(string $alias, ?string $expectedVersio
}

/** @return mixed[][] */
public function getAliasesWithNoExecuted(): array
public static function getAliasesWithNoExecuted(): array
{
return [
['first', '0'],
Expand All @@ -113,7 +113,7 @@ public function getAliasesWithNoExecuted(): array
}

/** @return mixed[][] */
public function getAliases(): array
public static function getAliases(): array
{
return [
['first', '0'],
Expand Down
17 changes: 8 additions & 9 deletions tests/Doctrine/Migrations/Tests/Version/ExecutorTest.php
Expand Up @@ -504,15 +504,8 @@ public function executeDownShouldAppendDescriptionWhenItIsNotEmpty(): void

protected function setUp(): void
{
// add getSql to mock until method will be added to MetadataStorage interface
$this->metadataStorage = $this->getMockBuilder(MetadataStorage::class)
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->disallowMockingUnknownTypes()
->onlyMethods(['ensureInitialized', 'getExecutedMigrations', 'complete', 'reset'])
->addMethods(['getSql'])
->getMock();
// use FutureMetadataStorage until getSql is added to MetadataStorage interface
$this->metadataStorage = $this->createMock(FutureMetadataStorage::class);

$this->connection = $this->createMock(Connection::class);
$driverConnection = $this->createStub(DriverConnection::class);
Expand Down Expand Up @@ -563,3 +556,9 @@ protected function setUp(): void
->willReturn([$stopWatchPeriod]);
}
}

interface FutureMetadataStorage extends MetadataStorage
{
/** @return iterable<Query> */
public function getSql(ExecutionResult $result): iterable;
}
Expand Up @@ -138,7 +138,7 @@ public function testPlanWhenNoMigrations(string $to, array $expectedPlan, string
}

/** @return mixed[] */
public function getPlanUpWhenNoMigrations(): array
public static function getPlanUpWhenNoMigrations(): array
{
return [
['A', ['A'], Direction::UP],
Expand Down Expand Up @@ -182,7 +182,7 @@ public function testTargetMigrationNotFound(): void
}

/** @return mixed[] */
public function getPlanUpWhenMigrations(): array
public static function getPlanUpWhenMigrations(): array
{
return [
['0', ['B', 'A'], Direction::DOWN],
Expand Down Expand Up @@ -220,7 +220,7 @@ public function testPlanWhenMigrationsOutOfOrder(string $to, array $expectedPlan
}

/** @return mixed[] */
public function getPlanUpWhenMigrationsOutOfOrder(): array
public static function getPlanUpWhenMigrationsOutOfOrder(): array
{
return [
['C',['A'],Direction::UP],
Expand Down

0 comments on commit dd84e71

Please sign in to comment.