You are here

public function ViewExecutableTest::testSetOffsetDuringPreRender in Drupal 9

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

@covers ::setOffset @covers ::getOffset

File

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

Class

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

Namespace

Drupal\Tests\views\Unit

Code

public function testSetOffsetDuringPreRender() {

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

  /** @var \Drupal\views\Plugin\views\display\DisplayPluginBase|\PHPUnit\Framework\MockObject\MockObject $display */
  list($view, $display) = $this
    ->setupBaseViewAndDisplay();
  $elements =& $view->element;
  $elements['#cache'] += [
    'keys' => [],
  ];
  $elements['#pre_rendered'] = TRUE;
  $view
    ->setOffset(12);
  $this
    ->assertEquals(12, $view
    ->getOffset());
  $this
    ->assertNotContains('offset:12', $view->element['#cache']['keys']);
}