Fix: write() after clearGroup() does not actually write to file

Although clearGroup() does not use $this->_File, it needs to be null-ed
so that subsequent write() call do not see stale object.
This commit is contained in:
Rachman Chavik 2013-04-26 13:07:44 +07:00
parent 3c036e9ebf
commit 03e5207aa1
2 changed files with 27 additions and 0 deletions

View file

@ -369,6 +369,7 @@ class FileEngine extends CacheEngine {
unlink($object->getPathName());
}
}
$this->_File = null;
return true;
}
}

View file

@ -411,6 +411,32 @@ class FileEngineTest extends CakeTestCase {
$this->assertTrue(Cache::write('test_groups3', 'value3', 'file_groups'));
}
/**
* 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');
}
/**
* Tests that deleting from a groups-enabled config is possible
*