I am in the test files, and I want to launch some symfony commands namely a database followed by a drop followed by a create i create schema:
public function runCommand(Client $client, $command)
{
$application = new Application($client->getKernel());
$application->setAutoExit(false);
$fp = tmpfile();
$input = new StringInput($command);
$output = new StreamOutput($fp);
$application->run($input, $output);
fseek($fp, 0);
$output = '';
while (!feof($fp)) {
$output = fread($fp, 4096);
}
fclose($fp);
return $output;
}
public function cleanDataBaseTest() {
$client = self::createClient();
$command_drop_database = $this->runCommand($client, 'doctrine:database:drop --env=test --force');
$command_create_database = $this->runCommand($client, 'doctrine:database:create --env=test');
$command_create_schema = $this->runCommand($client, 'doctrine:schema:create --dump-sql');
echo $command_create_schema;
/*
ALTER TABLE.....
*/
}
or when I do a echo $ command_create_schema, I only alter table.
C6 FOREIGN KEY (akey) REFERENCES atable (id);
ALTER TABLE atablea ADD CONSTRAINT FK_646DFFB72576E0FD FOREIGN KEY (anid) REFERENCES ....
So if I'm doing command: php app / console doctrine: schema: create - dump-sql I get the create and alter table
Do you know why ?