Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #26121 [FrameworkBundle] feature: add the ability to search a…
… route (Simperfit) This PR was merged into the 4.1-dev branch. Discussion ---------- [FrameworkBundle] feature: add the ability to search a route | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no <!-- don't forget to update UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #26033 | License | MIT | Doc PR | symfony/symfony-docs#9236 This add the ability to search a route in the debug:router command. ![img_3271](https://user-images.githubusercontent.com/3451634/36034017-e60cbfda-0db2-11e8-841a-60bc75b0b631.jpeg) Commits ------- ef0df02 [FrameworkBundle] feature: add the ability to search a route
- Loading branch information
Showing
7 changed files
with
136 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 0 additions & 109 deletions
109
src/Symfony/Bundle/FrameworkBundle/Tests/Command/RouterDebugCommandTest.php
This file was deleted.
Oops, something went wrong.
80 changes: 80 additions & 0 deletions
80
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/RouterDebugCommandTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
|
||
/** | ||
* @group functional | ||
*/ | ||
class RouterDebugCommandTest extends WebTestCase | ||
{ | ||
private $application; | ||
|
||
protected function setUp() | ||
{ | ||
$kernel = static::createKernel(array('test_case' => 'RouterDebug', 'root_config' => 'config.yml')); | ||
$this->application = new Application($kernel); | ||
} | ||
|
||
public function testDumpAllRoutes() | ||
{ | ||
$tester = $this->createCommandTester(); | ||
$ret = $tester->execute(array()); | ||
$display = $tester->getDisplay(); | ||
|
||
$this->assertSame(0, $ret, 'Returns 0 in case of success'); | ||
$this->assertContains('routerdebug_test', $display); | ||
$this->assertContains('/test', $display); | ||
$this->assertContains('/session', $display); | ||
} | ||
|
||
public function testDumpOneRoute() | ||
{ | ||
$tester = $this->createCommandTester(); | ||
$ret = $tester->execute(array('name' => 'routerdebug_session_welcome')); | ||
|
||
$this->assertSame(0, $ret, 'Returns 0 in case of success'); | ||
$this->assertContains('routerdebug_session_welcome', $tester->getDisplay()); | ||
$this->assertContains('/session', $tester->getDisplay()); | ||
} | ||
|
||
public function testSearchMultipleRoutes() | ||
{ | ||
$tester = $this->createCommandTester(); | ||
$tester->setInputs(array(3)); | ||
$ret = $tester->execute(array('name' => 'routerdebug'), array('interactive' => true)); | ||
|
||
$this->assertSame(0, $ret, 'Returns 0 in case of success'); | ||
$this->assertContains('Select one of the matching routes:', $tester->getDisplay()); | ||
$this->assertContains('routerdebug_test', $tester->getDisplay()); | ||
$this->assertContains('/test', $tester->getDisplay()); | ||
} | ||
|
||
/** | ||
* @expectedException \InvalidArgumentException | ||
* @expectedExceptionMessage The route "gerard" does not exist. | ||
*/ | ||
public function testSearchWithThrow() | ||
{ | ||
$tester = $this->createCommandTester(); | ||
$tester->execute(array('name' => 'gerard'), array('interactive' => true)); | ||
} | ||
|
||
private function createCommandTester(): CommandTester | ||
{ | ||
$command = $this->application->get('debug:router'); | ||
|
||
return new CommandTester($command); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/RouterDebug/bundles.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
|
||
return array( | ||
new FrameworkBundle(), | ||
new TestBundle(), | ||
); |
2 changes: 2 additions & 0 deletions
2
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/RouterDebug/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
imports: | ||
- { resource: ../config/default.yml } |
15 changes: 15 additions & 0 deletions
15
src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/RouterDebug/routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
routerdebug_session_welcome: | ||
path: /session | ||
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::welcomeAction } | ||
|
||
routerdebug_session_welcome_name: | ||
path: /session/{name} | ||
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::welcomeAction } | ||
|
||
routerdebug_session_logout: | ||
path: /session_logout | ||
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::logoutAction } | ||
|
||
routerdebug_test: | ||
path: /test | ||
defaults: { _controller: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\SessionController::welcomeAction } |