diff --git a/Tests/Command/DoctrineCommandTest.php b/Tests/Command/DoctrineCommandTest.php index 3400243..6ffceb3 100644 --- a/Tests/Command/DoctrineCommandTest.php +++ b/Tests/Command/DoctrineCommandTest.php @@ -4,6 +4,7 @@ use Doctrine\Bundle\MigrationsBundle\Command\DoctrineCommand; use Doctrine\DBAL\Migrations\Configuration\Configuration; +use ReflectionClass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; @@ -18,17 +19,41 @@ public function testConfigureMigrations() $configurationMock->method('getMigrations') ->willReturn(array()); + $reflectionClass = new ReflectionClass('Doctrine\DBAL\Migrations\Configuration\Configuration'); + if ($reflectionClass->hasMethod('getCustomTemplate')) { + $configurationMock + ->expects($this->once()) + ->method('setCustomTemplate') + ->with('migrations.tpl'); + } + + $configurationMock + ->expects($this->once()) + ->method('setMigrationsTableName') + ->with('migrations'); + + $configurationMock + ->expects($this->once()) + ->method('setMigrationsNamespace') + ->with('App\Migrations'); + + $configurationMock + ->expects($this->once()) + ->method('setMigrationsDirectory') + ->with(__DIR__ . '/../../'); + DoctrineCommand::configureMigrations($this->getContainer(), $configurationMock); } private function getContainer() { return new ContainerBuilder(new ParameterBag(array( - 'doctrine_migrations.dir_name' => __DIR__.'/../../', - 'doctrine_migrations.namespace' => 'test', - 'doctrine_migrations.name' => 'test', - 'doctrine_migrations.table_name' => 'test', + 'doctrine_migrations.dir_name' => __DIR__ . '/../../', + 'doctrine_migrations.namespace' => 'App\\Migrations', + 'doctrine_migrations.name' => 'App migrations', + 'doctrine_migrations.table_name' => 'migrations', 'doctrine_migrations.organize_migrations' => Configuration::VERSIONS_ORGANIZATION_BY_YEAR, + 'doctrine_migrations.custom_template' => 'migrations.tpl', ))); } } diff --git a/Tests/DependencyInjection/DoctrineMigrationsExtensionTest.php b/Tests/DependencyInjection/DoctrineMigrationsExtensionTest.php index f6f2660..6afa74a 100644 --- a/Tests/DependencyInjection/DoctrineMigrationsExtensionTest.php +++ b/Tests/DependencyInjection/DoctrineMigrationsExtensionTest.php @@ -4,10 +4,11 @@ use Doctrine\Bundle\MigrationsBundle\DependencyInjection\DoctrineMigrationsExtension; use Doctrine\DBAL\Migrations\Configuration\Configuration; +use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; -class DoctrineMigrationsExtensionTest extends \PHPUnit_Framework_TestCase +class DoctrineMigrationsExtensionTest extends TestCase { public function testOrganizeMigrations() { diff --git a/composer.json b/composer.json index 713cda3..ca253f6 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "doctrine/migrations": "^1.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.36" + "phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^7.4" }, "autoload": { "psr-4": { "Doctrine\\Bundle\\MigrationsBundle\\": "" }