Split PartialMatcher tests out into their own test class.

8.0.x
Larry Garfield 2012-07-04 15:08:58 -05:00 committed by effulgentsia
parent f0c3b571e7
commit 5701e622f6
2 changed files with 71 additions and 2 deletions

View File

@ -2,7 +2,7 @@
/**
* @file
* Definition of Drupal\system\Tests\Routing\PartialMatcherTest.
* Definition of Drupal\system\Tests\Routing\HttpMethodMMatcherTest.
*/
namespace Drupal\system\Tests\Routing;
@ -20,7 +20,7 @@ use Drupal\Core\Routing\FirstEntryFinalMatcher;
use Exception;
/**
* Basic tests for the UrlMatcherDumper.
* Basic tests for the HttpMethodMatcher class.
*/
class HttpMethodMatcherTest extends UnitTestBase {

View File

@ -0,0 +1,69 @@
<?php
/**
* @file
* Definition of Drupal\system\Tests\Routing\NestedMatcherTest.
*/
namespace Drupal\system\Tests\Routing;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
use Drupal\simpletest\UnitTestBase;
use Drupal\Core\Routing\HttpMethodMatcher;
use Drupal\Core\Routing\NestedMatcher;
use Drupal\Core\Routing\FirstEntryFinalMatcher;
use Exception;
/**
* Basic tests for the NestedMatcher class.
*/
class NestedMatcherTest extends UnitTestBase {
/**
* A collection of shared fixture data for tests.
*
* @var RoutingFixtures
*/
protected $fixtures;
public static function getInfo() {
return array(
'name' => 'NestedMatcher tests',
'description' => 'Confirm that the NestedMatcher system is working properly.',
'group' => 'Routing',
);
}
function __construct($test_id = NULL) {
parent::__construct($test_id);
$this->fixtures = new RoutingFixtures();
}
public function setUp() {
parent::setUp();
}
/**
* Confirms we can nest multiple partial matchers.
*/
public function testNestedMatcher() {
$matcher = new NestedMatcher();
$matcher->setInitialMatcher(new MockPathMatcher($this->fixtures->sampleRouteCollection()));
$matcher->addPartialMatcher(new HttpMethodMatcher());
$matcher->setFinalMatcher(new FirstEntryFinalMatcher());
$request = Request::create('/path/one', 'GET');
$attributes = $matcher->matchRequest($request);
$this->assertEqual($attributes['_route'], 'route_a', t('The correct matching route was found.'));
}
}