This is a simple idea, but routes need to be tested on the outside of your framework. I have previously been doing this with bash scripts, as it was faster. This came up in a conversation recently, so here is a nicer one.
This source is AGPL, not that the licence on a test script should impact any products.

To use:

  • ensure you have phpunit installed
  • ensure you have the Symfony route module installed (maybe in Drupal8, Syllius, Laravel or Symfony)
  • copy this file into your project, edit the URL arrays
  • profit.

It is easier to download this off my github


// test to verify the state space for this URL
// this is much easier than in other frameworks
class RoutesTest extends PHPUnit_Framework_TestCase
	protected $goodURL;
	protected $badURL

	protected function setUp() {
		$isEnabled=exec('cd .', $ignored, $status);
//			$this->markTestSkipped("No exec(), can't run this entire test. ");	
			die("No exec(), can't run this entire test '$status'. ");
		$isEnabled=exec('php -v', $ignored, $status);
		if($isEnabled===false) {
//			$this->markTestSkipped("No php on the path, can't run this entire test. ");	
			die("No php on the path, can't run this entire test. ");
		$this->goodURL= []; // ADD URLS HERE
		$this->badURL= []; // ADD URLS HERE

	protected function tearDown() {

	private function quickRouteTest($urn) {
		$t="php ../../../bin/console router:match '$urn' ";
		$ret=@exec($t, $ignored, $status);
		return intval($status);

	public function testRoute1() {
		foreach($this->goodURL as $v) {
			$this->assertTrue($this->quickRouteTest($v)==0, $v);

	public function testRoute2() {
		foreach($$this->badURL as $v) {
			$this->assertTrue($this->quickRouteTest($v)==1, $v);