Skip to content

Commit

Permalink
added tests for FriendsOfSymfony#379 - route order is kept if the met…
Browse files Browse the repository at this point in the history
…hod is not a custom one
  • Loading branch information
mdouailin committed Jun 12, 2013
1 parent 07f22c3 commit d1e2fb2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Tests/Fixtures/Controller/OrdersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public function newFoosAction()
public function newBarsAction()
{} // [GET] /bars/new

public function getBarsCustomAction()
{} // [GET] /bars/custom

public function getBarsAction($slug)
{} // [GET] /bars/{slug}
}
23 changes: 23 additions & 0 deletions Tests/Routing/Loader/RestRouteLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,29 @@ public function testConventionalActions()
$this->assertEquals($expectedMethod, $subsubcollection->get('remove_comment')->getRequirement('_method'));
}

/**
* Test that custom actions (new/edit/remove) are dumped earlier,
* and that developer routes order is kept
*
* @see https://github.com/FriendsOfSymfony/RestBundle/issues/379
*/
public function testCustomActionRoutesInDeveloperOrder()
{
// without prefix

$collection = $this->loadFromControllerFixture('OrdersController');
$pos = array_flip(array_keys($collection->all()));

$this->assertLessThan($pos['get_bars'], $pos['get_bars_custom']);

// with prefix

$collection = $this->loadFromControllerFixture('OrdersController', 'prefix_');
$pos = array_flip(array_keys($collection->all()));

$this->assertLessThan($pos['prefix_get_bars'], $pos['prefix_get_bars_custom']);
}

/**
* Load routes collection from fixture class under Tests\Fixtures directory.
*
Expand Down

0 comments on commit d1e2fb2

Please sign in to comment.