Skip to content

Commit

Permalink
ensure there is always some metadata configuration set
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Nov 30, 2019
1 parent 4626cbd commit 5a09688
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Doctrine/Migrations/Configuration/Loader/ArrayLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ public function load($array) : Configuration
$object = new Configuration();
self::applyConfigs($configMap, $object, $array);

if ($object->getMetadataStorageConfiguration() === null) {
$object->setMetadataStorageConfiguration(new TableMetadataStorageConfiguration());
}

return $object;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ public function testLoad() : void
self::assertSame('doctrine_migration_executed_at_column_test', $storage->getExecutedAtColumnName());
}

public function testLoadBasic() : void
{
$config = $this->load('basic');

self::assertNull($config->getName());
self::assertSame(['DoctrineMigrationsTest' => dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files'], $config->getMigrationDirectories());

self::assertSame([], $config->getMigrationClasses());

$storage = $config->getMetadataStorageConfiguration();
self::assertInstanceOf(TableMetadataStorageConfiguration::class, $storage);

self::assertSame('doctrine_migration_versions', $storage->getTableName());
self::assertSame('version', $storage->getVersionColumnName());
self::assertSame(1024, $storage->getVersionColumnLength());
self::assertSame('execution_time', $storage->getExecutionTimeColumnName());
self::assertSame('executed_at', $storage->getExecutedAtColumnName());
}

public function testConfigurationFileNotExists() : void
{
$this->expectException(InvalidArgumentException::class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"migrations_paths" : {
"DoctrineMigrationsTest": "."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

declare(strict_types=1);

return [
'migrations_paths' => ['DoctrineMigrationsTest' => '.'],
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-migrations xmlns="http://doctrine-project.org/schemas/migrations/configuration/3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/migrations/configuration/3.0
http://doctrine-project.org/schemas/migrations/configuration/3.0.xsd">
<migrations-paths>
<path namespace="DoctrineMigrationsTest">.</path>
</migrations-paths>

</doctrine-migrations>


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
migrations_paths:
DoctrineMigrationsTest: .


0 comments on commit 5a09688

Please sign in to comment.