public function BackendChainImplementationUnitTest::testGetMultiple

Test the get multiple feature.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Cache/BackendChainImplementationUnitTest.php, line 113
Definition of Drupal\system\Tests\Cache\BackendChainImplementationUnitTest.

Class

BackendChainImplementationUnitTest
Tests implementation-specific functionality of the BackendChain backend.

Namespace

Drupal\system\Tests\Cache

Code

public function testGetMultiple() {
  $cids = array(
    't123',
    't23',
    't3',
    't4',
  );
  $ret = $this->chain
    ->getMultiple($cids);
  $this
    ->assertIdentical($ret['t123']->data, 1231, 'Got key 123 and value is from the first backend');
  $this
    ->assertIdentical($ret['t23']->data, 232, 'Got key 23 and value is from the second backend');
  $this
    ->assertIdentical($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
    ->assert(in_array('t4', $cids), "Non existing key 4 is still in &\$cids");
}