Skip to content

Commit

Permalink
Merge pull request #433 from rcatlin/fix/execute-command-registers
Browse files Browse the repository at this point in the history
Fix: ExecuteCommand
  • Loading branch information
mikeSimonson committed Feb 18, 2016
2 parents b31931f + e8b5f5d commit 62acf77
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Doctrine/DBAL/Migrations/Configuration/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,10 @@ public function getMigrations()
*/
public function getVersion($version)
{
if (empty($this->migrations)) {
$this->registerMigrationsFromDirectory($this->getMigrationsDirectory());
}

if (!isset($this->migrations[$version])) {
throw MigrationException::unknownMigrationVersion($version);
}
Expand Down
40 changes: 40 additions & 0 deletions tests/Doctrine/DBAL/Migrations/Tests/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Doctrine\DBAL\Migrations\Tests;

use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Doctrine\DBAL\Migrations\MigrationException;

class ConfigurationTest extends MigrationTestCase
{
Expand Down Expand Up @@ -190,6 +191,31 @@ public function testFormatVersion($version, $return)
$this->assertEquals($return, $config->formatVersion($version));
}

/**
* @dataProvider autoloadVersionProvider
*
* @param $version
*/
public function testGetVersion($version)
{
$config = $this->getSqliteConfiguration();
$config->setMigrationsNamespace('Doctrine\DBAL\Migrations\Tests\Stub\Configuration\AutoloadVersions');
$config->setMigrationsDirectory(__DIR__ . '/Stub/Configuration/AutoloadVersions');

$result = $config->getVersion($version);

$this->assertNotNull($result);
}

public function testGetVersionNotFound()
{
$this->setExpectedException(MigrationException::class);

$config = $this->getSqliteConfiguration();

$config->getVersion('foo');
}

/**
* @dataProvider versionProvider
*/
Expand All @@ -212,4 +238,18 @@ public function versionProvider()
['20150202162811', '2015-02-02 16:28:11']
];
}

/**
* @return array
*/
public function autoloadVersionProvider()
{
return [
['1Test'],
['2Test'],
['3Test'],
['4Test'],
['5Test'],
];
}
}

0 comments on commit 62acf77

Please sign in to comment.