function BackendChainImplementationUnitTest::testGetMultiple

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php \Drupal\Tests\Core\Cache\BackendChainImplementationUnitTest::testGetMultiple()
  2. 8.9.x core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php \Drupal\Tests\Core\Cache\BackendChainImplementationUnitTest::testGetMultiple()
  3. 11.x core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php \Drupal\Tests\Core\Cache\BackendChainImplementationUnitTest::testGetMultiple()

Tests the get multiple feature.

File

core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php, line 110

Class

BackendChainImplementationUnitTest
Unit test of backend chain implementation specifics.

Namespace

Drupal\Tests\Core\Cache

Code

public function testGetMultiple() : void {
    $cids = [
        't123',
        't23',
        't3',
        't4',
    ];
    $ret = $this->chain
        ->getMultiple($cids);
    $this->assertSame($ret['t123']->data, 1231, 'Got key 123 and value is from the first backend');
    $this->assertSame($ret['t23']->data, 232, 'Got key 23 and value is from the second backend');
    $this->assertSame($ret['t3']->data, 33, 'Got key 3 and value is from the third backend');
    $this->assertArrayNotHasKey('t4', $ret);
    $this->assertNotContains('t123', $cids, "Existing key 123 has been removed from &\$cids");
    $this->assertNotContains('t23', $cids, "Existing key 23 has been removed from &\$cids");
    $this->assertNotContains('t3', $cids, "Existing key 3 has been removed from &\$cids");
    $this->assertContains('t4', $cids, "Non existing key 4 is still in &\$cids");
}

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