From 66b36efa5df371874dda1bf4f4843384b6acfa06 Mon Sep 17 00:00:00 2001 From: Johnathan Croom Date: Thu, 29 Nov 2012 17:54:28 -0700 Subject: keep_flashdata array test --- tests/codeigniter/libraries/Session_test.php | 52 +++++++++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/codeigniter/libraries/Session_test.php b/tests/codeigniter/libraries/Session_test.php index 14469f7fa..50d263827 100644 --- a/tests/codeigniter/libraries/Session_test.php +++ b/tests/codeigniter/libraries/Session_test.php @@ -269,6 +269,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 * @@ -399,4 +449,4 @@ class Session_test extends CI_TestCase { $this->session->native->sess_destroy(); $this->assertNull($this->session->native->userdata($key)); } -} \ No newline at end of file +} -- cgit v1.2.3-24-g4f1b