diff options
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r-- | tests/codeigniter/core/Input_test.php | 25 | ||||
-rw-r--r-- | tests/codeigniter/core/Loader_test.php | 18 | ||||
-rw-r--r-- | tests/codeigniter/core/Output_test.php | 35 | ||||
-rw-r--r-- | tests/codeigniter/core/URI_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/core/Utf8_test.php | 20 |
5 files changed, 89 insertions, 11 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/Loader_test.php b/tests/codeigniter/core/Loader_test.php index ecc5ca933..dea01a555 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -25,7 +25,7 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_base_root, 'libraries'); // Test is_loaded fail $this->assertFalse($this->load->is_loaded($lib)); @@ -48,7 +48,7 @@ class Loader_test extends CI_TestCase { // Test non-existent class $this->setExpectedException( 'RuntimeException', - 'CI Error: Non-existent class: '.$lib + 'CI Error: Unable to load the requested class: '.ucfirst($lib) ); $this->assertNull($this->load->library($lib)); } @@ -105,7 +105,7 @@ class Loader_test extends CI_TestCase { $lib = 'unit_test_config_lib'; $class = 'CI_'.ucfirst($lib); $content = '<?php class '.$class.' { public function __construct($params) { $this->config = $params; } }'; - $this->ci_vfs_create($lib, $content, $this->ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), $content, $this->ci_base_root, 'libraries'); // Create config file $cfg = array( @@ -133,7 +133,7 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'super_test_library'; $class = ucfirst($lib); - $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_app_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries'); // Load library $this->assertNull($this->load->library($lib)); @@ -152,7 +152,7 @@ class Loader_test extends CI_TestCase { $dir = ucfirst($driver); $class = 'CI_'.$dir; $content = '<?php class '.$class.' { } '; - $this->ci_vfs_create($driver, $content, $this->ci_base_root, 'libraries/'.$dir); + $this->ci_vfs_create(ucfirst($driver), $content, $this->ci_base_root, 'libraries/'.$dir); // Test loading as an array. $this->assertNull($this->load->driver(array($driver))); @@ -410,7 +410,7 @@ class Loader_test extends CI_TestCase { $dir = 'third-party'; $lib = 'unit_test_package'; $class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_app_root, array($dir, 'libraries')); + $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, array($dir, 'libraries')); // Get paths $paths = $this->load->get_package_paths(TRUE); @@ -440,7 +440,7 @@ class Loader_test extends CI_TestCase { // Test failed load without path $this->setExpectedException( 'RuntimeException', - 'CI Error: Unable to load the requested class: '.$lib + 'CI Error: Unable to load the requested class: '.ucfirst($lib) ); $this->load->library($lib); } @@ -467,13 +467,13 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'autolib'; $lib_class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, '<?php class '.$lib_class.' { }', $this->ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), '<?php class '.$lib_class.' { }', $this->ci_base_root, 'libraries'); // Create driver in VFS $drv = 'autodrv'; $subdir = ucfirst($drv); $drv_class = 'CI_'.$subdir; - $this->ci_vfs_create($drv, '<?php class '.$drv_class.' { }', $this->ci_base_root, array('libraries', $subdir)); + $this->ci_vfs_create(ucfirst($drv), '<?php class '.$drv_class.' { }', $this->ci_base_root, array('libraries', $subdir)); // Create model in VFS package path $dir = 'testdir'; 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/URI_test.php b/tests/codeigniter/core/URI_test.php index e2deabe51..7fa0e6265 100644 --- a/tests/codeigniter/core/URI_test.php +++ b/tests/codeigniter/core/URI_test.php @@ -91,7 +91,7 @@ class URI_test extends CI_TestCase { public function test_explode_segments() { - // Lets test the function's ability to clean up this mess + // Let's test the function's ability to clean up this mess $uris = array( 'test/uri' => array('test', 'uri'), '/test2/uri2' => array('test2', 'uri2'), 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 |