コード例 #1
0
 public function testRunInstallCommandChooseNothing()
 {
     $application = new Application($this->getClient()->getKernel());
     $application->add(new InstallCommand());
     $application->add(new DropDatabaseDoctrineCommand());
     $application->add(new CreateDatabaseDoctrineCommand());
     // drop database first, so the install command won't ask to reset things
     $command = new DropDatabaseDoctrineCommand();
     $command->setApplication($application);
     $command->run(new ArrayInput(['command' => 'doctrine:database:drop', '--force' => true]), new NullOutput());
     $this->getClient()->getContainer()->get('doctrine')->getConnection()->close();
     $command = new CreateDatabaseDoctrineCommand();
     $command->setApplication($application);
     $command->run(new ArrayInput(['command' => 'doctrine:database:create', '--env' => 'test']), new NullOutput());
     $command = $application->find('wallabag:install');
     // We mock the QuestionHelper
     $question = $this->getMockBuilder('Symfony\\Component\\Console\\Helper\\QuestionHelper')->disableOriginalConstructor()->getMock();
     $question->expects($this->exactly(2))->method('ask')->will($this->onConsecutiveCalls(false, false));
     // We override the standard helper with our mock
     $command->getHelperSet()->set($question, 'question');
     $tester = new CommandTester($command);
     $tester->execute(['command' => $command->getName()]);
     $this->assertContains('Checking system requirements.', $tester->getDisplay());
     $this->assertContains('Setting up database.', $tester->getDisplay());
     $this->assertContains('Administration setup.', $tester->getDisplay());
     $this->assertContains('Config setup.', $tester->getDisplay());
     $this->assertContains('Creating schema', $tester->getDisplay());
 }