Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit c5fdcfa

Browse files
committed
Added refresh auto routes command
1 parent 7d69bdc commit c5fdcfa

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

Command/RefreshCommand.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ public function execute(InputInterface $input, OutputInterface $output)
4343
foreach ($context->getRoutes() as $route) {
4444
$dm->persist($route);
4545
$routeId = $uow->getDocumentId($route);
46-
$output->writeln('<comment> - Persisting: </comment>'.$routeId);
46+
$output->writeln(sprintf(
47+
'<comment> - Persisting: </comment> %s <comment>%s</comment>',
48+
$routeId,
49+
'[...]'.substr(get_class($route), -10)
50+
));
51+
$dm->flush();
4752
}
48-
$dm->flush();
4953
}
5054
}
5155
}

Tests/Functional/BaseTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
require __DIR__.'/app/AppKernel.php';
66

77
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
8-
use Symfony\Component\Console\Application;
8+
use Symfony\Bundle\FrameworkBundle\Console\Application;
99

1010
class BaseTestCase extends WebTestCase
1111
{

Tests/Functional/Command/RefreshCommandTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Functional\BaseTestCase;
77
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Functional\app\Document\Post;
88
use Symfony\Component\Console\Input\ArrayInput;
9+
use Symfony\Component\Console\Output\NullOutput;
10+
use Symfony\Cmf\Bundle\RoutingAutoBundle\Command\RefreshCommand;
11+
use Symfony\Component\Console\Output\StreamOutput;
912

1013
class RefreshCommandTest extends BaseTestCase
1114
{
12-
public function setUp()
13-
{
14-
$this->createBlog(true);
15-
}
16-
1715
protected function createBlog($withPosts = false)
1816
{
1917
$blog = new Blog;
@@ -35,9 +33,16 @@ protected function createBlog($withPosts = false)
3533

3634
public function testCommand()
3735
{
36+
$this->createBlog(true);
37+
3838
$application = $this->getApplication();
39-
$input = new ArrayInput;
40-
$application->run($input);
39+
$input = new ArrayInput(array(
40+
));;
41+
$output = new NullOutput();
42+
//$output = new StreamOutput(fopen('php://stdout', 'w'));
43+
$command = new RefreshCommand();
44+
$command->setApplication($application);
45+
$command->execute($input, $output);
4146
}
4247
}
4348

0 commit comments

Comments
 (0)