protected function GroupContentCreateAccessTest::createRequest in Group 2.0.x
Same name and namespace in other branches
- 8 tests/src/Kernel/GroupContentCreateAccessTest.php \Drupal\Tests\group\Kernel\GroupContentCreateAccessTest::createRequest()
Creates a request for a specific route.
Parameters
string $route_name: The route name.
\Drupal\group\Entity\GroupInterface $group: The group.
string|null $plugin_id: (optional) The plugin ID.
Return value
\Symfony\Component\HttpFoundation\Request The request.
2 calls to GroupContentCreateAccessTest::createRequest()
- GroupContentCreateAccessTest::testFormAccess in tests/
src/ Kernel/ GroupContentCreateAccessTest.php - Tests access to the create/add form.
- GroupContentCreateAccessTest::testPageAccess in tests/
src/ Kernel/ GroupContentCreateAccessTest.php - Tests access to the create/add overview page.
File
- tests/
src/ Kernel/ GroupContentCreateAccessTest.php, line 297
Class
- GroupContentCreateAccessTest
- Tests the group content create access for groups.
Namespace
Drupal\Tests\group\KernelCode
protected function createRequest($route_name, GroupInterface $group, $plugin_id = NULL) {
$params = [
'group' => $group
->id(),
];
$attributes = [
'group' => $group,
];
if ($plugin_id) {
$params['plugin_id'] = $plugin_id;
$attributes['plugin_id'] = $plugin_id;
}
$attributes[RouteObjectInterface::ROUTE_NAME] = $route_name;
$attributes[RouteObjectInterface::ROUTE_OBJECT] = $this->routeProvider
->getRouteByName($route_name);
$attributes['_raw_variables'] = new ParameterBag($params);
$request = Request::create(Url::fromRoute($route_name, $params)
->toString());
$request->attributes
->add($attributes);
// Push the request to the request stack so `current_route_match` works.
$this->container
->get('request_stack')
->push($request);
return $request;
}