Skip to content

Commit 736d336

Browse files
committed
Adding tests for using a custom session config with CacheSession.
1 parent 49397c7 commit 736d336

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

cake/tests/cases/libs/cake_session.test.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,37 @@ function testReadAndWriteWithCacheStorage() {
571571
$this->assertNull(TestCakeSession::read('SessionTestCase'));
572572
}
573573

574+
/**
575+
* test that changing the config name of the cache config works.
576+
*
577+
* @return void
578+
*/
579+
function testReadAndWriteWithCustomCacheConfig() {
580+
session_write_close();
581+
Configure::write('Session.defaults', 'cache');
582+
Configure::write('Session.handler.config', 'session_test');
583+
584+
Cache::config('session_test', array(
585+
'engine' => 'File',
586+
'prefix' => 'session_test_',
587+
));
588+
589+
TestCakeSession::init();
590+
TestCakeSession::destroy();
591+
592+
TestCakeSession::write('SessionTestCase', 'Some value');
593+
$this->assertEquals('Some value', TestCakeSession::read('SessionTestCase'));
594+
595+
session_write_close();
596+
597+
$this->assertContains('Some value', Cache::read(TestCakeSession::id(), 'session_test'));
598+
$this->assertFalse(Cache::read(TestCakeSession::id(), 'default'));
599+
600+
TestCakeSession::destroy();
601+
Cache::delete(TestCakeSession::id(), 'session_test');
602+
Cache::drop('session_test');
603+
}
604+
574605
/**
575606
* testReadAndWriteWithDatabaseStorage method
576607
*

0 commit comments

Comments
 (0)