Skip to content

Commit

Permalink
Test that XML and YAML route collections forward requirements and def…
Browse files Browse the repository at this point in the history
…aults
  • Loading branch information
vierbergenlars authored and lsmith77 committed Feb 9, 2015
1 parent 1777fe4 commit 4290af3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@
<route id="get_users" pattern="/users">
<default key="_controller">FOSRestBundle:UsersController:getUsers</default>
<option key="expose">true</option>
<requirement key="slug">[a-z]+</requirement>
<default key="slug">home</default>
</route>
</routes>
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ users:
resource: FOS\RestBundle\Tests\Fixtures\Controller\UsersController
options:
expose: true
requirements:
slug: "[a-z]+"
defaults:
slug: home
15 changes: 4 additions & 11 deletions Tests/Routing/Loader/RestXmlCollectionLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,14 @@ public function testManualRoutesWithDefaultFormat()
$this->assertEquals('xml', $route->getDefault('_format'));
}

public function testForwardOptions()
public function testForwardOptionsRequirementsAndDefaults()
{
$collection = $this->loadFromXmlCollectionFixture(
'routes_with_options.xml',
true,
array(
'json' => false,
'xml' => false,
'html' => true,
),
'xml'
);
$collection = $this->loadFromXmlCollectionFixture('routes_with_options_requirements_and_defaults.xml');

foreach ($collection as $route) {
$this->assertTrue('true' === $route->getOption('expose'));
$this->assertEquals('[a-z]+', $route->getRequirement('slug'));
$this->assertEquals('home', $route->getDefault('slug'));
}
}
/**
Expand Down
6 changes: 4 additions & 2 deletions Tests/Routing/Loader/RestYamlCollectionLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ public function testNamedPrefixedReportsFixtureHasNoDuplicates()
$this->assertEquals(count($names), count(array_unique($names)));
}

public function testForwardOptions()
public function testForwardOptionsRequirementsAndDefaults()
{
$collection = $this->loadFromYamlCollectionFixture('routes_with_options.yml');
$collection = $this->loadFromYamlCollectionFixture('routes_with_options_requirements_and_defaults.yml');

foreach ($collection as $route) {
$this->assertTrue($route->getOption('expose'));
$this->assertEquals('[a-z]+', $route->getRequirement('slug'));
$this->assertEquals('home', $route->getDefault('slug'));
}
}

Expand Down

0 comments on commit 4290af3

Please sign in to comment.