ApcuBackendUnitTest.php in Zircon Profile 8
File
core/modules/system/src/Tests/Cache/ApcuBackendUnitTest.php
View source
<?php
namespace Drupal\system\Tests\Cache;
use Drupal\Core\Cache\ApcuBackend;
class ApcuBackendUnitTest extends GenericCacheBackendUnitTestBase {
protected function getRequirements() {
$requirements = [];
if (!extension_loaded('apc')) {
$requirements[] = 'APC extension not found.';
}
else {
if (version_compare(phpversion('apc'), '3.1.1', '<')) {
$requirements[] = 'APC extension must be newer than 3.1.1 for APCIterator support.';
}
if (PHP_SAPI === 'cli' && !ini_get('apc.enable_cli')) {
$requirements[] = 'apc.enable_cli must be enabled to run this test.';
}
}
return $requirements;
}
protected function requirementsFail() {
$requirements = $this
->getRequirements();
if (!empty($requirements)) {
foreach ($requirements as $message) {
$this
->pass($message);
}
return TRUE;
}
return FALSE;
}
protected function createCacheBackend($bin) {
return new ApcuBackend($bin, $this->databasePrefix, \Drupal::service('cache_tags.invalidator.checksum'));
}
protected function tearDown() {
foreach ($this->cachebackends as $bin => $cachebackend) {
$this->cachebackends[$bin]
->removeBin();
}
parent::tearDown();
}
public function testSetGet() {
if ($this
->requirementsFail()) {
return;
}
parent::testSetGet();
$backend = $this
->getCacheBackend($this
->getTestBin());
$key = $backend
->getApcuKey('TEST8');
foreach (new \APCIterator('user', '/^' . $key . '/') as $item) {
$this
->assertEqual(0, $item['ttl']);
$found = TRUE;
}
$this
->assertTrue($found);
}
public function testDelete() {
if ($this
->requirementsFail()) {
return;
}
parent::testDelete();
}
public function testValueTypeIsKept() {
if ($this
->requirementsFail()) {
return;
}
parent::testValueTypeIsKept();
}
public function testGetMultiple() {
if ($this
->requirementsFail()) {
return;
}
parent::testGetMultiple();
}
public function testSetMultiple() {
if ($this
->requirementsFail()) {
return;
}
parent::testSetMultiple();
}
public function testDeleteMultiple() {
if ($this
->requirementsFail()) {
return;
}
parent::testDeleteMultiple();
}
public function testDeleteAll() {
if ($this
->requirementsFail()) {
return;
}
parent::testDeleteAll();
}
public function testInvalidate() {
if ($this
->requirementsFail()) {
return;
}
parent::testInvalidate();
}
public function testInvalidateTags() {
if ($this
->requirementsFail()) {
return;
}
parent::testInvalidateTags();
}
public function testInvalidateAll() {
if ($this
->requirementsFail()) {
return;
}
parent::testInvalidateAll();
}
public function testRemoveBin() {
if ($this
->requirementsFail()) {
return;
}
parent::testRemoveBin();
}
}