class MockMatcher in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Routing/MockMatcher.php \Drupal\system\Tests\Routing\MockMatcher
A mock matcher that can be configured with any matching logic for testing.
Hierarchy
- class \Drupal\system\Tests\Routing\MockMatcher implements RequestMatcherInterface
Expanded class hierarchy of MockMatcher
File
- core/
modules/ system/ src/ Tests/ Routing/ MockMatcher.php, line 16 - Contains \Drupal\system\Tests\Routing\MockMatcher.
Namespace
Drupal\system\Tests\RoutingView source
class MockMatcher implements RequestMatcherInterface {
/**
* The matcher being tested.
*/
protected $matcher;
/**
* Constructs a MockMatcher object.
*
* @param \Closure $matcher
* An anonymous function that will be used for the matchRequest() method.
*/
public function __construct(\Closure $matcher) {
$this->matcher = $matcher;
}
/**
* {@inheritdoc}
*/
public function matchRequest(Request $request) {
$matcher = $this->matcher;
return $matcher($request);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MockMatcher:: |
protected | property | The matcher being tested. | |
MockMatcher:: |
public | function |
Tries to match a request with a set of routes. Overrides RequestMatcherInterface:: |
|
MockMatcher:: |
public | function | Constructs a MockMatcher object. |