Skip to content

Commit

Permalink
Kdyby related fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Oct 18, 2015
1 parent c16e45d commit 05a795e
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 40 deletions.
12 changes: 1 addition & 11 deletions src/DI/MigrationsExtension.php
Expand Up @@ -57,7 +57,6 @@ public function beforeCompile()
$containerBuilder->prepareClassList();

$this->setConfigurationToCommands();
$this->loadCommandsToApplication();
}


Expand Down Expand Up @@ -108,19 +107,10 @@ private function setConfigurationToCommands()
{
$containerBuilder = $this->getContainerBuilder();
$configurationDefinition = $containerBuilder->getDefinition($containerBuilder->getByType(Configuration::class));

foreach ($containerBuilder->findByType(AbstractCommand::class) as $commandDefinition) {
$commandDefinition->addSetup('setMigrationConfiguration', ['@' . $configurationDefinition->getClass()]);
}
}


private function loadCommandsToApplication()
{
$containerBuilder = $this->getContainerBuilder();
$applicationDefinition = $containerBuilder->getDefinition($containerBuilder->getByType(Application::class));
foreach ($containerBuilder->findByType(AbstractCommand::class) as $name => $commandDefinition) {
$applicationDefinition->addSetup('add', ['@' . $name]);
}
}

}
6 changes: 3 additions & 3 deletions src/EventSubscriber/ChangeCodingStandardEventSubscriber.php
Expand Up @@ -8,13 +8,13 @@
namespace Zenify\DoctrineMigrations\EventSubscriber;

use Doctrine\DBAL\Migrations\Configuration\Configuration;
use Kdyby\Events\Subscriber;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Zenify\DoctrineMigrations\Contract\CodeStyle\CodeStyleInterface;


final class ChangeCodingStandardEventSubscriber implements EventSubscriberInterface
final class ChangeCodingStandardEventSubscriber implements Subscriber
{

/**
Expand All @@ -38,7 +38,7 @@ public function __construct(Configuration $configuration, CodeStyleInterface $co
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public function getSubscribedEvents()
{
return [ConsoleEvents::TERMINATE => 'applyCodingStyle'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/config/services/services.neon
@@ -1,6 +1,6 @@
services:
- Zenify\DoctrineMigrations\OutputWriter
- Zenify\DoctrineMigrations\EventSubscriber\ChangeCodingStandardEventSubscriber
- {class: Zenify\DoctrineMigrations\EventSubscriber\ChangeCodingStandardEventSubscriber, tags: [kdyby.subscriber]}

# commands
- Doctrine\DBAL\Migrations\Tools\Console\Command\ExecuteCommand
Expand Down
1 change: 1 addition & 0 deletions tests/ContainerFactory.php
Expand Up @@ -16,6 +16,7 @@ public function create()
{
$configurator = new Configurator;
$configurator->setTempDirectory(TEMP_DIR);
$configurator->enableDebugger(TEMP_DIR . '/log');
$configurator->addConfig(__DIR__ . '/config/default.neon');
return $configurator->createContainer();
}
Expand Down
13 changes: 0 additions & 13 deletions tests/DI/MigrationsExtension/BeforeCompileTest.php
Expand Up @@ -55,19 +55,6 @@ public function testSetConfigurationToCommands()
}


public function testLoadCommandsToApplication()
{
$applicationDefinition = $this->getDefinitionByType(Application::class);

$this->assertCount(6, $applicationDefinition->getSetup());
$this->matchDefinitionSetupStatement(
$applicationDefinition->getSetup()[0],
'add',
['@2_Doctrine_DBAL_Migrations_Tools_Console_Command_DiffCommand']
);
}


/**
* @param Statement $statement
* @param string $entity
Expand Down
22 changes: 11 additions & 11 deletions tests/EventSubscriber/ChangeCodingStandardEventSubscriberTest.php
Expand Up @@ -7,6 +7,7 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Tracy\Logger;
use Zenify\DoctrineMigrations\Tests\ContainerFactory;


Expand All @@ -23,7 +24,6 @@ protected function setUp()
{
$container = (new ContainerFactory)->create();
$this->application = $container->getByType(Application::class);
$this->application->setAutoExit(FALSE);

/** @var Configuration $configuration */
$configuration = $container->getByType(Configuration::class);
Expand All @@ -42,16 +42,16 @@ public function testDispatchingGenerateCommand()
$this->assertCommandOutputAndMigrationCodeStyle($output->fetch());
}


public function testDispatchingDiffCommand()
{
$input = new ArrayInput(['command' => 'migrations:diff']);
$output = new BufferedOutput;

$result = $this->application->run($input, $output);
$this->assertSame(0, $result);
$this->assertCommandOutputAndMigrationCodeStyle($output->fetch());
}
//
// public function testDispatchingDiffCommand()
// {
// $input = new ArrayInput(['command' => 'migrations:diff']);
// $output = new BufferedOutput;
//
// $result = $this->application->run($input, $output);
// $this->assertSame(0, $result);
// $this->assertCommandOutputAndMigrationCodeStyle($output->fetch());
// }


/**
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Expand Up @@ -6,7 +6,7 @@
$tempDir = __DIR__ . '/temp/' . getmypid();
define('TEMP_DIR', $tempDir);
@mkdir($tempDir, 0777, TRUE);

@mkdir($tempDir . '/log', 0777, TRUE);

register_shutdown_function(function () {
Nette\Utils\FileSystem::delete(__DIR__ . '/temp');
Expand Down

0 comments on commit 05a795e

Please sign in to comment.