Skip to content

Commit

Permalink
Merge pull request bcit-ci#2043 from johnathancroom/keep_flash_data_a…
Browse files Browse the repository at this point in the history
…rray

Test for keep_flashdata accepting an array
  • Loading branch information
narfbg committed Nov 30, 2012
2 parents b37d2bc + 66b36ef commit 74ad0bb
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/codeigniter/libraries/Session_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,56 @@ public function test_keep_flashdata()
$this->assertNull($this->session->native->flashdata($key));
}

public function test_keep_flashdata_with_array()
{
// Set flashdata array for each driver
$cdata = array(
'one' => 'first',
'two' => 'second',
'three' => 'third',
'foo' => 'bar',
'bar' => 'baz'
);
$ndata = array(
'one' => 'gold',
'two' => 'silver',
'three' => 'bronze',
'foo' => 'baz',
'bar' => 'foo'
);
$kdata = array(
'one',
'two',
'three',
'foo',
'bar'
);
$this->session->cookie->set_flashdata($cdata);
$this->session->native->set_flashdata($ndata);

// Simulate page reload and verify independent messages
$this->session->cookie->reload();
$this->session->native->reload();
$this->assertEquals($cdata, $this->session->cookie->all_flashdata());
$this->assertEquals($ndata, $this->session->native->all_flashdata());

// Keep messages
$this->session->cookie->keep_flashdata($kdata);
$this->session->native->keep_flashdata($kdata);

// Simulate next page reload and verify message persistence
$this->session->cookie->reload();
$this->session->native->reload();
$this->assertEquals($cdata, $this->session->cookie->all_flashdata());
$this->assertEquals($ndata, $this->session->native->all_flashdata());

// Simulate next page reload and verify absence of messages
$this->session->cookie->reload();
$this->session->native->reload();
$this->assertEmpty($this->session->cookie->all_flashdata());
$this->assertEmpty($this->session->native->all_flashdata());
}

/**
* Test the all_flashdata() function
*/
Expand Down

0 comments on commit 74ad0bb

Please sign in to comment.