You are here

public function StreamWrapperTest::testCreateCache in AmazonS3 7.2

Test that a Drupal cache adapter is created.

@covers \Drupal\amazons3\StreamWrapper::__construct

File

tests/StreamWrapperTest.php, line 117

Class

StreamWrapperTest
Tests \Drupal\amazons3\StreamWrapper.

Namespace

Drupal\amazons3Test

Code

public function testCreateCache() {
  $config = StreamWrapperConfiguration::fromConfig([
    'bucket' => 'bucket.example.com',
    'region' => 'region',
    'caching' => TRUE,
    'expiration' => 0,
  ]);
  $wrapper = new StreamWrapper($config);
  $reflect = new \ReflectionObject($wrapper);
  $cache = $reflect
    ->getProperty('cache');
  $cache
    ->setAccessible(TRUE);
  try {
    $this
      ->assertInstanceOf('Doctrine\\Common\\Cache\\ChainCache', $cache
      ->getValue()
      ->getCacheObject());
  } catch (\Exception $e) {
  }
  StreamWrapper::detachCache();
  if (isset($e)) {
    throw $e;
  }
}