public function BackendChainImplementationUnitTest::testGetMultiple

Test the get multiple feature.

File

drupal/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTest.php, line 115
Definition of Drupal\Tests\Core\Cache\BackendChainImplementationUnitTest.

Class

BackendChainImplementationUnitTest
Tests implementation-specific functionality of the BackendChain backend.

Namespace

Drupal\Tests\Core\Cache

Code

public function testGetMultiple() {
  $cids = array(
    '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
    ->assertFalse(array_key_exists('t4', $ret), "Didn't get the nonexistent key");
  $this
    ->assertFalse(in_array('t123', $cids), "Existing key 123 has been removed from &\$cids");
  $this
    ->assertFalse(in_array('t23', $cids), "Existing key 23 has been removed from &\$cids");
  $this
    ->assertFalse(in_array('t3', $cids), "Existing key 3 has been removed from &\$cids");
  $this
    ->assertTrue(in_array('t4', $cids), "Non existing key 4 is still in &\$cids");
}