Skip to content

Commit

Permalink
Merge pull request #213 from ruudvanderweijde/master
Browse files Browse the repository at this point in the history
Add method_exists to avoid fatal error

Fixes #207 
Fixes #217
  • Loading branch information
lcobucci committed Nov 1, 2017
2 parents f10dda4 + a74cd8e commit a9e5063
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Command/DoctrineCommand.php
Expand Up @@ -56,7 +56,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'));
}

Expand Down
34 changes: 34 additions & 0 deletions Tests/Command/DoctrineCommandTest.php
@@ -0,0 +1,34 @@
<?php

namespace Doctrine\Bundle\MigrationsBundle\Tests\DependencyInjection;

use Doctrine\Bundle\MigrationsBundle\Command\DoctrineCommand;
use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;

class DoctrineCommandTest extends \PHPUnit\Framework\TestCase
{
public function testConfigureMigrations()
{
$configurationMock = $this->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,
)));
}
}
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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\\": "" }
Expand Down

0 comments on commit a9e5063

Please sign in to comment.