Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / src / Functional / Routing / MockMatcher.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Routing;
4
5 use Symfony\Component\HttpFoundation\Request;
6 use Symfony\Component\Routing\Matcher\RequestMatcherInterface;
7
8 /**
9  * A mock matcher that can be configured with any matching logic for testing.
10  */
11 class MockMatcher implements RequestMatcherInterface {
12
13   /**
14    * The matcher being tested.
15    */
16   protected $matcher;
17
18   /**
19    * Constructs a MockMatcher object.
20    *
21    * @param \Closure $matcher
22    *   An anonymous function that will be used for the matchRequest() method.
23    */
24   public function __construct(\Closure $matcher) {
25     $this->matcher = $matcher;
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function matchRequest(Request $request) {
32     $matcher = $this->matcher;
33     return $matcher($request);
34   }
35
36 }