function ViewsTest::setUp

Same name and namespace in other branches
  1. 9 core/modules/views/tests/src/Unit/ViewsTest.php \Drupal\Tests\views\Unit\ViewsTest::setUp()
  2. 8.9.x core/modules/views/tests/src/Unit/ViewsTest.php \Drupal\Tests\views\Unit\ViewsTest::setUp()
  3. 10 core/modules/views/tests/src/Unit/ViewsTest.php \Drupal\Tests\views\Unit\ViewsTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/views/tests/src/Unit/ViewsTest.php, line 33

Class

ViewsTest
@coversDefaultClass <a href="/api/drupal/core%21modules%21views%21src%21Views.php/class/Views/11.x" title="Static service container wrapper for views." class="local">\Drupal\views\Views</a> @group views

Namespace

Drupal\Tests\views\Unit

Code

protected function setUp() : void {
    parent::setUp();
    $this->container = new ContainerBuilder();
    $user = $this->createMock('Drupal\\Core\\Session\\AccountInterface');
    $request_stack = new RequestStack();
    $request_stack->push(new Request());
    $views_data = $this->getMockBuilder('Drupal\\views\\ViewsData')
        ->disableOriginalConstructor()
        ->getMock();
    $route_provider = $this->createMock('Drupal\\Core\\Routing\\RouteProviderInterface');
    $display_plugin_manager = $this->getMockBuilder('\\Drupal\\views\\Plugin\\ViewsPluginManager')
        ->disableOriginalConstructor()
        ->getMock();
    $this->container
        ->set('views.executable', new ViewExecutableFactory($user, $request_stack, $views_data, $route_provider, $display_plugin_manager));
    \Drupal::setContainer($this->container);
}

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