diff options
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r-- | tests/codeigniter/core/Config_test.php | 24 | ||||
-rw-r--r-- | tests/codeigniter/core/Lang_test.php | 7 | ||||
-rw-r--r-- | tests/codeigniter/core/Loader_test.php | 16 | ||||
-rw-r--r-- | tests/codeigniter/core/Output_test.php | 33 | ||||
-rw-r--r-- | tests/codeigniter/core/Security_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/core/URI_test.php | 28 | ||||
-rw-r--r-- | tests/codeigniter/core/compat/standard_test.php | 6 |
7 files changed, 55 insertions, 61 deletions
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index 2c28a639c..f125fc6e9 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -76,7 +76,8 @@ class Config_test extends CI_TestCase { // Capture server vars $old_host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : NULL; - $old_script = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : NULL; + $old_script_name = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : NULL; + $old_script_filename = $_SERVER['SCRIPT_FILENAME']; $old_https = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : NULL; // Setup server vars for detection @@ -85,6 +86,7 @@ class Config_test extends CI_TestCase { $script = 'base_test.php'; $_SERVER['HTTP_HOST'] = $host; $_SERVER['SCRIPT_NAME'] = $path.$script; + $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/'.$script; // Rerun constructor $this->config = new $cls; @@ -95,6 +97,7 @@ class Config_test extends CI_TestCase { // Rerun constructor $path = '/path/'; $_SERVER['SCRIPT_NAME'] = $path.$script; + $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/'.$path.$script; $this->config = new $cls; // Test plain detected (subfolder) @@ -110,10 +113,12 @@ class Config_test extends CI_TestCase { // Restore server vars if ($old_host === NULL) unset($_SERVER['HTTP_HOST']); else $_SERVER['HTTP_HOST'] = $old_host; - if ($old_script === NULL) unset($_SERVER['SCRIPT_NAME']); - else $_SERVER['SCRIPT_NAME'] = $old_script; + if ($old_script_name === NULL) unset($_SERVER['SCRIPT_NAME']); + else $_SERVER['SCRIPT_NAME'] = $old_script_name; if ($old_https === NULL) unset($_SERVER['HTTPS']); else $_SERVER['HTTPS'] = $old_https; + + $_SERVER['SCRIPT_FILENAME'] = $old_script_filename; } // -------------------------------------------------------------------- @@ -200,13 +205,18 @@ class Config_test extends CI_TestCase { 'number' => 42, 'letter' => 'Z' ); + $pkg_dir = 'package'; - $this->ci_vfs_create($file.'.php', '<?php $config = '.var_export($cfg2, TRUE).';', $this->ci_app_root, - array($pkg_dir, 'config')); - $this->config->_config_paths[] = $this->ci_vfs_path($pkg_dir.'/', APPPATH); + $this->ci_vfs_create( + $file.'.php', + '<?php $config = '.var_export($cfg2, TRUE).';', + $this->ci_app_root, + array($pkg_dir, 'config') + ); + array_unshift($this->config->_config_paths, $this->ci_vfs_path($pkg_dir.'/', APPPATH)); $this->assertTrue($this->config->load($file, TRUE)); $this->assertEquals(array_merge($cfg, $cfg2), $this->config->item($file)); - array_pop($this->config->_config_paths); + array_shift($this->config->_config_paths); // Test graceful fail of invalid file $file = 'badfile'; diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php index d3c7ee1e4..87a71c885 100644 --- a/tests/codeigniter/core/Lang_test.php +++ b/tests/codeigniter/core/Lang_test.php @@ -29,6 +29,11 @@ class Lang_test extends CI_TestCase { $this->assertTrue($this->lang->load('date')); $this->assertEquals('Year', $this->lang->language['date_year']); + // A language other than english + $this->ci_vfs_clone('system/language/english/email_lang.php', 'system/language/german/'); + $this->assertTrue($this->lang->load('email', 'german')); + $this->assertEquals('german', $this->lang->is_loaded['email_lang.php'] ); + // Non-alpha idiom (should act the same as unspecified language) $this->ci_vfs_clone('system/language/english/number_lang.php'); $this->assertTrue($this->lang->load('number')); @@ -56,4 +61,4 @@ class Lang_test extends CI_TestCase { $this->assertFalse($this->lang->line(NULL)); } -}
\ No newline at end of file +} diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 93ca5b223..9e2092e05 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -405,12 +405,19 @@ class Loader_test extends CI_TestCase { // Create model in VFS package path $dir = 'third-party'; $lib = 'unit_test_package'; - $class = 'CI_'.ucfirst($lib); + $class = ucfirst($lib); $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); + // Test failed load without path + $this->setExpectedException( + 'RuntimeException', + 'CI Error: Unable to load the requested class: '.ucfirst($lib) + ); + $this->load->library($lib); + // Add path and verify $path = APPPATH.$dir.'/'; $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path)); @@ -432,13 +439,6 @@ class Loader_test extends CI_TestCase { // Remove path and verify restored paths $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path)); $this->assertEquals($paths, $this->load->get_package_paths(TRUE)); - - // Test failed load without path - $this->setExpectedException( - 'RuntimeException', - 'CI Error: Unable to load the requested class: '.ucfirst($lib) - ); - $this->load->library($lib); } // -------------------------------------------------------------------- diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php index 0eeb93f7b..887c077d7 100644 --- a/tests/codeigniter/core/Output_test.php +++ b/tests/codeigniter/core/Output_test.php @@ -3,19 +3,20 @@ class Output_test extends CI_TestCase { public $output; - protected $_output_data = <<<HTML -<html> - <head> - <title>Basic HTML</title> - </head> - <body> - Test - </body> -</html> -HTML; + protected $_output_data = ''; public function set_up() { + $this->_output_data =<<<HTML + <html> + <head> + <title>Basic HTML</title> + </head> + <body> + Test + </body> + </html> +HTML; $this->ci_set_config('charset', 'UTF-8'); $output = $this->ci_core_class('output'); $this->output = new $output(); @@ -38,16 +39,6 @@ HTML; // -------------------------------------------------------------------- - 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()); @@ -69,4 +60,4 @@ HTML; ); } -}
\ No newline at end of file +} diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index c80c3d65a..402422ff8 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -98,7 +98,7 @@ class Security_test extends CI_TestCase { $this->assertEquals('<div>Hello <b>Booya</b></div>', $decoded); - // Issue #3057 (https://github.com/EllisLab/CodeIgniter/issues/3057) + // Issue #3057 (https://github.com/bcit-ci/CodeIgniter/issues/3057) $this->assertEquals( '&foo should not include a semicolon', $this->security->entity_decode('&foo should not include a semicolon') diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php index 6589c1f5a..42dff3639 100644 --- a/tests/codeigniter/core/URI_test.php +++ b/tests/codeigniter/core/URI_test.php @@ -11,7 +11,7 @@ class URI_test extends CI_TestCase { /* As of the following commit, _set_uri_string() is a protected method: - https://github.com/EllisLab/CodeIgniter/commit/d461934184d95b0cfb2feec93f27b621ef72a5c2 + https://github.com/bcit-ci/CodeIgniter/commit/d461934184d95b0cfb2feec93f27b621ef72a5c2 public function test_set_uri_string() { @@ -119,26 +119,12 @@ class URI_test extends CI_TestCase { */ // -------------------------------------------------------------------- - public function test_filter_uri() + public function test_filter_uri_passing() { $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-'); - $str_in = 'abc01239~%.:_-'; - $str = $this->uri->filter_uri($str_in); - - $this->assertEquals($str, $str_in); - } - - // -------------------------------------------------------------------- - - public function test_filter_uri_escaping() - { - // ensure escaping even if dodgey characters are permitted - $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-()$'); - - $str = $this->uri->filter_uri('$destroy_app(foo)'); - - $this->assertEquals($str, '$destroy_app(foo)'); + $str = 'abc01239~%.:_-'; + $this->uri->filter_uri($str); } // -------------------------------------------------------------------- @@ -149,7 +135,8 @@ class URI_test extends CI_TestCase { $this->uri->config->set_item('enable_query_strings', FALSE); $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-'); - $this->uri->filter_uri('$this()'); + $segment = '$this()'; // filter_uri() accepts by reference + $this->uri->filter_uri($segment); } // -------------------------------------------------------------------- @@ -265,6 +252,3 @@ class URI_test extends CI_TestCase { } } - -/* End of file URI_test.php */ -/* Location: ./tests/core/URI_test.php */
\ No newline at end of file diff --git a/tests/codeigniter/core/compat/standard_test.php b/tests/codeigniter/core/compat/standard_test.php index a3a6d9552..4077a5c7c 100644 --- a/tests/codeigniter/core/compat/standard_test.php +++ b/tests/codeigniter/core/compat/standard_test.php @@ -449,7 +449,6 @@ class standard_test extends CI_TestCase { return $this->markTestSkipped('quoted_printable_encode() is already available on PHP 5.3'); } - // These are actually imap_8bit() tests: $this->assertEquals("String with CRLF at end=20\r\n", quoted_printable_encode("String with CRLF at end \r\n")); // ext/imap/tests/imap_8bit_basic.phpt says for this line: @@ -459,6 +458,11 @@ class standard_test extends CI_TestCase { $this->assertEquals("String with tab at end =09", quoted_printable_encode("String with tab at end \t")); $this->assertEquals("=00=01=02=03=04=FE=FF=0A=0D", quoted_printable_encode("\x00\x01\x02\x03\x04\xfe\xff\x0a\x0d")); + if (function_exists('imap_8bit')) + { + return $this->markTestIncomplete('imap_8bit() exists and is called as an alias for quoted_printable_encode()'); + } + // And these are from ext/standard/tests/strings/quoted_printable_encode_002.phpt: $this->assertEquals( "=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n" |