Skip to content

Commit

Permalink
Merge pull request #434 from mikeSimonson/fix-config-order
Browse files Browse the repository at this point in the history
Fixing an issue in the order at which some configuration key are loaded
  • Loading branch information
mikeSimonson committed Feb 17, 2016
2 parents 9b2b450 + 81a36ea commit 60ae914
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ abstract class AbstractFileConfiguration extends Configuration
* @var array of possible configuration properties in migrations configuration.
*/
private $configurationProperties = [
'name' => 'setName',
'table_name' => 'setMigrationsTableName',
'migrations_namespace' => 'setMigrationsNamespace',
'table_name' => 'setMigrationsTableName',
'organize_migrations' => 'setMigrationOrganisation',
'name' => 'setName','name' => 'setName',
'migrations_directory' => 'loadMigrationsFromDirectory',
'migrations' => 'loadMigrations',
];
Expand All @@ -65,7 +65,11 @@ protected function setConfiguration(Array $config)
$msg = sprintf('Migrations configuration key "%s" does not exists.', $configurationKey);
throw MigrationException::configurationNotValid($msg);
}
$this->{$this->configurationProperties[$configurationKey]}($configurationValue);
}
foreach($this->configurationProperties as $configurationKey => $configurationSetter) {
if (isset($config[$configurationKey])) {
$this->{$configurationSetter}($config[$configurationKey]);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,20 @@ public function testLoadMigrationsList()
$this->loadConfiguration('migrations_list');
$this->loadConfiguration('migrations_list2');
}

/**
* @dataProvider getConfigWithKeysInVariousOrder
*/
public function testThatTheOrderOfConfigKeysDoesNotMatter($file)
{
$this->loadConfiguration($file);
}

public function getConfigWithKeysInVariousOrder()
{
return [
['order_1'],
['order_2'],
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name" : "Doctrine Sandbox Migrations",
"migrations_namespace": "DoctrineMigrationsTest",
"table_name" : "doctrine_migration_versions_test",
"migrations_directory": ".",
"migrations" : []
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
return array(
'name' => 'Doctrine Sandbox Migrations',
'migrations_namespace' => 'DoctrineMigrationsTest',
'table_name' => 'doctrine_migration_versions_test',
'migrations_directory' => '.',
'migrations' => array()
);
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/migrations/configuration
http://doctrine-project.org/schemas/migrations/configuration.xsd">

<name>Doctrine Sandbox Migrations</name>
<migrations-namespace>DoctrineMigrationsTest</migrations-namespace>
<table name="doctrine_migration_versions_test" />
<migrations-directory>.</migrations-directory>

</doctrine-migrations>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: Doctrine Sandbox Migrations
migrations_namespace: DoctrineMigrationsTest
table_name: doctrine_migration_versions_test
migrations_directory: .
migrations:
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name" : "Doctrine Sandbox Migrations",
"migrations_directory": ".",
"migrations_namespace": "DoctrineMigrationsTest",
"table_name" : "doctrine_migration_versions_test",
"migrations" : []
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
return array(
'name' => 'Doctrine Sandbox Migrations',
'migrations_directory' => '.',
'migrations_namespace' => 'DoctrineMigrationsTest',
'table_name' => 'doctrine_migration_versions_test',
'migrations' => array()
);
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/migrations/configuration
http://doctrine-project.org/schemas/migrations/configuration.xsd">

<name>Doctrine Sandbox Migrations</name>
<migrations-directory>.</migrations-directory>
<migrations-namespace>DoctrineMigrationsTest</migrations-namespace>
<table name="doctrine_migration_versions_test" />

</doctrine-migrations>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: Doctrine Sandbox Migrations
migrations_directory: .
migrations_namespace: DoctrineMigrationsTest
table_name: doctrine_migration_versions_test
migrations:

0 comments on commit 60ae914

Please sign in to comment.