From 5d76dd622a11923c8fa5a0afbe86e4bd3702a43a Mon Sep 17 00:00:00 2001 From: Ruud van der Weijde Date: Tue, 31 Oct 2017 09:26:51 +0100 Subject: [PATCH 1/2] Add method_exists to avoid fatal error Related error: ``` [Symfony\Component\Debug\Exception\UndefinedMethodException] Attempted to call an undefined method named "getCustomTemplate" of class "Doctrine\DBAL\Migrations\Configuration\Configuration". ``` This commit can be reverted when https://github.com/doctrine/migrations v1.6 is released. --- Command/DoctrineCommand.php | 2 +- Tests/Command/DoctrineCommandTest.php | 34 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Tests/Command/DoctrineCommandTest.php diff --git a/Command/DoctrineCommand.php b/Command/DoctrineCommand.php index a814d1d..1abea57 100644 --- a/Command/DoctrineCommand.php +++ b/Command/DoctrineCommand.php @@ -67,7 +67,7 @@ public static function configureMigrations(ContainerInterface $container, Config $configuration->registerMigrationsFromDirectory($configuration->getMigrationsDirectory()); } - if (!$configuration->getCustomTemplate()) { + if (method_exists($configuration, 'getCustomTemplate') && !$configuration->getCustomTemplate()) { $configuration->setCustomTemplate($container->getParameter('doctrine_migrations.custom_template')); } diff --git a/Tests/Command/DoctrineCommandTest.php b/Tests/Command/DoctrineCommandTest.php new file mode 100644 index 0000000..3400243 --- /dev/null +++ b/Tests/Command/DoctrineCommandTest.php @@ -0,0 +1,34 @@ +getMockBuilder('Doctrine\DBAL\Migrations\Configuration\Configuration') + ->disableOriginalConstructor() + ->getMock(); + + $configurationMock->method('getMigrations') + ->willReturn(array()); + + 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.organize_migrations' => Configuration::VERSIONS_ORGANIZATION_BY_YEAR, + ))); + } +} From a74cd8ea0b93c5bb3bedc187ba057762c04f7d7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Wed, 1 Nov 2017 10:03:00 +0100 Subject: [PATCH 2/2] Require PHPUnit 4.8.36 To ensure we have the forward compatibility layer (for PHPUnit 6+). --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ade136e..713cda3 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "doctrine/migrations": "^1.1" }, "require-dev": { - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "^4.8.36" }, "autoload": { "psr-4": { "Doctrine\\Bundle\\MigrationsBundle\\": "" }