Skip to content

Commit

Permalink
Use pull instead get and forget.
Browse files Browse the repository at this point in the history
Signed-off-by: crynobone <crynobone@gmail.com>
  • Loading branch information
crynobone committed Nov 14, 2014
1 parent e1dd05a commit 825ed2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/Messages/MessageBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,9 @@ public function retrieve()
$this->instance->setSessionStore($this->session);

if ($this->session->has('message')) {
$messages = @unserialize($this->session->get('message', ''));
$messages = unserialize($this->session->pull('message'));
}

$this->session->forget('message');

if (is_array($messages)) {
$this->instance->merge($messages);
}
Expand Down
10 changes: 4 additions & 6 deletions tests/MessageBagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ public function testRetrieveMethod()
{
$session = m::mock('\Illuminate\Session\Store');
$session->shouldReceive('has')->once()->andReturn(true)
->shouldReceive('get')->once()
->andReturn('a:2:{s:5:"hello";a:1:{i:0;s:8:"Hi World";}s:3:"bye";a:1:{i:0;s:7:"Goodbye";}}')
->shouldReceive('forget')->once()->andReturn(true);
->shouldReceive('pull')->once()
->andReturn('a:2:{s:5:"hello";a:1:{i:0;s:8:"Hi World";}s:3:"bye";a:1:{i:0;s:7:"Goodbye";}}');

$retrieve = (new MessageBag)->setSessionStore($session)->retrieve();
$retrieve->setFormat();
Expand All @@ -107,9 +106,8 @@ public function testExtendMethod()
{
$session = m::mock('\Illuminate\Session\Store');
$session->shouldReceive('has')->once()->andReturn(true)
->shouldReceive('get')->once()
->andReturn('a:1:{s:5:"hello";a:1:{i:0;s:8:"Hi World";}}')
->shouldReceive('forget')->once()->andReturn(true);
->shouldReceive('pull')->once()
->andReturn('a:1:{s:5:"hello";a:1:{i:0;s:8:"Hi World";}}');

$callback = function ($msg) {
$msg->add('hello', 'Hi Orchestra Platform');
Expand Down

0 comments on commit 825ed2f

Please sign in to comment.