Skip to content

Commit

Permalink
[DoctrineBundle] fixed CS
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 1, 2011
1 parent 74a243b commit 6edb644
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 23 deletions.
Expand Up @@ -56,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$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) {
throw new \InvalidArgumentException("Connection does not contain a 'path' or 'dbname' parameter and cannot be dropped.");
Expand All @@ -71,7 +71,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
}
} 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('Please run the operation with --force to execute');
$output->writeln('<error>All data will be lost!</error>');
Expand Down
Expand Up @@ -65,16 +65,14 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

if (strpos($metadata->name, $foundBundle->getNamespace()) === false) {
throw new \RuntimeException(
"Entity " . $metadata->name . " and bundle don't have a common namespace, ".
"generation failed because the target directory cannot be detected.");
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));
}

$output->writeln(sprintf(' > generating <comment>%s</comment>', $metadata->name));
$entityGenerator->generate(array($metadata), $this->findBasePathForBundle($foundBundle));
}
} 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));
}
}
}
}
Expand Up @@ -59,9 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

if ($metadata->customRepositoryClassName) {
if (strpos($metadata->customRepositoryClassName, $foundBundle->getNamespace()) === false) {
throw new \RuntimeException(
"Repository " . $metadata->customRepositoryClassName . " and bundle don't have a common namespace, ".
"generation failed because the target directory cannot be detected.");
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));
}

$output->writeln(sprintf(' > <info>OK</info> generating <comment>%s</comment>', $metadata->customRepositoryClassName));
Expand All @@ -71,7 +69,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
} 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));
}
}
}
Expand Up @@ -103,7 +103,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
file_put_contents($path, $code);
}
} 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');
}
}
}
Expand Up @@ -64,17 +64,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
);
}

$output->write(sprintf("Found <info>%d</info> entities mapped in entity manager <info>%s</info>:\n",
count($entityClassNames), $entityManagerName), true);
$output->writeln(sprintf("Found <info>%d</info> entities mapped in entity manager <info>%s</info>:", count($entityClassNames), $entityManagerName));

foreach ($entityClassNames as $entityClassName) {
try {
$cm = $entityManager->getClassMetadata($entityClassName);
$output->write("<info>[OK]</info> " . $entityClassName, true);
$output->writeln(sprintf("<info>[OK]</info> %s", $entityClassName));
} catch (MappingException $e) {
$output->write("<error>[FAIL]</error> " . $entityClassName, true);
$output->write("<comment>" . $e->getMessage()."</comment>", true);
$output->write("", true);
$output->writeln("<error>[FAIL]</error> ".$entityClassName);
$output->writeln(sprintf("<comment>%s</comment>", $e->getMessage()));
$output->writeln('');
}
}
}
Expand Down
Expand Up @@ -16,11 +16,11 @@ public function testAnnotationsBundle()
$input = new StringInput("doctrine:mapping:info");
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
$output->expects($this->at(0))
->method('write')
->with($this->equalTo("Found <info>1</info> entities mapped in entity manager <info>default</info>:\n"), $this->equalTo(true));
->method('writeln')
->with($this->equalTo("Found <info>1</info> entities mapped in entity manager <info>default</info>:"));
$output->expects($this->at(1))
->method('write')
->with($this->equalTo("<info>[OK]</info> Fixtures\Bundles\YamlBundle\Entity\Test"), $this->equalTo(true));
->method('writeln')
->with($this->equalTo("<info>[OK]</info> Fixtures\Bundles\YamlBundle\Entity\Test"));

$testContainer = $this->createYamlBundleTestContainer();
$kernel = $this->getMock('Symfony\Component\HttpKernel\Kernel', array(), array(), '', false);
Expand All @@ -36,4 +36,4 @@ public function testAnnotationsBundle()
$cmd->setApplication($application);
$cmd->run($input, $output);
}
}
}

0 comments on commit 6edb644

Please sign in to comment.