1

明確にできるように順序を設定したいと思います: テストモードをキャッシュしてから、データベースを削除し、スキーマを削除し、スキームを追加し、テストモードでフィクスチャを追加します。

class BaseCommand extends \Symfony\Component\Console\Command\Command {

//put your code here

protected function configure()
{
    $this
            ->setName('mycommand:test')
            ->setDescription('Launch test')
    ;

}

protected function execute(InputInterface $input, OutputInterface $output)
{
    $command_first_migration = $this->getApplication()->find('cache:clear');
    $arguments_first_migration = array(
        'command' => 'cache:clean',
        '--env' => 'test'
    );
    $input_first_migration = new ArrayInput($arguments_first_migration);
    try {

        $returnCode = $command_first_migration->run($input_first_migration, $output);


    } catch (\Doctrine\DBAL\Migrations\MigrationException $ex) {
        echo "MigrationExcepion !!!! ";
    }
}

}

しかし、私はこの結果を持っています:

clearing the case for the dev environment with debug true

開発環境でテストに合格するには?

ありがとうございました

4

1 に答える 1

3

php app/console mycommand:test を実行すると、カーネルと環境が既に作成されているため、 --env=test を設定することはできません。

唯一の方法は、コマンドを実行するときに env を指定することです。

php app/console mycommand:test --env=test
于 2013-07-22T09:19:17.670 に答える