Example #1
0
 /**
  * @covers Veles\Cache\Cache::getAdapter
  * @depends testSetAdapter
  */
 public function testGetAdapter()
 {
     Cache::setAdapter(MemcacheAdapter::instance());
     $result = Cache::getAdapter();
     $this->assertTrue($result instanceof MemcacheAdapter);
     Cache::setAdapter(MemcachedAdapter::instance());
     $result = Cache::getAdapter();
     $this->assertTrue($result instanceof MemcachedAdapter);
 }
 /**
  * @covers Veles\Cache\Adapters\MemcacheAdapter::delByTemplate
  */
 public function testDelByTemplate()
 {
     $key = uniqid('VELES::UNIT-TEST::DEL-BY-TPL::');
     $value = mt_rand(1, 1000);
     Cache::set($key, $value, 10);
     $result = $this->object->delByTemplate('VELES::UNIT-TEST::DEL-BY-TPL::');
     $msg = 'Memcache::delByTemplate() return wrong result!';
     $this->assertSame(true, $result, $msg);
     $result = $this->object->has($key);
     $msg = 'Key was not deleted by template!';
     $this->assertSame(false, $result, $msg);
     MemcacheRaw::setConnectionParams('localhost', 11213);
     $result = $this->object->delByTemplate('EnyKey');
     $msg = 'Wrong MemcacheAdapter::delByTemplate() behavior!';
     $this->assertSame(false, $result, $msg);
 }
 private function initCache()
 {
     MemcachedAdapter::addCall('addServer', ['localhost', 11211]);
     MemcacheAdapter::addCall('addServer', ['localhost', 11211]);
 }
 * @date      Чтв Дек 20 12:22:58 2012
 * @license   The BSD 3-Clause License
 *            <https://tldrlegal.com/license/bsd-3-clause-license-(revised)>
 */
namespace Veles\Tests;

use Veles\AutoLoader;
use Veles\Cache\Adapters\MemcacheAdapter;
use Veles\Cache\Adapters\MemcachedAdapter;
use Veles\Cache\Adapters\MemcacheRaw;
use Veles\Cache\Cache;
use Veles\View\Adapters\NativeAdapter;
use Veles\View\View;
//ini_set('error_reporting', E_ALL);
//ini_set('display_errors', '1');
//ini_set('display_startup_errors', '1');
define('LIB_DIR', realpath(__DIR__ . '/../..'));
define('TEST_DIR', realpath(LIB_DIR . '/Veles/Tests'));
date_default_timezone_set('Europe/Moscow');
require LIB_DIR . '/Veles/AutoLoader.php';
$includes = LIB_DIR . ':' . TEST_DIR . ':' . realpath(__DIR__ . '/Project');
set_include_path(implode(PATH_SEPARATOR, [$includes, get_include_path()]));
AutoLoader::init();
$view_adapter = new NativeAdapter();
$view_adapter->setTemplateDir(TEST_DIR . '/Project/View/');
View::setAdapter($view_adapter);
// Cache initialization
MemcacheRaw::setConnectionParams('localhost', 11211);
MemcachedAdapter::addCall('addServer', ['localhost', 11211]);
MemcacheAdapter::addCall('addServer', ['localhost', 11211]);
Cache::setAdapter(MemcachedAdapter::instance());