php-censor/tests/B8Framework/CacheTest.php

39 lines
1 KiB
PHP
Raw Normal View History

2016-04-12 19:31:39 +02:00
<?php
2016-04-17 08:34:12 +02:00
namespace Tests\b8;
2016-04-12 19:31:39 +02:00
2016-04-17 08:34:12 +02:00
use b8\Config, b8\Cache;
2016-04-12 19:31:39 +02:00
class CacheTest extends \PHPUnit\Framework\TestCase
2016-04-12 19:31:39 +02:00
{
2016-04-21 19:06:58 +02:00
public function testCreateSingleton()
{
$cache = Cache::getCache(Cache::TYPE_APC);
self::assertInstanceOf('\b8\Cache\ApcCache', $cache);
2016-04-21 19:06:58 +02:00
}
public function testDisableCaching()
{
$config = new Config();
Config::getInstance()->set('DisableCaching', true);
$cache = Cache::getCache(Cache::TYPE_APC);
$this->assertFalse($cache->isEnabled());
$this->assertFalse($cache->set('anything', 10));
$this->assertTrue(is_null($cache->get('anything')));
Config::getInstance()->set('DisableCaching', false);
}
public function testCaching()
{
$cache = Cache::getCache(Cache::TYPE_APC);
if ($cache->isEnabled()) {
$this->assertTrue($cache->set('anything', 10));
$this->assertTrue($cache->get('anything') == 10);
$this->assertTrue(is_null($cache->get('invalid')));
}
}
2016-04-12 19:31:39 +02:00
}