/**
  * Teardown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Cache::drop('orm_cache');
     $ds = ConnectionManager::get('test');
     $ds->cacheMetadata(false);
 }
Beispiel #2
0
 /**
  * tearDown
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Cache::clear(false, 'session_test');
     Cache::drop('session_test');
     unset($this->storage);
 }
Beispiel #3
0
 /**
  * Tear down data.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Plugin::unload($this->plugin);
     Cache::drop('permissions');
     Cache::drop('permission_roles');
     unset($this->Roles, $this->Users, $this->userData);
 }
Beispiel #4
0
 /**
  * Tear down.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->_controller, $this->url, $this->data);
     Plugin::unload($this->plugin);
     Plugin::unload('Union/Extensions');
     Cache::drop('permissions');
     Cache::drop('permission_roles');
     Cache::drop('plugins');
 }
 /**
  * Called before the controller action. You can use this method to configure and customize components
  * or perform logic that needs to happen before each controller action.
  *
  * @param Event $event An Event instance
  * @return void
  * @link http://book.cakephp.org/3.0/en/controllers.html#request-life-cycle-callbacks
  */
 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     // TODO: Change the autogenerated stub
     if ($this->request->data) {
         Cache::drop('settingsFrontend');
         Cache::drop('menuParents');
         Cache::drop('subMenu');
     }
 }
 /**
  * CacheStorage constructor.
  * @param array $config initial configuration
  */
 public function __construct(array $config)
 {
     $this->config($config);
     $_config = $this->config();
     $_configName = $_config['cacheConfig'];
     unset($_config['cacheConfig']);
     if (Cache::config($_configName)) {
         Cache::drop($_configName);
     }
     Cache::config($_configName, $_config);
 }
Beispiel #7
0
 /**
  * Initialize - install cache spies.
  *
  * @return void
  */
 public function initialize()
 {
     foreach (Cache::configured() as $name) {
         $config = Cache::config($name);
         if ($config['className'] instanceof DebugEngine) {
             $instance = $config['className'];
         } else {
             Cache::drop($name);
             $instance = new DebugEngine($config);
             Cache::config($name, $instance);
         }
         $this->_instances[$name] = $instance;
     }
 }
Beispiel #8
0
 /**
  * test that store and restore only store/restore the provided data.
  *
  * @return void
  */
 public function testStoreAndRestoreWithData()
 {
     Cache::enable();
     Cache::config('configure', ['className' => 'File', 'path' => TMP . 'tests']);
     Configure::write('testing', 'value');
     Configure::store('store_test', 'configure', ['store_test' => 'one']);
     Configure::delete('testing');
     $this->assertNull(Configure::read('store_test'), 'Calling store with data shouldn\'t modify runtime.');
     Configure::restore('store_test', 'configure');
     $this->assertEquals('one', Configure::read('store_test'));
     $this->assertNull(Configure::read('testing'), 'Values that were not stored are not restored.');
     Cache::delete('store_test', 'configure');
     Cache::drop('configure');
 }
 /**
  * Test that clearing with repeat writes works properly
  *
  * @return void
  */
 public function testClearingWithRepeatWrites()
 {
     Cache::config('repeat', ['engine' => 'File', 'groups' => ['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');
 }
Beispiel #10
0
 /**
  * Test elementCache method
  *
  * @return void
  */
 public function testElementCache()
 {
     Cache::drop('test_view');
     Cache::config('test_view', ['engine' => 'File', 'duration' => '+1 day', 'path' => CACHE . 'views/', 'prefix' => '']);
     Cache::clear(false, 'test_view');
     $View = $this->PostsController->createView();
     $View->elementCache = 'test_view';
     $result = $View->element('test_element', [], ['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', ['param' => 'one', 'foo' => 'two'], ['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', ['param' => 'one', 'foo' => 'two'], ['cache' => ['key' => 'custom_key']]);
     $result = Cache::read('element_custom_key', 'test_view');
     $this->assertEquals($expected, $result);
     $View->elementCache = 'default';
     $View->element('test_element', ['param' => 'one', 'foo' => 'two'], ['cache' => ['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');
 }
Beispiel #11
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Acl);
     Cache::clear(false, 'tests');
     Cache::drop('tests');
 }
 /**
  * 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');
 }
 /**
  * Create the cache config for this component
  *
  * @return void
  */
 protected function _createCacheConfig()
 {
     if ($this->_isCacheEnabled()) {
         $cache = array('duration' => $this->cacheDuration, 'engine' => 'File', 'path' => CACHE);
         if (isset($this->settings['cache'])) {
             $cache = array_merge($cache, $this->settings['cache']);
         }
         Cache::drop('SassComponent');
         Cache::config('SassComponent', $cache);
     }
 }
Beispiel #14
0
 /**
  * Test cached render array config
  *
  * @return void
  */
 public function testCachedRenderArrayConfig()
 {
     $mock = $this->getMock('Cake\\Cache\\CacheEngine');
     $mock->method('init')->will($this->returnValue(true));
     $mock->method('read')->will($this->returnValue(false));
     $mock->expects($this->once())->method('write')->with('my_key', "dummy\n");
     Cache::config('cell', $mock);
     $cell = $this->View->cell('Articles', [], ['cache' => ['key' => 'my_key', 'config' => 'cell']]);
     $result = $cell->render();
     $this->assertEquals("dummy\n", $result);
     Cache::drop('cell');
 }
Beispiel #15
0
 /**
  * Test that failed writes cause errors to be triggered.
  *
  * @return void
  */
 public function testWriteTriggerError()
 {
     Configure::write('App.namespace', 'TestApp');
     Cache::config('test_trigger', ['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');
 }
Beispiel #16
0
    define('MEYOUTUBE', 'MeYoutube');
}
/**
 * Loads the MeYoutube configuration
 */
Configure::load(sprintf('%s.me_youtube', MEYOUTUBE));
//Merges with the configuration from application, if exists
if (is_readable(CONFIG . 'me_youtube.php')) {
    Configure::load('me_youtube');
}
//Merges with the MeCms configuration
Configure::write(MECMS, Hash::merge(config(MECMS), Configure::consume(MEYOUTUBE)));
if (!config('Youtube.key') || config('Youtube.key') === 'your-key-here') {
    throw new InternalErrorException('YouTube API key is missing');
}
/**
 * Loads the cache configuration
 */
Configure::load(sprintf('%s.cache', MEYOUTUBE));
//Merges with the configuration from application, if exists
if (is_readable(CONFIG . 'cache.php')) {
    Configure::load('cache');
}
//Adds all cache configurations
foreach (Configure::consume('Cache') as $key => $config) {
    //Drops cache configurations that already exist
    if (Cache::config($key)) {
        Cache::drop($key);
    }
    Cache::config($key, $config);
}
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Cache::drop('xcache');
     Cache::drop('xcache_groups');
 }
Beispiel #18
0
 /**
  * Teardown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Cache::drop('queryCache');
 }
Beispiel #19
0
 /**
  * Writing cache entries with duration = 0 (forever) should work.
  *
  * @return void
  */
 public function testReadWriteDurationZero()
 {
     Cache::drop('apc');
     Cache::config('apc', ['engine' => 'Apc', 'duration' => 0, 'prefix' => 'cake_']);
     Cache::write('zero', 'Should save', 'apc');
     sleep(1);
     $result = Cache::read('zero', 'apc');
     $this->assertEquals('Should save', $result);
 }
 /**
  * cleanup after test case.
  *
  * @return void
  */
 public static function teardownAfterClass()
 {
     Cache::clear(false, 'session_test');
     Cache::drop('session_test');
     Configure::write('Session', static::$_sessionBackup);
 }
Beispiel #21
0
 /**
  * Test that when the cell cache is enabled, the cell action is only invoke the first
  * time the cell is rendered
  *
  * @return void
  */
 public function testCachedRenderSimpleCustomTemplateViewBuilder()
 {
     Cache::config('default', ['className' => 'File', 'path' => CACHE]);
     $cell = $this->View->cell('Articles::customTemplateViewBuilder', [], ['cache' => ['key' => 'celltest']]);
     $result = $cell->render();
     $this->assertEquals(1, $cell->counter);
     $cell->render();
     $this->assertEquals(1, $cell->counter);
     $this->assertContains('This is the alternate template', $result);
     Cache::delete('celltest');
     Cache::drop('default');
 }
Beispiel #22
0
 /**
  * test clearAll() method
  *
  * @return void
  */
 public function testClearAll()
 {
     Cache::config('configTest', ['engine' => 'File', 'path' => TMP . 'tests']);
     Cache::config('anotherConfigTest', ['engine' => 'File', 'path' => TMP . 'tests']);
     Cache::write('key_1', 'hello', 'configTest');
     Cache::write('key_2', 'hello again', 'anotherConfigTest');
     $this->assertSame(Cache::read('key_1', 'configTest'), 'hello');
     $this->assertSame(Cache::read('key_2', 'anotherConfigTest'), 'hello again');
     $result = Cache::clearAll();
     $this->assertTrue($result['configTest']);
     $this->assertTrue($result['anotherConfigTest']);
     $this->assertFalse(Cache::read('key_1', 'configTest'));
     $this->assertFalse(Cache::read('key_2', 'anotherConfigTest'));
     Cache::drop('configTest');
     Cache::drop('anotherConfigTest');
 }
Beispiel #23
0
 /**
  * Teardown method.
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     Cache::drop('debug_kit_test');
 }
 /**
  * Helper method for testing.
  *
  * @param array $config
  * @return void
  */
 protected function _configCache($config = [])
 {
     $defaults = ['className' => 'Wincache', 'prefix' => 'cake_'];
     Cache::drop('wincache');
     Cache::config('wincache', array_merge($defaults, $config));
 }
 /**
  * testConfig method
  *
  * @return void
  */
 public function testMultipleServers()
 {
     $servers = ['127.0.0.1:11211', '127.0.0.1:11222'];
     $available = true;
     $Memcached = new \Memcached();
     foreach ($servers as $server) {
         list($host, $port) = explode(':', $server);
         //@codingStandardsIgnoreStart
         if (!$Memcached->addServer($host, $port)) {
             $available = false;
         }
         //@codingStandardsIgnoreEnd
     }
     $this->skipIf(!$available, 'Need memcached servers at ' . implode(', ', $servers) . ' to run this test.');
     $Memcached = new MemcachedEngine();
     $Memcached->init(['engine' => 'Memcached', 'servers' => $servers]);
     $config = $Memcached->config();
     $this->assertEquals($config['servers'], $servers);
     Cache::drop('dual_server');
 }
Beispiel #26
0
 /**
  * test that drop removes cache configs, and that further attempts to use that config
  * do not work.
  *
  * @return void
  */
 public function testDrop()
 {
     Configure::write('App.namespace', 'TestApp');
     $result = Cache::drop('some_config_that_does_not_exist');
     $this->assertFalse($result, 'Drop should not succeed when config is missing.');
     Cache::config('unconfigTest', ['engine' => 'TestAppCache']);
     $this->assertInstanceOf('TestApp\\Cache\\Engine\\TestAppCacheEngine', Cache::engine('unconfigTest'));
     $this->assertTrue(Cache::drop('unconfigTest'));
 }