Skip to content

Commit

Permalink
Fix build for PHP 7.x
Browse files Browse the repository at this point in the history
  • Loading branch information
alcaeus committed Dec 3, 2018
1 parent a9e5063 commit d6427af
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
33 changes: 29 additions & 4 deletions Tests/Command/DoctrineCommandTest.php
Expand Up @@ -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;

Expand All @@ -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',
)));
}
}
Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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\\": "" }
Expand Down

0 comments on commit d6427af

Please sign in to comment.