You are here

protected function ViewExecutableTest::setupBaseViewAndDisplay in Drupal 8

Same name and namespace in other branches
  1. 9 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
@covers ::attachDisplays
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 498

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,
  ];
}