function ViewExecutableTest::testSetCurrentPageDuringPreRender

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

@covers ::setCurrentPage @covers ::getCurrentPage

File

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

Class

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

Namespace

Drupal\Tests\views\Unit

Code

public function testSetCurrentPageDuringPreRender() : void {
    
    /** @var \Drupal\views\ViewExecutable|\PHPUnit\Framework\MockObject\MockObject $view */
    $view = current($this->setupBaseViewAndDisplay());
    $elements =& $view->element;
    $elements['#cache'] += [
        'keys' => [],
    ];
    $elements['#pre_rendered'] = TRUE;
    $view->setCurrentPage(12);
    $this->assertEquals(12, $view->getCurrentPage());
    $this->assertNotContains('page:12', $view->element['#cache']['keys']);
}

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