You are here

public function DataLayerKernelTest::setupMockRouteMatch in dataLayer 8

Setup Mock RouteMatch.

1 call to DataLayerKernelTest::setupMockRouteMatch()
DataLayerKernelTest::testDataLayerMenuGetAnyObjectReturnsObject in tests/src/Kernel/DataLayerKernelTest.php
Test DataLayer Menu Get Any Object Returns Object.

File

tests/src/Kernel/DataLayerKernelTest.php, line 255

Class

DataLayerKernelTest
Kernel test cases for datalayer module.

Namespace

Drupal\Tests\datalayer\Kernel

Code

public function setupMockRouteMatch() {
  $this
    ->setupMockNode();
  $request =& drupal_static(__FUNCTION__);
  if (!$request) {
    $request = \Drupal::request()
      ->create('/node/1', 'GET', [
      'node' => $this->node,
    ]);
    $request->attributes
      ->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/node/{node}', [
      'node' => 1,
    ]));
    $request->attributes
      ->set(RouteObjectInterface::ROUTE_NAME, 'entity.node.canonical');
    $request->attributes
      ->set('node', $this->node);
    $this->container
      ->get('request_stack')
      ->push($request);
  }
}