You are here

ChainedStorageTests.php in Supercache 2.0.x

Same filename and directory in other branches
  1. 8 src/Tests/KeyValue/ChainedStorageTests.php

File

src/Tests/KeyValue/ChainedStorageTests.php
View source
<?php

namespace Drupal\supercache\Tests\KeyValue;

use Drupal\supercache\Tests\Generic\KeyValue\KeyValueTests;
use Drupal\supercache\KeyValueStore\KeyValueChainedFactory;
use Drupal\supercache\Tests\Generic\Cache\CacheServicesTrait;

/**
 * Test this on top of different combinations of cache backends.
 */
class ChainedStorageTests extends KeyValueTests {
  use CacheServicesTrait;

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    'system',
  ];

  /**
   * List of cache backend services.
   *
   * @var string[]
   */
  protected $backends;
  public function setUp() {
    parent::setUp();
    $this
      ->installSchema('system', [
      'key_value',
    ]);
    $this->backends = $this
      ->populateCacheServices();
  }
  public function testKeyValue() {

    // The good thing of this is that besides testing
    // the storage, we also test ALL the cache backend
    // implementations.
    foreach ($this->backends as $backend) {
      $connection = \Drupal\Core\Database\Database::getConnection();
      $factory = $this->container
        ->get($backend);
      $serializer = new \Drupal\Component\Serialization\PhpSerialize();
      $this->factory = new KeyValueChainedFactory($factory, $serializer, $connection);

      // Call the real test.
      parent::testKeyValue();
    }
  }
  public function tearDown() {
  }

}

Classes

Namesort descending Description
ChainedStorageTests Test this on top of different combinations of cache backends.