You are here

public function ViewExecutableFactoryTest::testGet in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Unit/ViewExecutableFactoryTest.php \Drupal\Tests\views\Unit\ViewExecutableFactoryTest::testGet()
  2. 10 core/modules/views/tests/src/Unit/ViewExecutableFactoryTest.php \Drupal\Tests\views\Unit\ViewExecutableFactoryTest::testGet()

Tests the get method.

@covers ::get

File

core/modules/views/tests/src/Unit/ViewExecutableFactoryTest.php, line 79

Class

ViewExecutableFactoryTest
@coversDefaultClass \Drupal\views\ViewExecutableFactory @group views

Namespace

Drupal\Tests\views\Unit

Code

public function testGet() {
  $request_1 = new Request();
  $request_2 = new Request();
  $this->requestStack
    ->push($request_1);
  $executable = $this->viewExecutableFactory
    ->get($this->view);
  $this
    ->assertInstanceOf('Drupal\\views\\ViewExecutable', $executable);
  $this
    ->assertSame($executable
    ->getRequest(), $request_1);
  $this
    ->assertSame($executable
    ->getUser(), $this->user);

  // Call get() again to ensure a new executable is created with the other
  // request object.
  $this->requestStack
    ->push($request_2);
  $executable = $this->viewExecutableFactory
    ->get($this->view);
  $this
    ->assertInstanceOf('Drupal\\views\\ViewExecutable', $executable);
  $this
    ->assertSame($executable
    ->getRequest(), $request_2);
  $this
    ->assertSame($executable
    ->getUser(), $this->user);
}