You are here

protected function TaxonomyDefaultArgumentTest::initViewWithRequest in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyDefaultArgumentTest::initViewWithRequest()
  2. 10 core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php \Drupal\Tests\taxonomy\Kernel\Views\TaxonomyDefaultArgumentTest::initViewWithRequest()

Init view with a request by provided url.

Parameters

string $request_url: The requested url.

string $view_name: The name of the view.

Return value

\Drupal\views\ViewExecutable The initiated view.

Throws

\Exception

3 calls to TaxonomyDefaultArgumentTest::initViewWithRequest()
TaxonomyDefaultArgumentTest::testNodePath in core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php
Tests the relationship.
TaxonomyDefaultArgumentTest::testNodePathWithViewSelection in core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php
TaxonomyDefaultArgumentTest::testTermPath in core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php

File

core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyDefaultArgumentTest.php, line 37

Class

TaxonomyDefaultArgumentTest
Tests the representative node relationship for terms.

Namespace

Drupal\Tests\taxonomy\Kernel\Views

Code

protected function initViewWithRequest($request_url, $view_name = 'taxonomy_default_argument_test') {
  $view = Views::getView($view_name);
  $request = Request::create($request_url);
  $request->server
    ->set('SCRIPT_NAME', $GLOBALS['base_path'] . 'index.php');
  $request->server
    ->set('SCRIPT_FILENAME', 'index.php');
  $response = $this->container
    ->get('http_kernel')
    ->handle($request, HttpKernelInterface::SUB_REQUEST);
  $view
    ->setRequest($request);
  $view
    ->setResponse($response);
  $view
    ->initHandlers();
  return $view;
}