function ViewExecutableFactoryTest::testGet

Same name in other branches
  1. 9 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()
  3. 11.x 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.