You are here

protected function LatestRevisionAccessTest::createRequest in Group 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Kernel/LatestRevisionAccessTest.php \Drupal\Tests\group\Kernel\LatestRevisionAccessTest::createRequest()

Creates a request for the group revision overview.

Parameters

\Drupal\group\Entity\GroupInterface $group: The group.

Return value

\Symfony\Component\HttpFoundation\Request The request.

1 call to LatestRevisionAccessTest::createRequest()
LatestRevisionAccessTest::testAccess in tests/src/Kernel/LatestRevisionAccessTest.php
Tests access to the revision tab.

File

tests/src/Kernel/LatestRevisionAccessTest.php, line 178

Class

LatestRevisionAccessTest
Tests the latest revision access for groups.

Namespace

Drupal\Tests\group\Kernel

Code

protected function createRequest(GroupInterface $group) {
  $url = Url::fromRoute('entity.group.latest_version', [
    'group' => $group
      ->id(),
  ]);
  $route = $this->routeProvider
    ->getRouteByName($url
    ->getRouteName());
  $request = Request::create($url
    ->toString());
  $request->attributes
    ->add([
    RouteObjectInterface::ROUTE_OBJECT => $route,
    'group' => $group,
  ]);

  // Push the request to the request stack so `current_route_match` works.
  $this->container
    ->get('request_stack')
    ->push($request);
  return $request;
}