/** * test that clear() doesn't wipe files not in the current engine's prefix. * * @return void */ public function testClearWithPrefixes() { $FileOne = new FileEngine(); $FileOne->init(array('prefix' => 'prefix_one_', 'duration' => DAY)); $FileTwo = new FileEngine(); $FileTwo->init(array('prefix' => 'prefix_two_', 'duration' => DAY)); $data1 = $data2 = $expected = 'content to cache'; $FileOne->write('prefix_one_key_one', $data1, DAY); $FileTwo->write('prefix_two_key_two', $data2, DAY); $this->assertEquals($FileOne->read('prefix_one_key_one'), $expected); $this->assertEquals($FileTwo->read('prefix_two_key_two'), $expected); $FileOne->clear(false); $this->assertEquals($FileTwo->read('prefix_two_key_two'), $expected, 'secondary config was cleared by accident.'); $FileTwo->clear(false); }
/** * Test that clear() also removes files with group tags. * * @return void */ public function testClearWithGroups() { $engine = new FileEngine(); $engine->init(array('prefix' => 'cake_test_', 'duration' => DAY, 'groups' => array('short', 'round'))); $key = 'cake_test_test_key'; $engine->write($key, 'it works', DAY); $engine->clear(false); $this->assertFalse($engine->read($key), 'Key should have been removed'); }