Non-working tests to demonstrate that default values don't work yet.
parent
a3deb0349d
commit
8306c5a32a
|
@ -127,6 +127,46 @@ class PathMatcherTest extends UnitTestBase {
|
|||
$this->assertNotNull($routes->get('route_b'), 'The second matching route was not found.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms that we can find routes whose pattern would match the request.
|
||||
*/
|
||||
function testOutlinePathMatchDefaults() {
|
||||
$connection = Database::getConnection();
|
||||
$matcher = new PathMatcher($connection, 'test_routes');
|
||||
|
||||
$this->fixtures->createTables($connection);
|
||||
|
||||
$collection = new RouteCollection();
|
||||
$collection->add('poink', new Route('/some/path/{value}', array(
|
||||
'value' => 'poink',
|
||||
)));
|
||||
|
||||
$dumper = new MatcherDumper($connection, 'test_routes');
|
||||
$dumper->addRoutes($collection);
|
||||
$dumper->dump();
|
||||
|
||||
$path = '/some/path';
|
||||
|
||||
$request = Request::create($path, 'GET');
|
||||
|
||||
try {
|
||||
$routes = $matcher->matchRequestPartial($request);
|
||||
|
||||
// All of the matching paths have the correct pattern.
|
||||
foreach ($routes as $route) {
|
||||
$compiled = $route->compile();
|
||||
debug($compiled->getPatternOutline());
|
||||
$this->assertEqual($route->compile()->getPatternOutline(), '/path/path/%', 'Found path has correct pattern');
|
||||
}
|
||||
|
||||
$this->assertEqual(count($routes->all()), 1, 'The correct number of routes was found.');
|
||||
$this->assertNotNull($routes->get('poink'), 'The first matching route was found.');
|
||||
}
|
||||
catch (ResourceNotFoundException $e) {
|
||||
$this->fail('No matching route found with default argument value.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirm that an exception is thrown when no matching path is found.
|
||||
*/
|
||||
|
|
|
@ -49,11 +49,20 @@ class RouterTest extends WebTestBase {
|
|||
/**
|
||||
* Confirms that placeholders in paths work correctly.
|
||||
*/
|
||||
public function testDefaultControllerPlaceholders() {
|
||||
public function testControllerPlaceholders() {
|
||||
$value = $this->randomName();
|
||||
$this->drupalGet('router_test/test3/' . $value);
|
||||
$this->assertRaw($value, 'The correct string was returned because the route was successful.');
|
||||
$this->assertRaw('</html>', 'Page markup was found.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms that default placeholders in paths work correctly.
|
||||
*/
|
||||
public function testControllerPlaceholdersDefaultValues() {
|
||||
$this->drupalGet('router_test/test4');
|
||||
$this->assertRaw('narf', 'The correct string was returned because the route was successful.');
|
||||
$this->assertRaw('</html>', 'Page markup was found.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,4 +26,8 @@ class TestControllers {
|
|||
return $value;
|
||||
}
|
||||
|
||||
public function test4($value) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,5 +24,11 @@ function router_test_route_info() {
|
|||
));
|
||||
$collection->add('router_test_3', $route);
|
||||
|
||||
$route = new Route('router_test/test4/{value}', array(
|
||||
'_content' => '\Drupal\router_test\TestControllers::test4',
|
||||
'value' => 'narf',
|
||||
));
|
||||
$collection->add('router_test_4', $route);
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue