FileEngineTest.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. <?php
  2. /**
  3. * FileEngineTest file
  4. *
  5. * CakePHP(tm) Tests <http://book.cakephp.org/2.0/en/development/testing.html>
  6. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://book.cakephp.org/2.0/en/development/testing.html CakePHP(tm) Tests
  14. * @package Cake.Test.Case.Cache.Engine
  15. * @since CakePHP(tm) v 1.2.0.5434
  16. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  17. */
  18. App::uses('Cache', 'Cache');
  19. /**
  20. * FileEngineTest class
  21. *
  22. * @package Cake.Test.Case.Cache.Engine
  23. */
  24. class FileEngineTest extends CakeTestCase {
  25. /**
  26. * config property
  27. *
  28. * @var array
  29. */
  30. public $config = array();
  31. /**
  32. * setUp method
  33. *
  34. * @return void
  35. */
  36. public function setUp() {
  37. parent::setUp();
  38. Configure::write('Cache.disable', false);
  39. Cache::config('file_test', array('engine' => 'File', 'path' => CACHE));
  40. }
  41. /**
  42. * tearDown method
  43. *
  44. * @return void
  45. */
  46. public function tearDown() {
  47. parent::tearDown();
  48. // Cache::clear(false, 'file_test');
  49. Cache::drop('file_test');
  50. Cache::drop('file_groups');
  51. Cache::drop('file_groups2');
  52. Cache::drop('file_groups3');
  53. }
  54. /**
  55. * testCacheDirChange method
  56. *
  57. * @return void
  58. */
  59. public function testCacheDirChange() {
  60. $result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions'));
  61. $this->assertEquals(Cache::settings('sessions'), $result['settings']);
  62. $result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'tests'));
  63. $this->assertEquals(Cache::settings('sessions'), $result['settings']);
  64. $this->assertNotEquals(Cache::settings('default'), $result['settings']);
  65. }
  66. /**
  67. * testReadAndWriteCache method
  68. *
  69. * @return void
  70. */
  71. public function testReadAndWriteCache() {
  72. Cache::config('default');
  73. $result = Cache::write(null, 'here', 'file_test');
  74. $this->assertFalse($result);
  75. Cache::set(array('duration' => 1), 'file_test');
  76. $result = Cache::read('test', 'file_test');
  77. $expecting = '';
  78. $this->assertEquals($expecting, $result);
  79. $data = 'this is a test of the emergency broadcasting system';
  80. $result = Cache::write('test', $data, 'file_test');
  81. $this->assertTrue(file_exists(CACHE . 'cake_test'));
  82. $result = Cache::read('test', 'file_test');
  83. $expecting = $data;
  84. $this->assertEquals($expecting, $result);
  85. Cache::delete('test', 'file_test');
  86. }
  87. /**
  88. * Test read/write on the same cache key. Ensures file handles are re-wound.
  89. *
  90. * @return void
  91. */
  92. public function testConsecutiveReadWrite() {
  93. Cache::write('rw', 'first write', 'file_test');
  94. $result = Cache::read('rw', 'file_test');
  95. Cache::write('rw', 'second write', 'file_test');
  96. $resultB = Cache::read('rw', 'file_test');
  97. Cache::delete('rw', 'file_test');
  98. $this->assertEquals('first write', $result);
  99. $this->assertEquals('second write', $resultB);
  100. }
  101. /**
  102. * testExpiry method
  103. *
  104. * @return void
  105. */
  106. public function testExpiry() {
  107. Cache::set(array('duration' => 1), 'file_test');
  108. $result = Cache::read('test', 'file_test');
  109. $this->assertFalse($result);
  110. $data = 'this is a test of the emergency broadcasting system';
  111. $result = Cache::write('other_test', $data, 'file_test');
  112. $this->assertTrue($result);
  113. sleep(2);
  114. $result = Cache::read('other_test', 'file_test');
  115. $this->assertFalse($result);
  116. Cache::set(array('duration' => "+1 second"), 'file_test');
  117. $data = 'this is a test of the emergency broadcasting system';
  118. $result = Cache::write('other_test', $data, 'file_test');
  119. $this->assertTrue($result);
  120. sleep(2);
  121. $result = Cache::read('other_test', 'file_test');
  122. $this->assertFalse($result);
  123. }
  124. /**
  125. * testDeleteCache method
  126. *
  127. * @return void
  128. */
  129. public function testDeleteCache() {
  130. $data = 'this is a test of the emergency broadcasting system';
  131. $result = Cache::write('delete_test', $data, 'file_test');
  132. $this->assertTrue($result);
  133. $result = Cache::delete('delete_test', 'file_test');
  134. $this->assertTrue($result);
  135. $this->assertFalse(file_exists(TMP . 'tests' . DS . 'delete_test'));
  136. $result = Cache::delete('delete_test', 'file_test');
  137. $this->assertFalse($result);
  138. }
  139. /**
  140. * testSerialize method
  141. *
  142. * @return void
  143. */
  144. public function testSerialize() {
  145. Cache::config('file_test', array('engine' => 'File', 'serialize' => true));
  146. $data = 'this is a test of the emergency broadcasting system';
  147. $write = Cache::write('serialize_test', $data, 'file_test');
  148. $this->assertTrue($write);
  149. Cache::config('file_test', array('serialize' => false));
  150. $read = Cache::read('serialize_test', 'file_test');
  151. $newread = Cache::read('serialize_test', 'file_test');
  152. Cache::delete('serialize_test', 'file_test');
  153. $this->assertSame($read, serialize($data));
  154. $this->assertSame(unserialize($newread), $data);
  155. }
  156. /**
  157. * testClear method
  158. *
  159. * @return void
  160. */
  161. public function testClear() {
  162. Cache::config('file_test', array('engine' => 'File', 'duration' => 1));
  163. $data = 'this is a test of the emergency broadcasting system';
  164. Cache::write('serialize_test1', $data, 'file_test');
  165. Cache::write('serialize_test2', $data, 'file_test');
  166. Cache::write('serialize_test3', $data, 'file_test');
  167. $this->assertTrue(file_exists(CACHE . 'cake_serialize_test1'));
  168. $this->assertTrue(file_exists(CACHE . 'cake_serialize_test2'));
  169. $this->assertTrue(file_exists(CACHE . 'cake_serialize_test3'));
  170. sleep(2);
  171. $result = Cache::clear(true, 'file_test');
  172. $this->assertTrue($result);
  173. $this->assertFalse(file_exists(CACHE . 'cake_serialize_test1'));
  174. $this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
  175. $this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
  176. $data = 'this is a test of the emergency broadcasting system';
  177. Cache::write('serialize_test1', $data, 'file_test');
  178. Cache::write('serialize_test2', $data, 'file_test');
  179. Cache::write('serialize_test3', $data, 'file_test');
  180. $this->assertTrue(file_exists(CACHE . 'cake_serialize_test1'));
  181. $this->assertTrue(file_exists(CACHE . 'cake_serialize_test2'));
  182. $this->assertTrue(file_exists(CACHE . 'cake_serialize_test3'));
  183. $result = Cache::clear(false, 'file_test');
  184. $this->assertTrue($result);
  185. $this->assertFalse(file_exists(CACHE . 'cake_serialize_test1'));
  186. $this->assertFalse(file_exists(CACHE . 'cake_serialize_test2'));
  187. $this->assertFalse(file_exists(CACHE . 'cake_serialize_test3'));
  188. }
  189. /**
  190. * test that clear() doesn't wipe files not in the current engine's prefix.
  191. *
  192. * @return void
  193. */
  194. public function testClearWithPrefixes() {
  195. $FileOne = new FileEngine();
  196. $FileOne->init(array(
  197. 'prefix' => 'prefix_one_',
  198. 'duration' => DAY
  199. ));
  200. $FileTwo = new FileEngine();
  201. $FileTwo->init(array(
  202. 'prefix' => 'prefix_two_',
  203. 'duration' => DAY
  204. ));
  205. $dataOne = $dataTwo = $expected = 'content to cache';
  206. $FileOne->write('prefix_one_key_one', $dataOne, DAY);
  207. $FileTwo->write('prefix_two_key_two', $dataTwo, DAY);
  208. $this->assertEquals($expected, $FileOne->read('prefix_one_key_one'));
  209. $this->assertEquals($expected, $FileTwo->read('prefix_two_key_two'));
  210. $FileOne->clear(false);
  211. $this->assertEquals($expected, $FileTwo->read('prefix_two_key_two'), 'secondary config was cleared by accident.');
  212. $FileTwo->clear(false);
  213. }
  214. /**
  215. * Test that clear() also removes files with group tags.
  216. *
  217. * @return void
  218. */
  219. public function testClearWithGroups() {
  220. $engine = new FileEngine();
  221. $engine->init(array(
  222. 'prefix' => 'cake_test_',
  223. 'duration' => DAY,
  224. 'groups' => array('short', 'round')
  225. ));
  226. $key = 'cake_test_test_key';
  227. $engine->write($key, 'it works', DAY);
  228. $engine->clear(false);
  229. $this->assertFalse($engine->read($key), 'Key should have been removed');
  230. }
  231. /**
  232. * Test that clear() also removes files with group tags.
  233. *
  234. * @return void
  235. */
  236. public function testClearWithNoKeys() {
  237. $engine = new FileEngine();
  238. $engine->init(array(
  239. 'prefix' => 'cake_test_',
  240. 'duration' => DAY,
  241. 'groups' => array('one', 'two')
  242. ));
  243. $key = 'cake_test_test_key';
  244. $engine->clear(false);
  245. $this->assertFalse($engine->read($key), 'No errors should be found');
  246. }
  247. /**
  248. * testKeyPath method
  249. *
  250. * @return void
  251. */
  252. public function testKeyPath() {
  253. $result = Cache::write('views.countries.something', 'here', 'file_test');
  254. $this->assertTrue($result);
  255. $this->assertTrue(file_exists(CACHE . 'cake_views_countries_something'));
  256. $result = Cache::read('views.countries.something', 'file_test');
  257. $this->assertEquals('here', $result);
  258. $result = Cache::clear(false, 'file_test');
  259. $this->assertTrue($result);
  260. $result = Cache::write('domain.test.com:8080', 'here', 'file_test');
  261. $this->assertTrue($result);
  262. $this->assertTrue(file_exists(CACHE . 'cake_domain_test_com_8080'));
  263. $result = Cache::write('command>dir|more', 'here', 'file_test');
  264. $this->assertTrue($result);
  265. $this->assertTrue(file_exists(CACHE . 'cake_command_dir_more'));
  266. }
  267. /**
  268. * testRemoveWindowsSlashesFromCache method
  269. *
  270. * @return void
  271. */
  272. public function testRemoveWindowsSlashesFromCache() {
  273. Cache::config('windows_test', array('engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP));
  274. $expected = array(
  275. 'C:\dev\prj2\sites\cake\libs' => array(
  276. 0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view',
  277. 2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages',
  278. 4 => 'C:\dev\prj2\sites\cake\libs\view\layouts', 5 => 'C:\dev\prj2\sites\cake\libs\view\layouts\xml',
  279. 6 => 'C:\dev\prj2\sites\cake\libs\view\layouts\rss', 7 => 'C:\dev\prj2\sites\cake\libs\view\layouts\js',
  280. 8 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email', 9 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\text',
  281. 10 => 'C:\dev\prj2\sites\cake\libs\view\layouts\email\html', 11 => 'C:\dev\prj2\sites\cake\libs\view\helpers',
  282. 12 => 'C:\dev\prj2\sites\cake\libs\view\errors', 13 => 'C:\dev\prj2\sites\cake\libs\view\elements',
  283. 14 => 'C:\dev\prj2\sites\cake\libs\view\elements\email', 15 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\text',
  284. 16 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\html', 17 => 'C:\dev\prj2\sites\cake\libs\model',
  285. 18 => 'C:\dev\prj2\sites\cake\libs\model\datasources', 19 => 'C:\dev\prj2\sites\cake\libs\model\datasources\dbo',
  286. 20 => 'C:\dev\prj2\sites\cake\libs\model\behaviors', 21 => 'C:\dev\prj2\sites\cake\libs\controller',
  287. 22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'),
  288. 'C:\dev\prj2\sites\main_site\vendors' => array(
  289. 0 => 'C:\dev\prj2\sites\main_site\vendors', 1 => 'C:\dev\prj2\sites\main_site\vendors\shells',
  290. 2 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates', 3 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates\cdc_project',
  291. 4 => 'C:\dev\prj2\sites\main_site\vendors\shells\tasks', 5 => 'C:\dev\prj2\sites\main_site\vendors\js',
  292. 6 => 'C:\dev\prj2\sites\main_site\vendors\css'),
  293. 'C:\dev\prj2\sites\vendors' => array(
  294. 0 => 'C:\dev\prj2\sites\vendors', 1 => 'C:\dev\prj2\sites\vendors\simpletest',
  295. 2 => 'C:\dev\prj2\sites\vendors\simpletest\test', 3 => 'C:\dev\prj2\sites\vendors\simpletest\test\support',
  296. 4 => 'C:\dev\prj2\sites\vendors\simpletest\test\support\collector', 5 => 'C:\dev\prj2\sites\vendors\simpletest\extensions',
  297. 6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs',
  298. 8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'),
  299. 'C:\dev\prj2\sites\main_site\views\helpers' => array(
  300. 0 => 'C:\dev\prj2\sites\main_site\views\helpers')
  301. );
  302. Cache::write('test_dir_map', $expected, 'windows_test');
  303. $data = Cache::read('test_dir_map', 'windows_test');
  304. Cache::delete('test_dir_map', 'windows_test');
  305. $this->assertEquals($expected, $data);
  306. Cache::drop('windows_test');
  307. }
  308. /**
  309. * testWriteQuotedString method
  310. *
  311. * @return void
  312. */
  313. public function testWriteQuotedString() {
  314. Cache::config('file_test', array('engine' => 'File', 'path' => TMP . 'tests'));
  315. Cache::write('App.doubleQuoteTest', '"this is a quoted string"', 'file_test');
  316. $this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
  317. Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test');
  318. $this->assertSame(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'");
  319. Cache::config('file_test', array('isWindows' => true, 'path' => TMP . 'tests'));
  320. $this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"');
  321. Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test');
  322. $this->assertSame(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'");
  323. Cache::delete('App.singleQuoteTest', 'file_test');
  324. Cache::delete('App.doubleQuoteTest', 'file_test');
  325. }
  326. /**
  327. * check that FileEngine does not generate an error when a configured Path does not exist in debug mode.
  328. *
  329. * @return void
  330. */
  331. public function testPathDoesNotExist() {
  332. $this->skipIf(is_dir(TMP . 'tests' . DS . 'autocreate'), 'Cannot run if test directory exists.');
  333. Cache::config('autocreate', array(
  334. 'engine' => 'File',
  335. 'path' => TMP . 'tests' . DS . 'autocreate'
  336. ));
  337. Cache::drop('autocreate');
  338. }
  339. /**
  340. * Testing the mask setting in FileEngine
  341. *
  342. * @return void
  343. */
  344. public function testMaskSetting() {
  345. if (DS === '\\') {
  346. $this->markTestSkipped('File permission testing does not work on Windows.');
  347. }
  348. Cache::config('mask_test', array('engine' => 'File', 'path' => TMP . 'tests'));
  349. $data = 'This is some test content';
  350. $write = Cache::write('masking_test', $data, 'mask_test');
  351. $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4);
  352. $expected = '0664';
  353. $this->assertEquals($expected, $result);
  354. Cache::delete('masking_test', 'mask_test');
  355. Cache::drop('mask_test');
  356. Cache::config('mask_test', array('engine' => 'File', 'mask' => 0666, 'path' => TMP . 'tests'));
  357. Cache::write('masking_test', $data, 'mask_test');
  358. $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4);
  359. $expected = '0666';
  360. $this->assertEquals($expected, $result);
  361. Cache::delete('masking_test', 'mask_test');
  362. Cache::drop('mask_test');
  363. Cache::config('mask_test', array('engine' => 'File', 'mask' => 0644, 'path' => TMP . 'tests'));
  364. Cache::write('masking_test', $data, 'mask_test');
  365. $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4);
  366. $expected = '0644';
  367. $this->assertEquals($expected, $result);
  368. Cache::delete('masking_test', 'mask_test');
  369. Cache::drop('mask_test');
  370. Cache::config('mask_test', array('engine' => 'File', 'mask' => 0640, 'path' => TMP . 'tests'));
  371. Cache::write('masking_test', $data, 'mask_test');
  372. $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4);
  373. $expected = '0640';
  374. $this->assertEquals($expected, $result);
  375. Cache::delete('masking_test', 'mask_test');
  376. Cache::drop('mask_test');
  377. }
  378. /**
  379. * Tests that configuring groups for stored keys return the correct values when read/written
  380. *
  381. * @return void
  382. */
  383. public function testGroupsReadWrite() {
  384. Cache::config('file_groups', array('engine' => 'File', 'duration' => 3600, 'groups' => array('group_a', 'group_b')));
  385. $this->assertTrue(Cache::write('test_groups', 'value', 'file_groups'));
  386. $this->assertEquals('value', Cache::read('test_groups', 'file_groups'));
  387. $this->assertTrue(Cache::write('test_groups2', 'value2', 'file_groups'));
  388. $this->assertTrue(Cache::write('test_groups3', 'value3', 'file_groups'));
  389. }
  390. /**
  391. * Test that clearing with repeat writes works properly
  392. *
  393. * @return void
  394. */
  395. public function testClearingWithRepeatWrites() {
  396. Cache::config('repeat', array(
  397. 'engine' => 'File', 'groups' => array('users')
  398. ));
  399. $this->assertTrue(Cache::write('user', 'rchavik', 'repeat'));
  400. $this->assertEquals('rchavik', Cache::read('user', 'repeat'));
  401. Cache::delete('user', 'repeat');
  402. $this->assertEquals(false, Cache::read('user', 'repeat'));
  403. $this->assertTrue(Cache::write('user', 'ADmad', 'repeat'));
  404. $this->assertEquals('ADmad', Cache::read('user', 'repeat'));
  405. Cache::clearGroup('users', 'repeat');
  406. $this->assertEquals(false, Cache::read('user', 'repeat'));
  407. $this->assertTrue(Cache::write('user', 'markstory', 'repeat'));
  408. $this->assertEquals('markstory', Cache::read('user', 'repeat'));
  409. Cache::drop('repeat');
  410. }
  411. /**
  412. * Tests that deleting from a groups-enabled config is possible
  413. *
  414. * @return void
  415. */
  416. public function testGroupDelete() {
  417. Cache::config('file_groups', array(
  418. 'engine' => 'File',
  419. 'duration' => 3600,
  420. 'groups' => array('group_a', 'group_b')
  421. ));
  422. $this->assertTrue(Cache::write('test_groups', 'value', 'file_groups'));
  423. $this->assertEquals('value', Cache::read('test_groups', 'file_groups'));
  424. $this->assertTrue(Cache::delete('test_groups', 'file_groups'));
  425. $this->assertFalse(Cache::read('test_groups', 'file_groups'));
  426. }
  427. /**
  428. * Test clearing a cache group
  429. *
  430. * @return void
  431. */
  432. public function testGroupClear() {
  433. Cache::config('file_groups', array('engine' => 'File', 'duration' => 3600, 'groups' => array('group_a', 'group_b')));
  434. Cache::config('file_groups2', array('engine' => 'File', 'duration' => 3600, 'groups' => array('group_b')));
  435. Cache::config('file_groups3', array(
  436. 'engine' => 'File',
  437. 'duration' => 3600,
  438. 'groups' => array('group_b'),
  439. 'prefix' => 'leading_',
  440. ));
  441. $this->assertTrue(Cache::write('test_groups', 'value', 'file_groups'));
  442. $this->assertTrue(Cache::write('test_groups2', 'value 2', 'file_groups2'));
  443. $this->assertTrue(Cache::write('test_groups3', 'value 3', 'file_groups3'));
  444. $this->assertTrue(Cache::clearGroup('group_b', 'file_groups'));
  445. $this->assertFalse(Cache::read('test_groups', 'file_groups'));
  446. $this->assertFalse(Cache::read('test_groups2', 'file_groups2'));
  447. $this->assertEquals('value 3', Cache::read('test_groups3', 'file_groups3'));
  448. $this->assertTrue(Cache::write('test_groups4', 'value', 'file_groups'));
  449. $this->assertTrue(Cache::write('test_groups5', 'value 2', 'file_groups2'));
  450. $this->assertTrue(Cache::write('test_groups6', 'value 3', 'file_groups3'));
  451. $this->assertTrue(Cache::clearGroup('group_b', 'file_groups'));
  452. $this->assertFalse(Cache::read('test_groups4', 'file_groups'));
  453. $this->assertFalse(Cache::read('test_groups5', 'file_groups2'));
  454. $this->assertEquals('value 3', Cache::read('test_groups6', 'file_groups3'));
  455. }
  456. /**
  457. * Test that clearGroup works with no prefix.
  458. *
  459. * @return void
  460. */
  461. public function testGroupClearNoPrefix() {
  462. Cache::config('file_groups', array(
  463. 'engine' => 'File',
  464. 'duration' => 3600,
  465. 'prefix' => '',
  466. 'groups' => array('group_a', 'group_b')
  467. ));
  468. Cache::write('key_1', 'value', 'file_groups');
  469. Cache::write('key_2', 'value', 'file_groups');
  470. Cache::clearGroup('group_a', 'file_groups');
  471. $this->assertFalse(Cache::read('key_1', 'file_groups'), 'Did not delete');
  472. $this->assertFalse(Cache::read('key_2', 'file_groups'), 'Did not delete');
  473. }
  474. }