NullBackendTest.php 828 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
<?php

/**
 * @file
 * Definition of Drupal\system\Tests\Cache\NullBackendTest.
 */

namespace Drupal\system\Tests\Cache;

use Drupal\Core\Cache\NullBackend;
use Drupal\simpletest\UnitTestBase;

/**
 * Tests the cache NullBackend.
 */
class NullBackendTest extends UnitTestBase {
  public static function getInfo() {
    return array(
      'name' => 'Cache NullBackend test',
      'description' => 'Tests the cache NullBackend.',
      'group' => 'Cache',
    );
  }

  /**
   * Tests that the NullBackend does not actually store variables.
   */
  function testNullBackend() {
    $null_cache = new NullBackend('test');

    $key = $this->randomName();
    $value = $this->randomName();

    $null_cache->set($key, $value);
    $this->assertTrue($null_cache->isEmpty());
    $this->assertFalse($null_cache->get($key));
  }
}