function test_dirty_cache_when_deleting_deep() { // query() should return 1 always; it does not get called when dbupdate() does not consider the cache to be dirty. $this->MockDB->returns('query', 1); $s = new AbstractSettings('T_test', array('key1', 'key2', 'key3'), 'val', 0); $this->assertTrue($s->set(1, 2, 3, 'value')); $this->assertEqual($s->get(1, 2, 3), 'value'); $this->assertTrue($s->dbupdate()); $this->assertFalse($s->dbupdate()); $this->assertTrue($s->delete(1, 2, 3)); $this->MockDB->expect('query', array("DELETE FROM T_test WHERE (`key1` = '1' AND `key2` = '2' AND `key3` = '3')")); $this->assertTrue($s->dbupdate()); }
/** * Log a creating of new item (Increase counter in global cache) * * @param string Source of item creation ( 'through_admin', 'through_xmlrpc', 'through_email' ) */ function log_new_item_create($created_through) { /** * @var AbstractSettings */ global $global_Cache; if (empty($global_Cache)) { // Init global cache if it is not defined (for example, during on install process) $global_Cache = new AbstractSettings('T_global__cache', array('cach_name'), 'cach_cache', 0); } if (!in_array($created_through, array('through_admin', 'through_xmlrpc', 'through_email'))) { // Set default value if source is wrong $created_through = 'through_admin'; } // Set variable name for current post counter $cache_var_name = 'post_' . $created_through; // Get previuos counter value $counter = (int) $global_Cache->get($cache_var_name); // Increase counter $global_Cache->set($cache_var_name, $counter + 1); // Update the changed data in global cache $global_Cache->dbupdate(); }
/** * Update the DB based on previously recorded changes * * @param integer Group ID */ function dbupdate($grp_ID) { if (!empty($this->_permissions)) { // Set temporary permissions. It is only for the new creating group foreach ($this->_permissions as $name => $value) { $this->set($name, $value, $grp_ID); } $this->_permissions = array(); } // Update permissions return parent::dbupdate(); }