Commit 8306c5a3 authored by Crell's avatar Crell Committed by effulgentsia

Non-working tests to demonstrate that default values don't work yet.

parent a3deb034
......@@ -127,6 +127,46 @@ function testOutlinePathMatch() {
$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 @@ public function testDefaultController() {
/**
* 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 @@ public function test3($value) {
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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment