You are here

class AwsCacheAdapterTest in Flysystem - S3 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/AwsCacheAdapterTest.php \NoDrupal\Tests\flysystem_s3\Unit\AwsCacheAdapterTest

@coversDefaultClass \Drupal\flysystem_s3\AwsCacheAdapter @covers \Drupal\flysystem_s3\AwsCacheAdapter @group flysystem_s3

Hierarchy

  • class \NoDrupal\Tests\flysystem_s3\Unit\AwsCacheAdapterTest extends \NoDrupal\Tests\flysystem_s3\Unit\PHPUnit_Framework_TestCase

Expanded class hierarchy of AwsCacheAdapterTest

File

tests/src/Unit/AwsCacheAdapterTest.php, line 13

Namespace

NoDrupal\Tests\flysystem_s3\Unit
View source
class AwsCacheAdapterTest extends \PHPUnit_Framework_TestCase {

  /**
   *
   */
  public function testBasicGetSetDelete() {
    $backend = new MemoryBackend('foo');
    $cache = new AwsCacheAdapter($backend, 'bar_prefix:');
    $cache
      ->set('key', 'value');
    $this
      ->assertSame('value', $cache
      ->get('key'));
    $backend_item = $backend
      ->get('bar_prefix:key');
    $this
      ->assertSame('value', $backend_item->data);
    $this
      ->assertSame(-1, $backend_item->expire);
    $cache
      ->remove('key');
    $this
      ->assertNull($cache
      ->get('key'));
    $this
      ->assertFalse($backend
      ->get('bar_prefix:key'));
  }

  /**
   *
   */
  public function testTtlIsSet() {
    $backend = new MemoryBackend('foo');
    $cache = new AwsCacheAdapter($backend);
    $cache
      ->set('key', 'value', 10);

    // This should work unles the system running the test is extremely slow.
    $expires = time() + 10;
    $this
      ->assertSame('value', $cache
      ->get('key'));
    $backend_item = $backend
      ->get('key');
    $this
      ->assertSame($expires, $backend_item->expire);
  }

}

Members