Skip to content
Snippets Groups Projects
Commit 5701e622 authored by Larry Garfield's avatar Larry Garfield Committed by Alex Bronstein
Browse files

Split PartialMatcher tests out into their own test class.

parent f0c3b571
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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 Exception;
/**
* Basic tests for the UrlMatcherDumper.
* Basic tests for the HttpMethodMatcher class.
*/
class HttpMethodMatcherTest extends UnitTestBase {
......
<?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.'));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment