class RangeQueryTest in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php \Drupal\KernelTests\Core\Database\RangeQueryTest
- 9 core/tests/Drupal/KernelTests/Core/Database/RangeQueryTest.php \Drupal\KernelTests\Core\Database\RangeQueryTest
Tests the Range query functionality.
@group Database
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\KernelTests\Core\Database\DatabaseTestBase
- class \Drupal\KernelTests\Core\Database\RangeQueryTest
- class \Drupal\KernelTests\Core\Database\DatabaseTestBase
Expanded class hierarchy of RangeQueryTest
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ RangeQueryTest.php, line 10
Namespace
Drupal\KernelTests\Core\DatabaseView source
class RangeQueryTest extends DatabaseTestBase {
/**
* Confirms that range queries work and return the correct result.
*/
public function testRangeQuery() {
// Test if return correct number of rows.
$range_rows = $this->connection
->queryRange("SELECT [name] FROM {test} ORDER BY [name]", 1, 3)
->fetchAll();
$this
->assertCount(3, $range_rows, 'Range query work and return correct number of rows.');
// Test if return target data.
$raw_rows = $this->connection
->query('SELECT [name] FROM {test} ORDER BY [name]')
->fetchAll();
$raw_rows = array_slice($raw_rows, 1, 3);
$this
->assertEquals($range_rows, $raw_rows);
}
}