diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codeigniter/core/Output_test.php | 37 | ||||
-rw-r--r-- | tests/codeigniter/libraries/Session_test.php | 50 |
2 files changed, 87 insertions, 0 deletions
diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php new file mode 100644 index 000000000..d8252403d --- /dev/null +++ b/tests/codeigniter/core/Output_test.php @@ -0,0 +1,37 @@ +<?php + +class Output_test extends CI_TestCase { + + public $output; + + public function set_up() + { + $this->ci_set_config('charset', 'UTF-8'); + $output = $this->ci_core_class('output'); + $this->output = new $output(); + } + + // -------------------------------------------------------------------- + + public function test_get_content_type() + { + $this->assertEquals('text/html', $this->output->get_content_type()); + } + + // -------------------------------------------------------------------- + + public function test_get_header() + { + $this->assertNull($this->output->get_header('Non-Existent-Header')); + + // TODO: Find a way to test header() values as well. Currently, + // PHPUnit prevents this by not using output buffering. + + $this->output->set_content_type('text/plain', 'WINDOWS-1251'); + $this->assertEquals( + 'text/plain; charset=windows-1251', // Character set is converted to lowercase + $this->output->get_header('content-type') // Case-insensitive comparison + ); + } + +}
\ No newline at end of file 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 */ |