summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-11-30 02:30:33 +0100
committerAndrey Andreev <narf@bofh.bg>2012-11-30 02:30:33 +0100
commit74ad0bbc4a5e39ced17d33f44ec6f2082d145c8e (patch)
tree983d60c505c8abec286db5b7ac558b80876a491c
parentb37d2bc462af918276111d0439592aa445ac6277 (diff)
parent66b36efa5df371874dda1bf4f4843384b6acfa06 (diff)
Merge pull request #2043 from johnathancroom/keep_flash_data_array
Test for keep_flashdata accepting an array
-rw-r--r--tests/codeigniter/libraries/Session_test.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/codeigniter/libraries/Session_test.php b/tests/codeigniter/libraries/Session_test.php
index e675b4ed7..7ef3a3667 100644
--- a/tests/codeigniter/libraries/Session_test.php
+++ b/tests/codeigniter/libraries/Session_test.php
@@ -252,6 +252,56 @@ class Session_test extends CI_TestCase {
$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
*/