/** * tearDown method * * @return void */ public function tearDown() { parent::tearDown(); Configure::write('Cache.disable', $this->_cacheDisable); Cache::drop('xcache'); Cache::drop('xcache_groups'); Cache::config('default'); }
/** * tearDown method * * @return void */ public function tearDown() { Configure::write('Cache.disable', $this->_cacheDisable); Cache::drop(''); Cache::drop('redis_groups'); Cache::drop('redis_helper'); Cache::config('default'); }
/** * tearDown method * * @return void */ public function endTest($method) { Cache::clear(false, 'database_test'); Configure::write('Cache.disable', $this->_cacheDisable); Cache::drop('database_test'); Cache::config('default'); parent::endTest($method); }
/** * end a test * * @return void **/ function tearDown() { parent::tearDown(); unset($this->Helper); Cache::delete(AssetConfig::CACHE_BUILD_TIME_KEY, AssetConfig::CACHE_CONFIG); Cache::drop(AssetConfig::CACHE_CONFIG); @unlink(TMP . AssetConfig::BUILD_TIME_FILE); }
public function tearDown() { SlugCache::clear(); SlugCache::config($this->slugCache); Configure::write('Cache.disable', $this->disabled); Cache::drop('SluggerTest'); parent::tearDown(); }
function setUp() { Cache::drop(AssetConfig::CACHE_CONFIG); Cache::config(AssetConfig::CACHE_CONFIG, array('engine' => 'File')); $this->_pluginPath = App::pluginPath('AssetCompress'); $this->testConfig = $this->_pluginPath . 'tests' . DS . 'test_files' . DS . 'config' . DS . 'config.ini'; AssetConfig::clearAllCachedKeys(); $this->config = AssetConfig::buildFromIniFile($this->testConfig); }
public function setUp() { parent::setUp(); $this->_config = Configure::read(); Configure::write('Config.language', 'ja'); Cache::drop('_cake_core_'); I18n::clear(); App::build(array('locales' => array(App::pluginPath('YamlReader') . 'Test' . DS . 'files' . DS . 'Locale' . DS)), true); }
/** * end a test * * @return void */ public function tearDown() { parent::tearDown(); unset($this->Helper); Cache::delete(AssetConfig::CACHE_BUILD_TIME_KEY, AssetConfig::CACHE_CONFIG); Cache::drop(AssetConfig::CACHE_CONFIG); // @codingStandardsIgnoreStart @unlink(TMP . AssetConfig::BUILD_TIME_FILE); // @codingStandardsIgnoreEnd }
public function setUp() { parent::setUp(); Cache::drop(AssetConfig::CACHE_CONFIG); Cache::config(AssetConfig::CACHE_CONFIG, array('engine' => 'File')); $this->_pluginPath = App::pluginPath('AssetCompress'); $this->_testFiles = App::pluginPath('AssetCompress') . 'Test' . DS . 'test_files' . DS; $this->testConfig = $this->_testFiles . 'Config' . DS . 'config.ini'; $this->_themeConfig = $this->_testFiles . 'Config' . DS . 'themed.ini'; AssetConfig::clearAllCachedKeys(); $this->config = AssetConfig::buildFromIniFile($this->testConfig); }
public function onLogin() { $hash = md5($this->id . ' ' . time() . ' ' . rand(1, 1000)); $query = 'INSERT INTO `users_session` SET `user_id`=' . $this->id . ', `session`=\'' . $hash . '\', `expires`=' . (time() + Config::need('auth_cookie_lifetime')) . ' ON DUPLICATE KEY UPDATE `session`=\'' . $hash . '\', `expires`=' . (time() + Config::need('auth_cookie_lifetime')); Database::query($query); Cache::drop('auth_' . $this->id); $this->setProperty('lastLogin', time()); $this->setAuthCookie($hash); }
function write() { global $current_user; /* @var $current_user CurrentUser */ if ($current_user->authorized) { $mask = array('id' => 'int', 'bday' => 'string', 'city_id' => 'int', 'link_fb' => array('type' => 'string', '*' => true), 'link_vk' => array('type' => 'string', '*' => true), 'link_lj' => array('type' => 'string', '*' => true), 'link_tw' => array('type' => 'string', '*' => true), 'quote' => array('type' => 'string', '*' => true), 'about' => array('type' => 'string', '*' => true)); $params = Request::checkPostParameters($mask); if ($current_user->id == $params['id']) { //avatar if (isset($_FILES['picture']) && $_FILES['picture']['tmp_name']) { $filename = Config::need('avatar_upload_path') . '/' . $current_user->id . '.jpg'; $upload = new UploadAvatar($_FILES['picture']['tmp_name'], 100, 100, "simple", $filename); if ($upload->out) { $current_user->setProperty('picture', 1); } else { throw new Exception('cant copy file to ' . $filename, 100); } } //bday $current_user->setProperty('bday', max(0, (int) @strtotime($params['bday']))); // city $current_user->setProperty('city_id', $params['city_id']); // facebook etc $current_user->setPropertySerialized('link_fb', $params['link_fb']); $current_user->setPropertySerialized('link_vk', $params['link_vk']); $current_user->setPropertySerialized('link_tw', $params['link_tw']); $current_user->setPropertySerialized('link_lj', $params['link_lj']); $params['quote'] = htmlspecialchars($params['quote']); $params['about'] = htmlspecialchars($params['about']); $current_user->setPropertySerialized('quote', $params['quote']); $current_user->setPropertySerialized('about', $params['about']); $current_user->save(); // после редактирования профиля надо посбрасывать кеш со страницы профиля // и со страницы редактирования профиля // кеш в остальных модулях истечет сам Cache::drop(Request::$pageName . '_ProfileModule_' . $current_user->id, Cache::DATA_TYPE_XML); //xmlthemeDefault_ru_user_ProfileModule Cache::drop(Request::$pageName . '_ProfileModule_' . $current_user->id . 'edit', Cache::DATA_TYPE_XML); //xmlthemeDefault_ru_user_ProfileModule_19 } } }
/** * test that drop removes cache configs, and that further attempts to use that config * do not work. * * @return void */ function testDrop() { App::build(array('libs' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'libs' . DS), 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)), true); $result = Cache::drop('some_config_that_does_not_exist'); $this->assertFalse($result); $_testsConfig = Cache::config('tests'); $result = Cache::drop('tests'); $this->assertTrue($result); Cache::config('unconfigTest', array('engine' => 'TestAppCache')); $this->assertTrue(Cache::isInitialized('unconfigTest')); $this->assertTrue(Cache::drop('unconfigTest')); $this->assertFalse(Cache::isInitialized('TestAppCache')); Cache::config('tests', $_testsConfig); App::build(); }
public function dropCache($id) { Cache::drop($this->itemName . '_' . $id); unset($this->items[$id]); }
/** * Testing the mask setting in FileEngine * * @return void */ public function testMaskSetting() { if (DS === '\\') { $this->markTestSkipped('File permission testing does not work on Windows.'); } Cache::config('mask_test', array('engine' => 'File', 'path' => TMP . 'tests')); $data = 'This is some test content'; $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0664'; $this->assertEquals($expected, $result); Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); Cache::config('mask_test', array('engine' => 'File', 'mask' => 0666, 'path' => TMP . 'tests')); $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0666'; $this->assertEquals($expected, $result); Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); Cache::config('mask_test', array('engine' => 'File', 'mask' => 0644, 'path' => TMP . 'tests')); $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0644'; $this->assertEquals($expected, $result); Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); Cache::config('mask_test', array('engine' => 'File', 'mask' => 0640, 'path' => TMP . 'tests')); $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0640'; $this->assertEquals($expected, $result); Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); }
/** * testSettings method * * @access public * @return void */ function testMultipleServers() { $servers = array('127.0.0.1:11211', '127.0.0.1:11222'); $available = true; $Memcache =& new Memcache(); foreach ($servers as $server) { list($host, $port) = explode(':', $server); if (!@$Memcache->connect($host, $port)) { $available = false; } } if ($this->skipIf(!$available, '%s Need memcache servers at ' . implode(', ', $servers) . ' to run this test')) { return; } $Memcache =& new MemcacheEngine(); $Memcache->init(array('engine' => 'Memcache', 'servers' => $servers)); $servers = array_keys($Memcache->__Memcache->getExtendedStats()); $settings = $Memcache->settings(); $this->assertEqual($servers, $settings['servers']); Cache::drop('dual_server'); }
/** * Test that clearing with repeat writes works properly */ public function testClearingWithRepeatWrites() { Cache::config('repeat', array('engine' => 'File', 'groups' => array('users'))); $this->assertTrue(Cache::write('user', 'rchavik', 'repeat')); $this->assertEquals('rchavik', Cache::read('user', 'repeat')); Cache::delete('user', 'repeat'); $this->assertEquals(false, Cache::read('user', 'repeat')); $this->assertTrue(Cache::write('user', 'ADmad', 'repeat')); $this->assertEquals('ADmad', Cache::read('user', 'repeat')); Cache::clearGroup('users', 'repeat'); $this->assertEquals(false, Cache::read('user', 'repeat')); $this->assertTrue(Cache::write('user', 'markstory', 'repeat')); $this->assertEquals('markstory', Cache::read('user', 'repeat')); Cache::drop('repeat'); }
function testUseDifferentCacheEngine() { $this->skipIf(!class_exists('Memcache'), 'Memcache is not installed, skipping test'); Cache::config('cacherMemcache', array('duration' => '+1 days', 'engine' => 'Memcache', 'prefix' => Inflector::slug(APP_DIR) . '_cacher_test_')); $this->CacheData->Behaviors->attach('Cacher.Cache', array('config' => 'cacherMemcache', 'clearOnDelete' => false)); $results = $this->CacheData->find('all', array('conditions' => array('CacheData.name LIKE' => '%cache%'))); $results = Set::extract('/CacheData/name', $results); $expected = array('A Cached Thing', 'Cache behavior'); $this->assertEquals($results, $expected); // test that it's pulling from the cache $this->CacheData->delete(1); $results = $this->CacheData->find('all', array('conditions' => array('CacheData.name LIKE' => '%cache%'))); $results = Set::extract('/CacheData/name', $results); $expected = array('A Cached Thing', 'Cache behavior'); $this->assertEquals($results, $expected); $ds = ConnectionManager::getDataSource('cacher'); $this->assertEquals($ds->config['config'], 'cacherMemcache'); $map = Cache::read('map', 'cacherMemcache'); $this->assertTrue($map !== false); $this->assertTrue(isset($map[$ds->source->configKeyName][$this->CacheData->alias][0])); $cache = Cache::read($map[$ds->source->configKeyName][$this->CacheData->alias][0], 'cacherMemcache'); $this->assertTrue($cache !== false); $this->CacheData->clearCache(); $map = Cache::read('map', 'cacherMemcache'); $this->assertTrue(empty($map[$ds->source->configKeyName][$this->CacheData->alias])); Cache::drop('cacherMemcache'); }
function testCacheDisable() { Cache::drop('config'); Configure::write('Cache.disable', true); $this->dataSource->__construct(); }
protected function dropCache() { $i = 0; $params = Request::getAllParameters(); while ($i < count($params)) { $i++; $name = Request::$pageName . '_' . $this->moduleName . '_' . implode('', array_slice($params, 0, $i)); Cache::drop($name, Cache::DATA_TYPE_XML); } }
/** * testRemoveWindowsSlashesFromCache method * * @access public * @return void */ function testRemoveWindowsSlashesFromCache() { Cache::config('windows_test', array('engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP)); $expected = array('C:\\dev\\prj2\\sites\\cake\\libs' => array(0 => 'C:\\dev\\prj2\\sites\\cake\\libs', 1 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view', 2 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\scaffolds', 3 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\pages', 4 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\layouts', 5 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\layouts\\xml', 6 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\layouts\\rss', 7 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\layouts\\js', 8 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\layouts\\email', 9 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\layouts\\email\\text', 10 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\layouts\\email\\html', 11 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\helpers', 12 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\errors', 13 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\elements', 14 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\elements\\email', 15 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\elements\\email\\text', 16 => 'C:\\dev\\prj2\\sites\\cake\\libs\\view\\elements\\email\\html', 17 => 'C:\\dev\\prj2\\sites\\cake\\libs\\model', 18 => 'C:\\dev\\prj2\\sites\\cake\\libs\\model\\datasources', 19 => 'C:\\dev\\prj2\\sites\\cake\\libs\\model\\datasources\\dbo', 20 => 'C:\\dev\\prj2\\sites\\cake\\libs\\model\\behaviors', 21 => 'C:\\dev\\prj2\\sites\\cake\\libs\\controller', 22 => 'C:\\dev\\prj2\\sites\\cake\\libs\\controller\\components', 23 => 'C:\\dev\\prj2\\sites\\cake\\libs\\cache'), 'C:\\dev\\prj2\\sites\\main_site\\vendors' => array(0 => 'C:\\dev\\prj2\\sites\\main_site\\vendors', 1 => 'C:\\dev\\prj2\\sites\\main_site\\vendors\\shells', 2 => 'C:\\dev\\prj2\\sites\\main_site\\vendors\\shells\\templates', 3 => 'C:\\dev\\prj2\\sites\\main_site\\vendors\\shells\\templates\\cdc_project', 4 => 'C:\\dev\\prj2\\sites\\main_site\\vendors\\shells\\tasks', 5 => 'C:\\dev\\prj2\\sites\\main_site\\vendors\\js', 6 => 'C:\\dev\\prj2\\sites\\main_site\\vendors\\css'), 'C:\\dev\\prj2\\sites\\vendors' => array(0 => 'C:\\dev\\prj2\\sites\\vendors', 1 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest', 2 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest\\test', 3 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest\\test\\support', 4 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest\\test\\support\\collector', 5 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest\\extensions', 6 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest\\extensions\\testdox', 7 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest\\docs', 8 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest\\docs\\fr', 9 => 'C:\\dev\\prj2\\sites\\vendors\\simpletest\\docs\\en'), 'C:\\dev\\prj2\\sites\\main_site\\views\\helpers' => array(0 => 'C:\\dev\\prj2\\sites\\main_site\\views\\helpers')); Cache::write('test_dir_map', $expected, 'windows_test'); $data = Cache::read('test_dir_map', 'windows_test'); Cache::delete('test_dir_map', 'windows_test'); $this->assertEqual($expected, $data); Cache::drop('windows_test'); }
/** * check that FileEngine generates an error when a configured Path does not exist. * * @return void */ function testErrorWhenPathDoesNotExist() { if ($this->skipIf(is_dir(TMP . 'tests' . DS . 'file_failure'), 'Cannot run test directory exists. %s')) { return; } $this->expectError(); Cache::config('failure', array( 'engine' => 'File', 'path' => TMP . 'tests' . DS . 'file_failure' )); Cache::drop('failure'); }
/** * tearDown method * * @return void */ public function tearDown() { Configure::write('Cache.disable', $this->_cacheDisable); Cache::drop('apc'); Cache::config('default'); }
/** * Test that failed writes cause errors to be triggered. * * @return void */ public function testWriteTriggerError() { App::build(array('libs' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS), 'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), true); Cache::config('test_trigger', array('engine' => 'TestAppCache', 'prefix' => '')); try { Cache::write('fail', 'value', 'test_trigger'); $this->fail('No exception thrown'); } catch (PHPUnit_Framework_Error $e) { $this->assertTrue(true); } Cache::drop('test_trigger'); App::build(); }
public static function dropCache($id) { Cache::drop('user_' . $id); }
/** * testSettings method * * @return void */ public function testMultipleServers() { $servers = array('127.0.0.1:11211', '127.0.0.1:11222'); $available = true; $Memcache = new Memcache(); foreach ($servers as $server) { list($host, $port) = explode(':', $server); //@codingStandardsIgnoreStart if (!@$Memcache->connect($host, $port)) { $available = false; } //@codingStandardsIgnoreEnd } $this->skipIf(!$available, 'Need memcache servers at ' . implode(', ', $servers) . ' to run this test.'); $Memcache = new MemcacheEngine(); $Memcache->init(array('engine' => 'Memcache', 'servers' => $servers)); $settings = $Memcache->settings(); $this->assertEquals($settings['servers'], $servers); Cache::drop('dual_server'); }
/** * testMultiDatabaseOperations method * * @return void */ public function testMultiDatabaseOperations() { Cache::config('redisdb0', array('engine' => 'Redis', 'prefix' => 'cake2_', 'duration' => 3600, 'persistent' => FALSE)); Cache::config('redisdb1', array('engine' => 'Redis', 'database' => 1, 'prefix' => 'cake2_', 'duration' => 3600, 'persistent' => FALSE)); $result = Cache::write('save_in_0', TRUE, 'redisdb0'); $exist = Cache::read('save_in_0', 'redisdb0'); $this->assertTrue($result); $this->assertTrue($exist); $result = Cache::write('save_in_1', TRUE, 'redisdb1'); $this->assertTrue($result); $exist = Cache::read('save_in_0', 'redisdb1'); $this->assertFalse($exist); $exist = Cache::read('save_in_1', 'redisdb1'); $this->assertTrue($exist); Cache::delete('save_in_0', 'redisdb0'); $exist = Cache::read('save_in_0', 'redisdb0'); $this->assertFalse($exist); Cache::delete('save_in_1', 'redisdb1'); $exist = Cache::read('save_in_1', 'redisdb1'); $this->assertFalse($exist); Cache::drop('redisdb0'); Cache::drop('redisdb1'); }
/** * cleanup after test case. * * @return void */ public static function teardownAfterClass() { Cache::clear(false, 'session_test'); Cache::drop('session_test'); Configure::write('Session', self::$_sessionBackup); }
/** * Testing the mask setting in FileEngine * * @return void */ public function testMaskSetting() { Cache::config('mask_test', array('engine' => 'File', 'path' => TMP . 'tests')); $data = 'This is some test content'; $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0664'; $this->assertEquals($result, $expected); Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); Cache::config('mask_test', array('engine' => 'File', 'mask' => 0666, 'path' => TMP . 'tests')); $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0666'; $this->assertEquals($result, $expected); Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); Cache::config('mask_test', array('engine' => 'File', 'mask' => 0644, 'path' => TMP . 'tests')); $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0644'; $this->assertEquals($result, $expected); Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); Cache::config('mask_test', array('engine' => 'File', 'mask' => 0640, 'path' => TMP . 'tests')); $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0640'; $this->assertEquals($result, $expected); Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); }
/** * Test elementCache method * * @return void */ public function testElementCache() { Cache::drop('test_view'); Cache::config('test_view', array('engine' => 'File', 'duration' => '+1 day', 'path' => CACHE . 'views' . DS, 'prefix' => '')); Cache::clear(true, 'test_view'); $View = new TestView($this->PostsController); $View->elementCache = 'test_view'; $result = $View->element('test_element', array(), array('cache' => true)); $expected = 'this is the test element'; $this->assertEquals($expected, $result); $result = Cache::read('element__test_element_cache_callbacks', 'test_view'); $this->assertEquals($expected, $result); $result = $View->element('test_element', array('param' => 'one', 'foo' => 'two'), array('cache' => true)); $this->assertEquals($expected, $result); $result = Cache::read('element__test_element_cache_callbacks_param_foo', 'test_view'); $this->assertEquals($expected, $result); $View->element('test_element', array('param' => 'one', 'foo' => 'two'), array('cache' => array('key' => 'custom_key'))); $result = Cache::read('element_custom_key', 'test_view'); $this->assertEquals($expected, $result); $View->elementCache = 'default'; $View->element('test_element', array('param' => 'one', 'foo' => 'two'), array('cache' => array('config' => 'test_view'))); $result = Cache::read('element__test_element_cache_callbacks_param_foo', 'test_view'); $this->assertEquals($expected, $result); Cache::clear(true, 'test_view'); Cache::drop('test_view'); }
/** * нужен ли кеш для хранения xml модуля? * * @return boolean да или нет */ protected function checkCacheSettings() { if (isset($this->params['cache']) && $this->params['cache']) { $this->xml_cache_name = Request::getModuleUniqueHash($this->moduleName, $this->action, $this->mode, $this->params); if (Request::post('writemodule')) { // erasing cache if any write actions Cache::drop($this->xml_cache_name, Cache::DATA_TYPE_XML); $this->cache_enabled = false; } else { $this->cache_enabled = true; } } return $this->cache_enabled; }