[DoctrineBundle] fixed CS

This commit is contained in:
Fabien Potencier 2011-05-01 10:39:54 +02:00
parent 74a243bdd6
commit 6edb6447c8
6 changed files with 20 additions and 23 deletions

View File

@ -56,7 +56,7 @@ EOT
$params = $connection->getParams(); $params = $connection->getParams();
$name = isset($params['path'])?$params['path']:(isset($params['dbname'])?$params['dbname']:false); $name = isset($params['path']) ? $params['path'] : (isset($params['dbname']) ? $params['dbname'] : false);
if (!$name) { if (!$name) {
throw new \InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped."); throw new \InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.");
@ -71,7 +71,8 @@ EOT
$output->writeln(sprintf('<error>%s</error>', $e->getMessage())); $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
} }
} else { } else {
$output->writeln('<error>ATTENTION:</error> This operation should not be executed in a production environment.' . PHP_EOL); $output->writeln('<error>ATTENTION:</error> This operation should not be executed in a production environment.');
$output->writeln('');
$output->writeln(sprintf('<info>Would drop the database named <comment>%s</comment>.</info>', $name)); $output->writeln(sprintf('<info>Would drop the database named <comment>%s</comment>.</info>', $name));
$output->writeln('Please run the operation with --force to execute'); $output->writeln('Please run the operation with --force to execute');
$output->writeln('<error>All data will be lost!</error>'); $output->writeln('<error>All data will be lost!</error>');

View File

@ -65,16 +65,14 @@ EOT
} }
if (strpos($metadata->name, $foundBundle->getNamespace()) === false) { if (strpos($metadata->name, $foundBundle->getNamespace()) === false) {
throw new \RuntimeException( throw new \RuntimeException(sprintf('Entity "%s" and bundle don\'t have a common namespace, generation failed because the target directory cannot be detected.', $metadata->name));
"Entity " . $metadata->name . " and bundle don't have a common namespace, ".
"generation failed because the target directory cannot be detected.");
} }
$output->writeln(sprintf(' > generating <comment>%s</comment>', $metadata->name)); $output->writeln(sprintf(' > generating <comment>%s</comment>', $metadata->name));
$entityGenerator->generate(array($metadata), $this->findBasePathForBundle($foundBundle)); $entityGenerator->generate(array($metadata), $this->findBasePathForBundle($foundBundle));
} }
} else { } else {
throw new \RuntimeException("Bundle " . $bundleName . " does not contain any mapped entities."); throw new \RuntimeException(sprintf('Bundle "%s" does not contain any mapped entities.', $bundleName));
} }
} }
} }

View File

@ -59,9 +59,7 @@ EOT
if ($metadata->customRepositoryClassName) { if ($metadata->customRepositoryClassName) {
if (strpos($metadata->customRepositoryClassName, $foundBundle->getNamespace()) === false) { if (strpos($metadata->customRepositoryClassName, $foundBundle->getNamespace()) === false) {
throw new \RuntimeException( throw new \RuntimeException(sprintf('Repository "%s" and bundle don\'t have a common namespace, generation failed because the target directory cannot be detected.', $metadata->customRepositoryClassName));
"Repository " . $metadata->customRepositoryClassName . " and bundle don't have a common namespace, ".
"generation failed because the target directory cannot be detected.");
} }
$output->writeln(sprintf(' > <info>OK</info> generating <comment>%s</comment>', $metadata->customRepositoryClassName)); $output->writeln(sprintf(' > <info>OK</info> generating <comment>%s</comment>', $metadata->customRepositoryClassName));
@ -71,7 +69,7 @@ EOT
} }
} }
} else { } else {
throw new \RuntimeException("Bundle " . $bundleName . " does not contain any mapped entities."); throw new \RuntimeException(sprintf('Bundle "%s" does not contain any mapped entities.', $bundleName));
} }
} }
} }

View File

@ -103,7 +103,8 @@ EOT
file_put_contents($path, $code); file_put_contents($path, $code);
} }
} else { } else {
$output->writeln('Database does not have any mapping information.'.PHP_EOL, 'ERROR'); $output->writeln('Database does not have any mapping information.', 'ERROR');
$output->writeln('', 'ERROR');
} }
} }
} }

View File

@ -64,17 +64,16 @@ EOT
); );
} }
$output->write(sprintf("Found <info>%d</info> entities mapped in entity manager <info>%s</info>:\n", $output->writeln(sprintf("Found <info>%d</info> entities mapped in entity manager <info>%s</info>:", count($entityClassNames), $entityManagerName));
count($entityClassNames), $entityManagerName), true);
foreach ($entityClassNames as $entityClassName) { foreach ($entityClassNames as $entityClassName) {
try { try {
$cm = $entityManager->getClassMetadata($entityClassName); $cm = $entityManager->getClassMetadata($entityClassName);
$output->write("<info>[OK]</info> " . $entityClassName, true); $output->writeln(sprintf("<info>[OK]</info> %s", $entityClassName));
} catch (MappingException $e) { } catch (MappingException $e) {
$output->write("<error>[FAIL]</error> " . $entityClassName, true); $output->writeln("<error>[FAIL]</error> ".$entityClassName);
$output->write("<comment>" . $e->getMessage()."</comment>", true); $output->writeln(sprintf("<comment>%s</comment>", $e->getMessage()));
$output->write("", true); $output->writeln('');
} }
} }
} }

View File

@ -16,11 +16,11 @@ class InfoDoctrineCommandTest extends TestCase
$input = new StringInput("doctrine:mapping:info"); $input = new StringInput("doctrine:mapping:info");
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$output->expects($this->at(0)) $output->expects($this->at(0))
->method('write') ->method('writeln')
->with($this->equalTo("Found <info>1</info> entities mapped in entity manager <info>default</info>:\n"), $this->equalTo(true)); ->with($this->equalTo("Found <info>1</info> entities mapped in entity manager <info>default</info>:"));
$output->expects($this->at(1)) $output->expects($this->at(1))
->method('write') ->method('writeln')
->with($this->equalTo("<info>[OK]</info> Fixtures\Bundles\YamlBundle\Entity\Test"), $this->equalTo(true)); ->with($this->equalTo("<info>[OK]</info> Fixtures\Bundles\YamlBundle\Entity\Test"));
$testContainer = $this->createYamlBundleTestContainer(); $testContainer = $this->createYamlBundleTestContainer();
$kernel = $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false); $kernel = $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false);
@ -36,4 +36,4 @@ class InfoDoctrineCommandTest extends TestCase
$cmd->setApplication($application); $cmd->setApplication($application);
$cmd->run($input, $output); $cmd->run($input, $output);
} }
} }