function ViewExecutableTest::setupBaseViewAndDisplay

Same name in other branches
  1. 8.9.x core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setupBaseViewAndDisplay()
  2. 10 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setupBaseViewAndDisplay()
  3. 11.x core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setupBaseViewAndDisplay()

Setups a view executable and default display.

Return value

array Returns the view executable and default display.

12 calls to ViewExecutableTest::setupBaseViewAndDisplay()
ViewExecutableTest::testAddHandler in core/modules/views/tests/src/Unit/ViewExecutableTest.php
@covers ::addHandler
ViewExecutableTest::testAddHandlerWithEntityField in core/modules/views/tests/src/Unit/ViewExecutableTest.php
@covers ::addHandler
ViewExecutableTest::testAttachDisplays in core/modules/views/tests/src/Unit/ViewExecutableTest.php
Tests if a display gets attached or not.
ViewExecutableTest::testBuildThemeFunctions in core/modules/views/tests/src/Unit/ViewExecutableTest.php
@covers ::buildThemeFunctions
ViewExecutableTest::testCacheIsIgnoredDuringPreview in core/modules/views/tests/src/Unit/ViewExecutableTest.php
@covers ::execute

... See full list

File

core/modules/views/tests/src/Unit/ViewExecutableTest.php, line 535

Class

ViewExecutableTest
@coversDefaultClass \Drupal\views\ViewExecutable @group views

Namespace

Drupal\Tests\views\Unit

Code

protected function setupBaseViewAndDisplay() {
    $config = [
        'id' => 'test_view',
        'tag' => 'OnE, TWO, and three',
        'display' => [
            'default' => [
                'id' => 'default',
                'display_plugin' => 'default',
                'display_title' => 'Default',
            ],
        ],
    ];
    $storage = new View($config, 'view');
    $view = new ViewExecutable($storage, $this->user, $this->viewsData, $this->routeProvider);
    $display = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
        ->disableOriginalConstructor()
        ->getMock();
    $display->expects($this->any())
        ->method('getPlugin')
        ->with($this->equalTo('cache'))
        ->willReturn($this->successCache);
    $display->display = $config['display']['default'];
    $view->current_display = 'default';
    $view->display_handler = $display;
    $view->displayHandlers = $this->displayHandlers;
    $view->displayHandlers
        ->expects($this->any())
        ->method('get')
        ->with('default')
        ->willReturn($display);
    $view->displayHandlers
        ->expects($this->any())
        ->method('has')
        ->with('default')
        ->willReturn(TRUE);
    foreach (array_keys($view->getHandlerTypes()) as $type) {
        $view->{$type} = [];
    }
    return [
        $view,
        $display,
    ];
}

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