Skip to content

Commit

Permalink
some CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
schmittjoh committed Jul 18, 2011
1 parent bda21f8 commit 6ddd3e5
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 62 deletions.
102 changes: 51 additions & 51 deletions Command/GenerateTestApplicationCommand.php
Expand Up @@ -11,32 +11,32 @@

class GenerateTestApplicationCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('generate:test-application')
->setDescription('Generates a sample application inside a bundle that you can use for functional tests.')
->addArgument('bundle', InputArgument::REQUIRED, 'The full bundle name, e.g. JMSCommandBundle')
->addOption('with-database', null, InputOption::VALUE_NONE, 'Whether to generate database support')
;
}
protected function configure()
{
$this
->setName('generate:test-application')
->setDescription('Generates a sample application inside a bundle that you can use for functional tests.')
->addArgument('bundle', InputArgument::REQUIRED, 'The full bundle name, e.g. JMSCommandBundle')
->addOption('with-database', null, InputOption::VALUE_NONE, 'Whether to generate database support')
;
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$bundle = $this->getContainer()->get('kernel')->getBundle($input->getArgument('bundle'));
protected function execute(InputInterface $input, OutputInterface $output)
{
$bundle = $this->getContainer()->get('kernel')->getBundle($input->getArgument('bundle'));

$files = array(
'/AppKernel.php' => array(
'namespace' => $bundle->getNamespace(),
'name' => $bundle->getName(),
'withDatabase' => $input->getOption('with-database'),
),
'/BaseTestCase.php' => array(
'namespace' => $bundle->getNamespace(),
'withDatabase' => $input->getOption('with-database'),
$files = array(
'/AppKernel.php' => array(
'namespace' => $bundle->getNamespace(),
'name' => $bundle->getName(),
'withDatabase' => $input->getOption('with-database'),
),
'/config/default.yml' => array(
'withDatabase' => $input->getOption('with-database'),
'/BaseTestCase.php' => array(
'namespace' => $bundle->getNamespace(),
'withDatabase' => $input->getOption('with-database'),
),
'/config/default.yml' => array(
'withDatabase' => $input->getOption('with-database'),
),
'/config/framework.yml' => array(
),
Expand All @@ -45,40 +45,40 @@ protected function execute(InputInterface $input, OutputInterface $output)
),
'/config/twig.yml' => array(
)
);
);

if ($input->getOption('with-database')) {
$files['/config/doctrine.yml'] = array();
}
if ($input->getOption('with-database')) {
$files['/config/doctrine.yml'] = array();
}

$testDir = $bundle->getPath().'/Tests/Functional';
foreach ($files as $name => $params) {
$file = $testDir.$name;
if (!file_exists($dir = dirname($file)) && false === @mkdir($dir, 0777, true)) {
throw new \RuntimeException(sprintf('Could not create directory "%s".', $dir));
}
$testDir = $bundle->getPath().'/Tests/Functional';
foreach ($files as $name => $params) {
$file = $testDir.$name;
if (!file_exists($dir = dirname($file)) && false === @mkdir($dir, 0777, true)) {
throw new \RuntimeException(sprintf('Could not create directory "%s".', $dir));
}

if (file_exists($file)) {
continue;
}
if (file_exists($file)) {
continue;
}

file_put_contents($file, $this->render('@JMSCommandBundle/Resources/skeleton/Application'.$name, $params));
$output->writeln(sprintf('[File+] <comment>%s</comment>', $file));
}
file_put_contents($file, $this->render('@JMSCommandBundle/Resources/skeleton/Application'.$name, $params));
$output->writeln(sprintf('[File+] <comment>%s</comment>', $file));
}

$output->writeln('Test Application has been generated successfully.');
}
$output->writeln('Test Application has been generated successfully.');
}

private function render($jms_name, $jms_params = array())
{
$jms_path = $this->getContainer()->get('kernel')->locateResource($jms_name);
private function render($jms_name, $jms_params = array())
{
$jms_path = $this->getContainer()->get('kernel')->locateResource($jms_name);

extract($jms_params, EXTR_SKIP);
ob_start();
require $jms_path;
$content = str_replace('[?php', '<?php', ob_get_contents());
ob_end_clean();
extract($jms_params, EXTR_SKIP);
ob_start();
require $jms_path;
$content = str_replace('[?php', '<?php', ob_get_contents());
ob_end_clean();

return $content;
}
return $content;
}
}
22 changes: 11 additions & 11 deletions Resources/skeleton/Application/BaseTestCase.php
Expand Up @@ -6,22 +6,22 @@

class BaseTestCase extends WebTestCase
{
static protected function createKernel(array $options = array())
{
return new AppKernel(
isset($options['config']) ? $options['config'] : 'default.yml'
);
}
static protected function createKernel(array $options = array())
{
return new AppKernel(
isset($options['config']) ? $options['config'] : 'default.yml'
);
}
<?php if ($withDatabase): ?>
protected final function importDatabaseSchema()
{
protected final function importDatabaseSchema()
{
$em = self::$kernel->getContainer()->get('doctrine.orm.entity_manager');

$metadata = $em->getMetadataFactory()->getAllMetadata();
if (!empty($metadata)) {
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
$schemaTool->createSchema($metadata);
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($em);
$schemaTool->createSchema($metadata);
}
}
}
<?php endif ?>
}

0 comments on commit 6ddd3e5

Please sign in to comment.