Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 23 |
| MockRouteProvider | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
110 | |
0.00% |
0 / 23 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getRouteCollectionForRequest | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getRouteByName | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 6 |
|||
| preLoadRoutes | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| getRoutesByNames | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 6 |
|||
| getRoutesByPattern | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| getAllRoutes | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| reset | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 2 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\system\Tests\Routing\MockRouteProvider. | |
| */ | |
| namespace Drupal\system\Tests\Routing; | |
| use Symfony\Component\HttpFoundation\Request; | |
| use Symfony\Component\Routing\Exception\RouteNotFoundException; | |
| use Symfony\Component\Routing\RouteCollection; | |
| use Drupal\Core\Routing\RouteProviderInterface; | |
| /** | |
| * Easily configurable mock route provider. | |
| */ | |
| class MockRouteProvider implements RouteProviderInterface { | |
| /** | |
| * A collection of routes for this route provider. | |
| * | |
| * @var RouteCollection | |
| */ | |
| protected $routes; | |
| /** | |
| * Constructs a new MockRouteProvider. | |
| * | |
| * @param \Symfony\Component\Routing\RouteCollection $routes | |
| * The route collection to use for this provider. | |
| */ | |
| public function __construct(RouteCollection $routes) { | |
| $this->routes = $routes; | |
| } | |
| /** | |
| * Implements \Symfony\Cmf\Component\Routing\RouteProviderInterface::getRouteCollectionForRequest(). | |
| * | |
| * Simply return all routes to prevent | |
| * \Symfony\Component\Routing\Exception\ResourceNotFoundException. | |
| */ | |
| public function getRouteCollectionForRequest(Request $request) { | |
| return $this->routes; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getRouteByName($name) { | |
| $routes = $this->getRoutesByNames(array($name)); | |
| if (empty($routes)) { | |
| throw new RouteNotFoundException(sprintf('Route "%s" does not exist.', $name)); | |
| } | |
| return reset($routes); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function preLoadRoutes($names) { | |
| // Nothing to do. | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getRoutesByNames($names) { | |
| $routes = array(); | |
| foreach ($names as $name) { | |
| $routes[] = $this->routes->get($name); | |
| } | |
| return $routes; | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getRoutesByPattern($pattern) { | |
| return new RouteCollection(); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getAllRoutes() { | |
| return $this->routes->all(); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function reset() { | |
| $this->routes = array(); | |
| } | |
| } |