function AlterTest::testAlterRemoveRange

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest::testAlterRemoveRange()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest::testAlterRemoveRange()
  3. 11.x core/tests/Drupal/KernelTests/Core/Database/AlterTest.php \Drupal\KernelTests\Core\Database\AlterTest::testAlterRemoveRange()

Tests that we can remove a range() value from a query.

This also tests hook_query_TAG_alter().

File

core/tests/Drupal/KernelTests/Core/Database/AlterTest.php, line 116

Class

AlterTest
Tests the hook_query_alter capabilities of the Select builder.

Namespace

Drupal\KernelTests\Core\Database

Code

public function testAlterRemoveRange() : void {
    $query = $this->connection
        ->select('test');
    $query->addField('test', 'name');
    $query->addField('test', 'age', 'age');
    $query->range(0, 2);
    $query->addTag('database_test_alter_remove_range');
    $num_records = count($query->execute()
        ->fetchAll());
    $this->assertEquals(4, $num_records, 'Returned the correct number of rows.');
}

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