function DatabaseBackendTest::getNumRows

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php \Drupal\KernelTests\Core\Cache\DatabaseBackendTest::getNumRows()
  2. 10 core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php \Drupal\KernelTests\Core\Cache\DatabaseBackendTest::getNumRows()
  3. 11.x core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php \Drupal\KernelTests\Core\Cache\DatabaseBackendTest::getNumRows()

Gets the number of rows in the test cache bin database table.

Return value

int The number of rows in the test cache bin database table.

1 call to DatabaseBackendTest::getNumRows()
DatabaseBackendTest::testGarbageCollection in core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php
Tests the row count limiting of cache bin database tables.

File

core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php, line 98

Class

DatabaseBackendTest
Unit test of the database backend using the generic cache unit test base.

Namespace

Drupal\KernelTests\Core\Cache

Code

protected function getNumRows() {
    $table = 'cache_' . $this->testBin;
    $connection = $this->container
        ->get('database');
    $query = $connection->select($table);
    $query->addExpression('COUNT([cid])', 'cid');
    return (int) $query->execute()
        ->fetchField();
}

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