function ViewExecutableTest::testCacheIsIgnoredDuringPreview

Tests cache is ignored during preview.

@legacy-covers ::execute

File

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

Class

ViewExecutableTest
Tests Drupal\views\ViewExecutable.

Namespace

Drupal\Tests\views\Unit

Code

public function testCacheIsIgnoredDuringPreview() : void {
  /** @var \Drupal\views\ViewExecutable|\PHPUnit\Framework\MockObject\MockObject $view */
  $view = current($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();
}

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