diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codeigniter/core/Input_test.php | 25 | ||||
-rw-r--r-- | tests/codeigniter/core/Output_test.php | 35 | ||||
-rw-r--r-- | tests/codeigniter/core/Utf8_test.php | 20 | ||||
-rw-r--r-- | tests/codeigniter/helpers/form_helper_test.php | 2 | ||||
-rwxr-xr-x | tests/mocks/database/ci_test.sqlite | bin | 19456 -> 19456 bytes | |||
-rw-r--r-- | tests/mocks/libraries/session.php | 4 |
6 files changed, 83 insertions, 3 deletions
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index ca1c6dfd7..5cf25fefa 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -95,8 +95,8 @@ class Input_test extends CI_TestCase { public function test_cookie() { $_COOKIE['foo'] = 'bar'; - $this->assertEquals('bar', $this->input->cookie('foo')); + $this->assertNull($this->input->cookie('bar')); } // -------------------------------------------------------------------- @@ -138,4 +138,27 @@ class Input_test extends CI_TestCase { } } + // -------------------------------------------------------------------- + + public function test_method() + { + $_SERVER['REQUEST_METHOD'] = 'GET'; + $this->assertEquals('get', $this->input->method()); + $this->assertEquals('GET', $this->input->method(TRUE)); + $_SERVER['REQUEST_METHOD'] = 'POST'; + $this->assertEquals('post', $this->input->method()); + $this->assertEquals('POST', $this->input->method(TRUE)); + } + + // -------------------------------------------------------------------- + + public function test_is_ajax_request() + { + $this->assertFalse($this->input->is_ajax_request()); + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'test'; + $this->assertFalse($this->input->is_ajax_request()); + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; + $this->assertTrue($this->input->is_ajax_request()); + } + }
\ No newline at end of file diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php index 728df3bf6..0eeb93f7b 100644 --- a/tests/codeigniter/core/Output_test.php +++ b/tests/codeigniter/core/Output_test.php @@ -3,6 +3,16 @@ class Output_test extends CI_TestCase { public $output; + protected $_output_data = <<<HTML +<html> + <head> + <title>Basic HTML</title> + </head> + <body> + Test + </body> +</html> +HTML; public function set_up() { @@ -13,6 +23,31 @@ class Output_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_set_get_append_output() + { + $append = "<!-- comment /-->\n"; + + $this->assertEquals( + $this->_output_data.$append, + $this->output + ->set_output($this->_output_data) + ->append_output("<!-- comment /-->\n") + ->get_output() + ); + } + + // -------------------------------------------------------------------- + + public function test_minify() + { + $this->assertEquals( + str_replace(array("\t", "\n"), '', $this->_output_data), + $this->output->minify($this->_output_data) + ); + } + + // -------------------------------------------------------------------- + public function test_get_content_type() { $this->assertEquals('text/html', $this->output->get_content_type()); diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php new file mode 100644 index 000000000..caa7b6986 --- /dev/null +++ b/tests/codeigniter/core/Utf8_test.php @@ -0,0 +1,20 @@ +<?php + +class Utf8_test extends CI_TestCase { + + public function set_up() + { + $this->utf8 = new Mock_Core_Utf8(); + } + + // -------------------------------------------------------------------- + + public function test_convert_to_utf8() + { + $this->assertEquals( + $this->utf8->convert_to_utf8('', 'WINDOWS-1251'), + 'тест' + ); + } + +}
\ No newline at end of file diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php index 89165271e..e234f9c83 100644 --- a/tests/codeigniter/helpers/form_helper_test.php +++ b/tests/codeigniter/helpers/form_helper_test.php @@ -58,7 +58,7 @@ EOH; public function test_form_upload() { $expected = <<<EOH -<input type="file" name="attachment" value="" /> +<input type="file" name="attachment" /> EOH; diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite Binary files differindex 44dcef9ec..574d3ae53 100755 --- a/tests/mocks/database/ci_test.sqlite +++ b/tests/mocks/database/ci_test.sqlite diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php index 562033bbf..adbecb329 100644 --- a/tests/mocks/libraries/session.php +++ b/tests/mocks/libraries/session.php @@ -33,4 +33,6 @@ class Mock_Libraries_Session_cookie extends CI_Session_cookie { $_COOKIE[$name] = $value; } } -}
\ No newline at end of file +} + +class Mock_Libraries_Session_native extends CI_Session_native {}
\ No newline at end of file |