class CacheItemBackendTest in Flysystem 2.0.x
Same name and namespace in other branches
- 8 tests/src/Unit/Flysystem/Adapter/CacheItemBackendTest.php \Drupal\Tests\flysystem\Unit\Flysystem\Adapter\CacheItemBackendTest
- 3.x tests/src/Unit/Flysystem/Adapter/CacheItemBackendTest.php \Drupal\Tests\flysystem\Unit\Flysystem\Adapter\CacheItemBackendTest
- 3.0.x tests/src/Unit/Flysystem/Adapter/CacheItemBackendTest.php \Drupal\Tests\flysystem\Unit\Flysystem\Adapter\CacheItemBackendTest
@group flysystem
@coversDefaultClass \Drupal\flysystem\Flysystem\Adapter\CacheItemBackend @covers \Drupal\flysystem\Flysystem\Adapter\CacheItemBackend
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, PhpUnitCompatibilityTrait, PhpUnitWarnings
- class \Drupal\Tests\flysystem\Unit\Flysystem\Adapter\CacheItemBackendTest
Expanded class hierarchy of CacheItemBackendTest
File
- tests/
src/ Unit/ Flysystem/ Adapter/ CacheItemBackendTest.php, line 16
Namespace
Drupal\Tests\flysystem\Unit\Flysystem\AdapterView source
class CacheItemBackendTest extends UnitTestCase {
/**
* The cache backend used in the CacheItemBackend.
*
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
protected $cacheBackend;
/**
* The cache item backend to test.
*
* @var \Drupal\flysystem\Flysystem\Adapter\CacheItemBackend
*/
protected $cacheItemBackend;
/**
* {@inheritdoc}
*/
public function setup() {
$this->cacheBackend = new MemoryBackend('foo');
$this->cacheItemBackend = new CacheItemBackend('test-scheme', $this->cacheBackend);
}
/**
* Tests whether a cache item exists.
*/
public function testHas() {
$this
->assertFalse($this->cacheItemBackend
->has('test.txt'));
}
/**
* Tests loading a cache item from the cache.
*/
public function testSetIsLoaded() {
$cache_item = new CacheItem();
$cache_item
->updateMetadata([
'mimetype' => 'test_mimetype',
]);
$this->cacheItemBackend
->set('test_path', $cache_item);
$metadata = $this->cacheItemBackend
->load('test_path')
->getMetadata();
$this
->assertSame('test_mimetype', $metadata['mimetype']);
}
/**
* Tests when loading a cache item creates a new item.
*/
public function testLoadMiss() {
$item = $this->cacheItemBackend
->load('test_path');
$this
->assertInstanceOf(CacheItem::class, $item);
}
/**
* Tests deleting by a path.
*/
public function testDelete() {
$cache_item = new CacheItem();
$cache_item
->updateMetadata([
'mimetype' => 'test_mimetype',
]);
$this->cacheItemBackend
->set('test_path', $cache_item);
$this->cacheItemBackend
->delete('test_path');
$metadata = $this->cacheItemBackend
->load('test_path')
->getMetadata();
$this
->assertTrue(empty($metadata['mimetype']));
}
/**
* Tests deleting multiple items at once.
*/
public function testDeleteMultiple() {
$cache_item_one = new CacheItem();
$cache_item_two = new CacheItem();
$this->cacheItemBackend
->set('one', $cache_item_one);
$this->cacheItemBackend
->set('two', $cache_item_two);
$this->cacheItemBackend
->deleteMultiple([
'one',
'two',
]);
$this
->assertNotSame($cache_item_one, $this->cacheItemBackend
->load('one'));
$this
->assertNotSame($cache_item_two, $this->cacheItemBackend
->load('two'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheItemBackendTest:: |
protected | property | The cache backend used in the CacheItemBackend. | |
CacheItemBackendTest:: |
protected | property | The cache item backend to test. | |
CacheItemBackendTest:: |
public | function | ||
CacheItemBackendTest:: |
public | function | Tests deleting by a path. | |
CacheItemBackendTest:: |
public | function | Tests deleting multiple items at once. | |
CacheItemBackendTest:: |
public | function | Tests whether a cache item exists. | |
CacheItemBackendTest:: |
public | function | Tests when loading a cache item creates a new item. | |
CacheItemBackendTest:: |
public | function | Tests loading a cache item from the cache. | |
PhpUnitWarnings:: |
private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |
PhpUnitWarnings:: |
public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 308 | |
UnitTestCase:: |
public static | function |