Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
1d803631
Commit
1d803631
authored
12 years ago
by
Larry Garfield
Committed by
Alex Bronstein
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests for FirstEntryFinalMatcher.
parent
02fd4b23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/system/lib/Drupal/system/Tests/Routing/FirstEntryFinalMatcherTest.php
+116
-0
116 additions, 0 deletions
...rupal/system/Tests/Routing/FirstEntryFinalMatcherTest.php
with
116 additions
and
0 deletions
core/modules/system/lib/Drupal/system/Tests/Routing/FirstEntryFinalMatcherTest.php
0 → 100644
+
116
−
0
View file @
1d803631
<?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
FirstEntryFinalMatcherTest
extends
UnitTestBase
{
/**
* A collection of shared fixture data for tests.
*
* @var RoutingFixtures
*/
protected
$fixtures
;
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'FirstEntryFinalMatcher tests'
,
'description'
=>
'Confirm that the FirstEntryFinalMatcher is working properly.'
,
'group'
=>
'Routing'
,
);
}
function
__construct
(
$test_id
=
NULL
)
{
parent
::
__construct
(
$test_id
);
$this
->
fixtures
=
new
RoutingFixtures
();
}
public
function
setUp
()
{
parent
::
setUp
();
}
/**
* Confirms the final matcher returns correct attributes for static paths.
*/
public
function
testFinalMatcherStatic
()
{
$collection
=
new
RouteCollection
();
$collection
->
add
(
'route_a'
,
new
Route
(
'/path/one'
,
array
(
'_controller'
=>
'foo'
,
)));
$request
=
Request
::
create
(
'/path/one'
,
'GET'
);
$matcher
=
new
FirstEntryFinalMatcher
();
$matcher
->
setCollection
(
$collection
);
$attributes
=
$matcher
->
matchRequest
(
$request
);
$this
->
assertEqual
(
$attributes
[
'_route'
],
'route_a'
,
'The correct matching route was found.'
);
$this
->
assertEqual
(
$attributes
[
'_controller'
],
'foo'
,
'The correct controller was found.'
);
}
/**
* Confirms the final matcher returns correct attributes for pattern paths.
*/
public
function
testFinalMatcherPattern
()
{
$collection
=
new
RouteCollection
();
$collection
->
add
(
'route_a'
,
new
Route
(
'/path/one/{value}'
,
array
(
'_controller'
=>
'foo'
,
)));
$request
=
Request
::
create
(
'/path/one/narf'
,
'GET'
);
$request
->
attributes
->
set
(
'system_path'
,
'path/one/narf'
);
$matcher
=
new
FirstEntryFinalMatcher
();
$matcher
->
setCollection
(
$collection
);
$attributes
=
$matcher
->
matchRequest
(
$request
);
$this
->
assertEqual
(
$attributes
[
'_route'
],
'route_a'
,
'The correct matching route was found.'
);
$this
->
assertEqual
(
$attributes
[
'_controller'
],
'foo'
,
'The correct controller was found.'
);
$this
->
assertEqual
(
$attributes
[
'value'
],
'narf'
,
'Required placeholder value found.'
);
}
/**
* Confirms the final matcher returns correct attributes with default values.
*/
public
function
testFinalMatcherPatternDefalts
()
{
$collection
=
new
RouteCollection
();
$collection
->
add
(
'route_a'
,
new
Route
(
'/path/one/{value}'
,
array
(
'_controller'
=>
'foo'
,
'value'
=>
'poink'
)));
$request
=
Request
::
create
(
'/path/one'
,
'GET'
);
$request
->
attributes
->
set
(
'system_path'
,
'path/one'
);
$matcher
=
new
FirstEntryFinalMatcher
();
$matcher
->
setCollection
(
$collection
);
$attributes
=
$matcher
->
matchRequest
(
$request
);
$this
->
assertEqual
(
$attributes
[
'_route'
],
'route_a'
,
'The correct matching route was found.'
);
$this
->
assertEqual
(
$attributes
[
'_controller'
],
'foo'
,
'The correct controller was found.'
);
$this
->
assertEqual
(
$attributes
[
'value'
],
'poink'
,
'Optional placeholder value used default.'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment