FileEngineTest.php 19 KB

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