You are here

public function ViewExecutableTest::testCacheIsIgnoredDuringPreview in Drupal 10

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

@covers ::execute

File

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

Class

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

Namespace

Drupal\Tests\views\Unit

Code

public function testCacheIsIgnoredDuringPreview() {

  /** @var \Drupal\views\ViewExecutable|\PHPUnit\Framework\MockObject\MockObject $view */

  /** @var \Drupal\views\Plugin\views\display\DisplayPluginBase|\PHPUnit\Framework\MockObject\MockObject $display */
  [
    $view,
    $display,
  ] = $this
    ->setupBaseViewAndDisplay();

  // Pager needs to be set to avoid false test failures.
  $view->pager = $this
    ->getMockBuilder(NonePager::class)
    ->disableOriginalConstructor()
    ->getMock();
  $query = $this
    ->getMockBuilder(QueryPluginBase::class)
    ->disableOriginalConstructor()
    ->getMock();
  $view->query = $query;
  $view->built = TRUE;
  $view->live_preview = TRUE;
  $this->noneCache
    ->expects($this
    ->once())
    ->method('cacheGet');
  $query
    ->expects($this
    ->once())
    ->method('execute');
  $view
    ->execute();
}