Skip to content

Commit

Permalink
Fix getting all namespace entries
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrooo committed Sep 25, 2013
1 parent 802f04e commit fa087bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/Ouzo/Session.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
namespace Ouzo;

use Ouzo\Utilities\Arrays;

class Session
{
private $_sessionNamespace;
Expand Down Expand Up @@ -60,6 +62,6 @@ public function delete()

public function all()
{
return $_SESSION[$this->_sessionNamespace];
return Arrays::getValue($_SESSION, $this->_sessionNamespace, array());
}
}
15 changes: 15 additions & 0 deletions test/lib/Ouzo/SessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,19 @@ public function shouldGetAllSessionNamespaceEntries()
//then
Assert::thatArray($all)->hasSize(2)->containsOnly('value1', 'value2');
}

/**
* @test
*/
public function shouldGetEmptyArrayIfNotFoundNamespace()
{
//given
$session = new Session('example');

//when
$all = $session->all();

//then
Assert::thatArray($all)->isEmpty();
}
}

0 comments on commit fa087bb

Please sign in to comment.