public function testExecuteWithSQL()
 {
     $this->createPrimary();
     $application = new Application();
     $application->add(new Command());
     // We mock the DialogHelper
     $command = $application->find('run');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--db' => getenv('DB_NAME'), '--user' => getenv('DB_USER'), '--host' => getenv('DB_HOST'), '--password' => getenv('DB_PASSWORD'), '--config' => __DIR__ . '/_files/config.right.yaml', '--sql' => null));
     $this->assertRegExp('|Anonymizing guestbook.*|', $commandTester->getDisplay());
     $this->assertRegExp('|.*UPDATE guestbook SET.*|', $commandTester->getDisplay());
 }
 public function testExecuteProtectId()
 {
     $this->createPrimary();
     $application = new Application();
     $application->add(new Command());
     // We mock the DialogHelper
     $command = $application->find('config:generate');
     $helper = $this->getMock('\\Symfony\\Component\\Console\\Helper\\QuestionHelper', array('ask'));
     $helper->expects($this->any())->method('ask')->willReturn(getenv('DB_PASSWORD'));
     $command->getHelperSet()->set($helper, 'question');
     $temp = tempnam(sys_get_temp_dir(), 'phpunit');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--host' => getenv('DB_HOST'), '--db' => getenv('DB_NAME'), '--user' => getenv('DB_USER'), '--file' => $temp, '--protect' => null));
     $this->assertRegExp('|Configuration written to.*|', $commandTester->getDisplay());
     $this->assertFileExists($temp);
     // try to read the file with the reader
     $reader = new Reader($temp);
     $values = $reader->getConfigValues();
     $this->assertInternalType('array', $values);
     $this->assertArrayHasKey('entities', $values);
     $this->assertArrayHasKey('guestbook', $values['entities']);
     $this->assertArrayHasKey('cols', $values['entities']['guestbook']);
     $this->assertArrayHasKey('user', $values['entities']['guestbook']['cols']);
     $this->assertArrayNotHasKey('id', $values['entities']['guestbook']['cols']);
     // remove the file
     unlink($temp);
 }