You are here

public function PagerPluginBaseTest::testExecuteCountQueryWithOffsetLargerThanResult in Drupal 9

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

Tests the executeCountQuery method with an offset larger than result count.

See also

\Drupal\views\Plugin\views\pager\PagerPluginBase::executeCountQuery()

File

core/modules/views/tests/src/Unit/Plugin/pager/PagerPluginBaseTest.php, line 256
Contains \Drupal\Tests\views\Unit\Plugin\pager\PagerPluginBaseTest.

Class

PagerPluginBaseTest
@coversDefaultClass \Drupal\views\Plugin\views\pager\PagerPluginBase @group views

Namespace

Drupal\Tests\views\Unit\Plugin\pager

Code

public function testExecuteCountQueryWithOffsetLargerThanResult() {
  $statement = $this
    ->createMock(TestStatementInterface::class);
  $statement
    ->expects($this
    ->once())
    ->method('fetchField')
    ->will($this
    ->returnValue(2));
  $query = $this
    ->getMockBuilder(Select::class)
    ->disableOriginalConstructor()
    ->getMock();
  $query
    ->expects($this
    ->once())
    ->method('execute')
    ->will($this
    ->returnValue($statement));
  $this->pager
    ->setOffset(3);
  $this
    ->assertEquals(0, $this->pager
    ->executeCountQuery($query));
}