Permalink
Browse files

Fixing typo in Session::read() preventing reading values from named s…

…ession. Tests added.
  • Loading branch information...
1 parent fecb7a7 commit e99051715ebbdf8f53169bb9f8d176fdc46303a3 @daetal-us daetal-us committed with gwoo Jan 30, 2010
Showing with 23 additions and 1 deletion.
  1. +1 −1 libraries/lithium/storage/Session.php
  2. +22 −0 libraries/lithium/tests/cases/storage/SessionTest.php
@@ -86,7 +86,7 @@ public static function isValid($name = null) {
public static function read($key, $options = array()) {
$defaults = array('name' => null);
$options += $defaults;
- $method = ($name = $options['name']) ? static::_adapter($name)->read($key, $options) : null;
+ $method = ($name = $options['name']) ? static::adapter($name)->read($key, $options) : null;
$settings = static::_config($name);
if (!$method) {
@@ -64,6 +64,28 @@ public function testSingleStoreReadWrite() {
$this->assertNull(Session::read('key'));
$this->assertIdentical(false, Session::write('key', 'value'));
}
+
+ public function testNamedConfigurationReadWrite() {
+ $store1 = new Memory();
+ $store2 = new Memory();
+ $config = array(
+ 'store1' => array('adapter' => &$store1, 'filters' => array(), 'strategies' => array()),
+ 'store2' => array('adapter' => &$store2, 'filters' => array(), 'strategies' => array())
+ );
+ Session::reset();
+ Session::config($config);
+ $result = Session::config();
+ $this->assertEqual($config, $result);
+
+ $result = Session::write('key', 'value', array('name' => 'store1'));
+ $this->assertTrue($result);
+
+ $result = Session::read('key', array('name' => 'store1'));
+ $this->assertEqual($result, 'value');
+
+ $result = Session::read('key', array('name' => 'store2'));
+ $this->assertFalse($result);
+ }
public function testSessionConfigReset() {
$this->assertTrue(Session::write('key', 'value'));

0 comments on commit e990517

Please sign in to comment.