Skip to content

Commit

Permalink
Stop using doctrine:schema:validate due to incompatibilities with doc…
Browse files Browse the repository at this point in the history
…trine:migrations

See doctrine/migrations#1406
  • Loading branch information
pierres committed Oct 28, 2024
1 parent 59fa326 commit f94eba3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
29 changes: 20 additions & 9 deletions MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class MigrationsTest extends WebTestCase

/**
* @param class-string $className
*
* @psalm-param class-string<T> $className
* @psalm-return ObjectRepository<T>
* @template T of object
* @return ObjectRepository<T>
*/
protected static function getRepository(string $className): ObjectRepository
{
Expand Down Expand Up @@ -60,7 +65,7 @@ protected static function dropDatabase(): void
'command' => 'doctrine:database:drop',
'--force' => true,
'--if-exists' => true,
'--quiet' => true
'--quiet' => true,
]));
}

Expand All @@ -80,7 +85,9 @@ protected static function runCommand(ArrayInput $input): void
protected static function createDatabase(): void
{
static::runCommand(new ArrayInput([
'command' => 'doctrine:database:create'
'command' => 'doctrine:database:create',
'--if-not-exists' => true,
'--quiet' => true,
]));
}

Expand All @@ -104,7 +111,9 @@ private function migrateDatabase(string $version): void
private function validateDatabase(): void
{
$this->runCommand(new ArrayInput([
'command' => 'doctrine:schema:validate'
'command' => 'doctrine:migrations:diff',
'--allow-empty-diff' => true,
'--quiet' => true,
]));
}

Expand All @@ -124,7 +133,7 @@ protected static function createDatabaseSchema(): void
{
static::runCommand(new ArrayInput([
'command' => 'doctrine:schema:create',
'--quiet' => true
'--quiet' => true,
]));
}

Expand Down Expand Up @@ -170,7 +179,10 @@ private static function shutdownKernel(): void
}
}

public static function provideAvailableVersions(): array
/**
* @return iterable<string[]>
*/
public static function provideAvailableVersions(): iterable
{
if (is_dir(__DIR__ . '/../../../migrations')) {
$files = glob(__DIR__ . '/../../../migrations/*.php');
Expand All @@ -179,13 +191,12 @@ public static function provideAvailableVersions(): array
}
static::assertIsArray($files);
asort($files);
$versions = [];

foreach ($files as $file) {
$versions[] = [preg_replace('#^/.+/([^/]+)\.php$#', 'DoctrineMigrations\\\$1', $file)];
$version = preg_replace('#^/.+/([^/]+)\.php$#', 'DoctrineMigrations\\\$1', $file);
static::assertIsString($version);
yield [$version];
}

return $versions;
}

protected function tearDown(): void
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ parameters:
- .
excludePaths:
- vendor
checkGenericClassInNonGenericObjectType: false
checkMissingIterableValueType: false

0 comments on commit f94eba3

Please sign in to comment.