Skip to content

Commit

Permalink
Merge branch 'hotfix-flash-remove-cast'
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Lockhart committed Apr 23, 2011
2 parents d4af923 + 028ecfb commit 688fe33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Slim/Session/Flash.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getSessionKey() {
* @return Slim_Session_Flash
*/
public function now( $key, $value ) {
$this->messages['now'][(string)$key] = (string)$value;
$this->messages['now'][(string)$key] = $value;
return $this->save();
}

Expand All @@ -121,7 +121,7 @@ public function now( $key, $value ) {
* @return Slim_Session_Flash
*/
public function set( $key, $value ) {
$this->messages['next'][(string)$key] = (string)$value;
$this->messages['next'][(string)$key] = $value;
return $this->save();
}

Expand Down
15 changes: 15 additions & 0 deletions tests/FlashTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,21 @@ public function testFlashKeepsMessages() {
$this->assertArrayHasKey('error', $_SESSION['flash']);
$this->assertEquals('New error message', $_SESSION['flash']['error']);
}

/**
* Tests flash can store array/object, not only strings.
*/
public function testFlashKeepsObjects() {
$c = new StdClass;
$c->foo = 'bar';

$f1 = new Slim_Session_Flash();
$f1->set('object', $c);
$f1->save();
$f1->load();

$this->assertObjectHasAttribute('foo', $f1['object']);
}

}
?>

0 comments on commit 688fe33

Please sign in to comment.