function DatabaseBackendTest::getNumRows

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php \Drupal\KernelTests\Core\Cache\DatabaseBackendTest::getNumRows()
  2. 8.9.x 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.

2 calls to DatabaseBackendTest::getNumRows()
DatabaseBackendTest::testGarbageCollection in core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php
Tests the row count limiting of cache bin database tables.
DatabaseBackendTest::testSetGet in core/tests/Drupal/KernelTests/Core/Cache/DatabaseBackendTest.php
Tests the get and set methods of Drupal\Core\Cache\CacheBackendInterface.

File

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

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.