Skip to content

Commit a9e5063

Browse files
authored
Merge pull request #213 from ruudvanderweijde/master
Add method_exists to avoid fatal error Fixes #207 Fixes #217
2 parents f10dda4 + a74cd8e commit a9e5063

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

Command/DoctrineCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static function configureMigrations(ContainerInterface $container, Config
5656
$configuration->registerMigrationsFromDirectory($configuration->getMigrationsDirectory());
5757
}
5858

59-
if (!$configuration->getCustomTemplate()) {
59+
if (method_exists($configuration, 'getCustomTemplate') && !$configuration->getCustomTemplate()) {
6060
$configuration->setCustomTemplate($container->getParameter('doctrine_migrations.custom_template'));
6161
}
6262

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Doctrine\Bundle\MigrationsBundle\Tests\DependencyInjection;
4+
5+
use Doctrine\Bundle\MigrationsBundle\Command\DoctrineCommand;
6+
use Doctrine\DBAL\Migrations\Configuration\Configuration;
7+
use Symfony\Component\DependencyInjection\ContainerBuilder;
8+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
9+
10+
class DoctrineCommandTest extends \PHPUnit\Framework\TestCase
11+
{
12+
public function testConfigureMigrations()
13+
{
14+
$configurationMock = $this->getMockBuilder('Doctrine\DBAL\Migrations\Configuration\Configuration')
15+
->disableOriginalConstructor()
16+
->getMock();
17+
18+
$configurationMock->method('getMigrations')
19+
->willReturn(array());
20+
21+
DoctrineCommand::configureMigrations($this->getContainer(), $configurationMock);
22+
}
23+
24+
private function getContainer()
25+
{
26+
return new ContainerBuilder(new ParameterBag(array(
27+
'doctrine_migrations.dir_name' => __DIR__.'/../../',
28+
'doctrine_migrations.namespace' => 'test',
29+
'doctrine_migrations.name' => 'test',
30+
'doctrine_migrations.table_name' => 'test',
31+
'doctrine_migrations.organize_migrations' => Configuration::VERSIONS_ORGANIZATION_BY_YEAR,
32+
)));
33+
}
34+
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"doctrine/migrations": "^1.1"
2727
},
2828
"require-dev": {
29-
"phpunit/phpunit": "~4.8"
29+
"phpunit/phpunit": "^4.8.36"
3030
},
3131
"autoload": {
3232
"psr-4": { "Doctrine\\Bundle\\MigrationsBundle\\": "" }

0 commit comments

Comments
 (0)