summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDiederikLascaris <info@runesa.nl>2017-01-22 21:45:15 +0100
committerDiederikLascaris <info@runesa.nl>2017-01-22 21:45:15 +0100
commit312efeba32d532878c536fd28e75f39d61a9dade (patch)
tree71ae4aaca33a9d34a789d6d375acd2594160123a /tests
parent947f1a06093a52a32b703ee795e52c22cd66363a (diff)
parent44c7af639ac1726780b64fb5a6cb6fca2df8b651 (diff)
Merge branch 'develop' of git://github.com/bcit-ci/CodeIgniter into develop
Diffstat (limited to 'tests')
-rw-r--r--tests/Bootstrap.php6
-rw-r--r--tests/codeigniter/core/Common_test.php17
-rw-r--r--tests/codeigniter/core/Config_test.php58
-rw-r--r--tests/codeigniter/core/Input_test.php46
-rw-r--r--tests/codeigniter/core/Lang_test.php22
-rw-r--r--tests/codeigniter/core/Loader_test.php39
-rw-r--r--tests/codeigniter/core/Log_test.php63
-rw-r--r--tests/codeigniter/core/Security_test.php142
-rw-r--r--tests/codeigniter/core/URI_test.php9
-rw-r--r--tests/codeigniter/core/Utf8_test.php53
-rw-r--r--tests/codeigniter/core/compat/password_test.php5
-rw-r--r--tests/codeigniter/core/compat/standard_test.php234
-rw-r--r--tests/codeigniter/database/DB_driver_test.php2
-rw-r--r--tests/codeigniter/database/query_builder/join_test.php43
-rw-r--r--tests/codeigniter/database/query_builder/where_test.php8
-rw-r--r--tests/codeigniter/helpers/cookie_helper_test.php7
-rw-r--r--tests/codeigniter/helpers/date_helper_test.php114
-rw-r--r--tests/codeigniter/helpers/email_helper_test.php24
-rw-r--r--tests/codeigniter/helpers/file_helper_test.php15
-rw-r--r--tests/codeigniter/helpers/form_helper_test.php16
-rw-r--r--tests/codeigniter/helpers/html_helper_test.php42
-rw-r--r--tests/codeigniter/helpers/inflector_helper_test.php19
-rw-r--r--tests/codeigniter/helpers/language_helper_test.php4
-rw-r--r--tests/codeigniter/helpers/number_helper_test.php4
-rw-r--r--tests/codeigniter/helpers/security_helper_test.php28
-rw-r--r--tests/codeigniter/helpers/string_helper_test.php32
-rw-r--r--tests/codeigniter/helpers/text_helper_test.php23
-rw-r--r--tests/codeigniter/helpers/url_helper_test.php12
-rw-r--r--tests/codeigniter/libraries/Calendar_test.php6
-rw-r--r--tests/codeigniter/libraries/Driver_test.php4
-rw-r--r--tests/codeigniter/libraries/Encrypt_test.php6
-rw-r--r--tests/codeigniter/libraries/Encryption_test.php10
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php84
-rw-r--r--tests/codeigniter/libraries/Session_test.php5
-rw-r--r--tests/codeigniter/libraries/Upload_test.php18
-rw-r--r--tests/mocks/autoloader.php5
-rw-r--r--tests/mocks/ci_testcase.php4
-rw-r--r--tests/mocks/core/input.php49
-rw-r--r--tests/mocks/core/utf8.php19
-rw-r--r--tests/mocks/database/drivers/mysql.php1
-rw-r--r--tests/mocks/database/drivers/mysqli.php1
-rw-r--r--tests/mocks/database/drivers/pdo.php1
-rw-r--r--tests/mocks/database/drivers/postgre.php1
-rw-r--r--tests/mocks/database/drivers/sqlite.php1
44 files changed, 561 insertions, 741 deletions
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
index 8240d2340..b4e56bdae 100644
--- a/tests/Bootstrap.php
+++ b/tests/Bootstrap.php
@@ -1,10 +1,4 @@
<?php
-// For some reason, setting this fixes the 5.2 tests but breaks the 5.3 ones ...
-if (version_compare(PHP_VERSION, '5.3.0', '<'))
-{
- ini_set('memory_limit', '128M');
-}
-
// Errors on full!
ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);
diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php
index 999b49cb3..ca19e5de0 100644
--- a/tests/codeigniter/core/Common_test.php
+++ b/tests/codeigniter/core/Common_test.php
@@ -47,6 +47,23 @@ class Common_test extends CI_TestCase {
html_escape('Here is a string containing "quoted" text.'),
'Here is a string containing &quot;quoted&quot; text.'
);
+
+ $this->assertEquals(
+ html_escape(array('associative' => 'and', array('multi' => 'dimentional'))),
+ array('associative' => 'and', array('multi' => 'dimentional'))
+ );
}
+ // ------------------------------------------------------------------------
+
+ public function test_remove_invisible_characters()
+ {
+ $raw_string = 'Here is a string containing invisible'.chr(0x08).' text %0e.';
+ $removed_string = 'Here is a string containing invisible text %0e.';
+ $this->assertEquals($removed_string, remove_invisible_characters($raw_string, FALSE));
+
+ $raw_string = 'Here is a string %0econtaining url_encoded invisible%1F text.';
+ $removed_string = 'Here is a string containing url_encoded invisible text.';
+ $this->assertEquals($removed_string, remove_invisible_characters($raw_string));
+ }
} \ No newline at end of file
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
index f125fc6e9..5201d46dc 100644
--- a/tests/codeigniter/core/Config_test.php
+++ b/tests/codeigniter/core/Config_test.php
@@ -79,46 +79,33 @@ class Config_test extends CI_TestCase {
$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;
+ $old_server_addr = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : NULL;
- // Setup server vars for detection
- $host = 'test.com';
- $path = '/';
- $script = 'base_test.php';
- $_SERVER['HTTP_HOST'] = $host;
- $_SERVER['SCRIPT_NAME'] = $path.$script;
- $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/'.$script;
-
- // Rerun constructor
+ // The 'Host' header is user input and must not be trusted
+ $_SERVER['HTTP_HOST'] = 'test.com';
$this->config = new $cls;
+ $this->assertEquals('http://localhost/', $this->config->base_url());
- // Test plain detected (root)
- $this->assertEquals('http://'.$host.$path, $this->config->base_url());
-
- // Rerun constructor
- $path = '/path/';
- $_SERVER['SCRIPT_NAME'] = $path.$script;
- $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/'.$path.$script;
+ // However, we may fallback to the server's IP address
+ $_SERVER['SERVER_ADDR'] = '127.0.0.1';
+ $_SERVER['SCRIPT_NAME'] = '/base_test.php';
+ $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/base_test.php';
$this->config = new $cls;
+ $this->assertEquals('http://127.0.0.1/', $this->config->base_url());
- // Test plain detected (subfolder)
- $this->assertEquals('http://'.$host.$path, $this->config->base_url());
-
- // Rerun constructor
+ // Making sure that HTTPS and URI path are also detected
$_SERVER['HTTPS'] = 'on';
+ $_SERVER['SCRIPT_NAME'] = '/path/base_test.php';
+ $_SERVER['SCRIPT_FILENAME'] = '/foo/bar/path/base_test.php';
$this->config = new $cls;
-
- // Test secure detected
- $this->assertEquals('https://'.$host.$path, $this->config->base_url());
+ $this->assertEquals('https://127.0.0.1/path/', $this->config->base_url());
// Restore server vars
- if ($old_host === NULL) unset($_SERVER['HTTP_HOST']);
- else $_SERVER['HTTP_HOST'] = $old_host;
- 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['HTTP_HOST'] = $old_host;
+ $_SERVER['SCRIPT_NAME'] = $old_script_name;
$_SERVER['SCRIPT_FILENAME'] = $old_script_filename;
+ $_SERVER['HTTPS'] = $old_https;
+ $_SERVER['SERVER_ADDR'] = $old_server_addr;
}
// --------------------------------------------------------------------
@@ -140,6 +127,8 @@ class Config_test extends CI_TestCase {
$this->assertEquals($index_page.'/'.$uri, $this->config->site_url($uri));
$this->assertEquals($index_page.'/'.$uri.'/'.$uri2, $this->config->site_url(array($uri, $uri2)));
+ $this->assertEquals($index_page.'/test/', $this->config->site_url('test/'));
+
$suffix = 'ing';
$this->config->set_item('url_suffix', $suffix);
@@ -163,13 +152,6 @@ class Config_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_system_url()
- {
- $this->assertEquals($this->cfg['base_url'].'system/', $this->config->system_url());
- }
-
- // --------------------------------------------------------------------
-
public function test_load()
{
// Test regular load
@@ -248,4 +230,4 @@ class Config_test extends CI_TestCase {
$this->assertNull($this->config->load($file));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index c56900d22..e068a84be 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -12,12 +12,8 @@ class Input_test extends CI_TestCase {
$this->ci_set_config('global_xss_filtering', FALSE);
$this->ci_set_config('csrf_protection', FALSE);
- $security = new Mock_Core_Security();
-
- $this->ci_set_config('charset', 'UTF-8');
- $utf8 = new Mock_Core_Utf8();
-
- $this->input = new Mock_Core_Input($security, $utf8);
+ $security = new Mock_Core_Security('UTF-8');
+ $this->input = new CI_Input($security);
}
// --------------------------------------------------------------------
@@ -122,14 +118,17 @@ class Input_test extends CI_TestCase {
public function test_fetch_from_array()
{
+ $reflection = new ReflectionMethod($this->input, '_fetch_from_array');
+ $reflection->setAccessible(TRUE);
+
$data = array(
'foo' => 'bar',
'harm' => 'Hello, i try to <script>alert(\'Hack\');</script> your site',
);
- $foo = $this->input->fetch_from_array($data, 'foo');
- $harm = $this->input->fetch_from_array($data, 'harm');
- $harmless = $this->input->fetch_from_array($data, 'harm', TRUE);
+ $foo = $reflection->invokeArgs($this->input, [&$data, 'foo']);
+ $harm = $reflection->invokeArgs($this->input, [&$data, 'harm']);
+ $harmless = $reflection->invokeArgs($this->input, [&$data, 'harm', TRUE]);
$this->assertEquals('bar', $foo);
$this->assertEquals("Hello, i try to <script>alert('Hack');</script> your site", $harm);
@@ -217,51 +216,60 @@ class Input_test extends CI_TestCase {
public function test_ip_address()
{
- $this->input->ip_address = '127.0.0.1';
+ $reflection = new ReflectionProperty($this->input, 'ip_address');
+ $reflection->setAccessible(TRUE);
+
+ $reflection->setValue($this->input, '127.0.0.1');
$this->assertEquals('127.0.0.1', $this->input->ip_address());
// 127.0.0.1 is set in our Bootstrap file
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->assertEquals('127.0.0.1', $this->input->ip_address());
// Invalid
$_SERVER['REMOTE_ADDR'] = 'invalid_ip_address';
- $this->input->ip_address = FALSE; // reset cached value
+ $reflection->setValue($this->input, FALSE); // reset cached value
$this->assertEquals('0.0.0.0', $this->input->ip_address());
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
// Proxy_ips tests
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', '127.0.0.3, 127.0.0.4, 127.0.0.2');
$_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2';
$this->assertEquals('127.0.0.1', $this->input->ip_address());
// Invalid spoof
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', 'invalid_ip_address');
$_SERVER['HTTP_CLIENT_IP'] = 'invalid_ip_address';
$this->assertEquals('127.0.0.1', $this->input->ip_address());
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.1/1');
$_SERVER['HTTP_CLIENT_IP'] = '127.0.0.1';
$this->assertEquals('127.0.0.1', $this->input->ip_address());
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', 'http://foo/bar/baz, 127.0.0.2');
$_SERVER['HTTP_CLIENT_IP'] = '127.0.0.2';
$_SERVER['REMOTE_ADDR'] = '127.0.0.2';
$this->assertEquals('127.0.0.2', $this->input->ip_address());
- //IPv6
- $this->input->ip_address = FALSE;
+ // IPv6
+ $reflection->setValue($this->input, FALSE);
$this->ci_set_config('proxy_ips', 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329/1, FE80:0000:0000:0000:0202:B3FF:FE1E:8300/2');
$_SERVER['HTTP_CLIENT_IP'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8300';
$_SERVER['REMOTE_ADDR'] = 'FE80:0000:0000:0000:0202:B3FF:FE1E:8329';
$this->assertEquals('FE80:0000:0000:0000:0202:B3FF:FE1E:8300', $this->input->ip_address());
- $this->input->ip_address = FALSE;
+ $reflection->setValue($this->input, FALSE);
+ $this->ci_set_config('proxy_ips', '0::/32');
+ $_SERVER['HTTP_CLIENT_IP'] = '127.0.0.7';
+ $_SERVER['REMOTE_ADDR'] = '0000:0000:0000:0000:0000:0000:0000:0001';
+ $this->assertEquals('127.0.0.7', $this->input->ip_address());
+
+ $reflection->setValue($this->input, FALSE);
$_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality
}
diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php
index d2dd7598a..4958f42e1 100644
--- a/tests/codeigniter/core/Lang_test.php
+++ b/tests/codeigniter/core/Lang_test.php
@@ -34,11 +34,6 @@ class Lang_test extends CI_TestCase {
$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'));
- $this->assertEquals('Bytes', $this->lang->language['bytes']);
-
// Non-existent file
$this->setExpectedException(
'RuntimeException',
@@ -49,6 +44,23 @@ class Lang_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function test_non_alpha_idiom()
+ {
+ // Non-alpha idiom (should act the same as unspecified language)
+ // test with existing file
+ $this->ci_vfs_clone('system/language/english/number_lang.php');
+ $this->ci_vfs_clone('system/language/english/number_lang.php', 'system/language/123funny/');
+ $this->assertTrue($this->lang->load('number', '123funny'));
+ $this->assertEquals('Bytes', $this->lang->language['bytes']);
+
+ // test without existing file
+ $this->ci_vfs_clone('system/language/english/email_lang.php');
+ $this->assertTrue($this->lang->load('email', '456funny'));
+ $this->assertEquals('You did not specify a SMTP hostname.', $this->lang->language['email_no_hostname']);
+ }
+
+ // --------------------------------------------------------------------
+
public function test_multiple_file_load()
{
// Multiple files
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 889ab92e4..241c415b3 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -48,11 +48,9 @@ class Loader_test extends CI_TestCase {
// Test a string given to params
$this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' '));
- // Create library w/o class
- $lib = 'bad_test_lib';
- $this->ci_vfs_create($lib, '', $this->ci_base_root, 'libraries');
+ // test non existent lib
+ $lib = 'non_existent_test_lib';
- // Test non-existent class
$this->setExpectedException(
'RuntimeException',
'CI Error: Unable to load the requested class: '.ucfirst($lib)
@@ -62,6 +60,19 @@ class Loader_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function test_bad_library()
+ {
+ $lib = 'bad_test_lib';
+ $this->ci_vfs_create(ucfirst($lib), '', $this->ci_app_root, 'libraries');
+ $this->setExpectedException(
+ 'RuntimeException',
+ 'CI Error: Non-existent class: '.ucfirst($lib)
+ );
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
+ }
+
+ // --------------------------------------------------------------------
+
public function test_library_extension()
{
// Create library and extension in VFS
@@ -131,6 +142,16 @@ class Loader_test extends CI_TestCase {
// Test is_loaded
$this->assertEquals($obj, $this->load->is_loaded(ucfirst($lib)));
+
+ // Test to load another class with the same object name
+ $lib = 'another_test_lib';
+ $class = ucfirst($lib);
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
+ $this->setExpectedException(
+ 'RuntimeException',
+ "CI Error: Resource '".$obj."' already exists and is not a ".$class." instance."
+ );
+ $this->load->library($lib, NULL, $obj);
}
// --------------------------------------------------------------------
@@ -270,12 +291,14 @@ class Loader_test extends CI_TestCase {
$this->assertEquals($content.$value, $out);
// Mock output class
- $output = $this->getMock('CI_Output', array('append_output'));
+ $output = $this->getMockBuilder('CI_Output')->setMethods(array('append_output'))->getMock();
$output->expects($this->once())->method('append_output')->with($content.$value);
$this->ci_instance_var('output', $output);
- // Test view output
- $this->assertInstanceOf('CI_Loader', $this->load->view($view, array($var => $value)));
+ // Test view output and $vars as an object
+ $vars = new stdClass();
+ $vars->$var = $value;
+ $this->assertInstanceOf('CI_Loader', $this->load->view($view, $vars));
}
// --------------------------------------------------------------------
@@ -420,7 +443,7 @@ class Loader_test extends CI_TestCase {
{
// Mock lang class and test load call
$file = 'test';
- $lang = $this->getMock('CI_Lang', array('load'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
$lang->expects($this->once())->method('load')->with($file);
$this->ci_instance_var('lang', $lang);
$this->assertInstanceOf('CI_Loader', $this->load->language($file));
diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php
new file mode 100644
index 000000000..d5a6fcb6b
--- /dev/null
+++ b/tests/codeigniter/core/Log_test.php
@@ -0,0 +1,63 @@
+<?php
+class Log_test extends CI_TestCase {
+
+ public function test_configuration()
+ {
+ $path = new ReflectionProperty('CI_Log', '_log_path');
+ $path->setAccessible(TRUE);
+ $threshold = new ReflectionProperty('CI_Log', '_threshold');
+ $threshold->setAccessible(TRUE);
+ $date_fmt = new ReflectionProperty('CI_Log', '_date_fmt');
+ $date_fmt->setAccessible(TRUE);
+ $file_ext = new ReflectionProperty('CI_Log', '_file_ext');
+ $file_ext->setAccessible(TRUE);
+ $file_perms = new ReflectionProperty('CI_Log', '_file_permissions');
+ $file_perms->setAccessible(TRUE);
+ $enabled = new ReflectionProperty('CI_Log', '_enabled');
+ $enabled->setAccessible(TRUE);
+
+ $this->ci_set_config('log_path', '/root/');
+ $this->ci_set_config('log_threshold', 'z');
+ $this->ci_set_config('log_date_format', 'd.m.Y');
+ $this->ci_set_config('log_file_extension', '');
+ $this->ci_set_config('log_file_permissions', '');
+ $instance = new CI_Log();
+
+ $this->assertEquals($path->getValue($instance), '/root/');
+ $this->assertEquals($threshold->getValue($instance), 1);
+ $this->assertEquals($date_fmt->getValue($instance), 'd.m.Y');
+ $this->assertEquals($file_ext->getValue($instance), 'php');
+ $this->assertEquals($file_perms->getValue($instance), 0644);
+ $this->assertEquals($enabled->getValue($instance), FALSE);
+
+ $this->ci_set_config('log_path', '');
+ $this->ci_set_config('log_threshold', '0');
+ $this->ci_set_config('log_date_format', '');
+ $this->ci_set_config('log_file_extension', '.log');
+ $this->ci_set_config('log_file_permissions', 0600);
+ $instance = new CI_Log();
+
+ $this->assertEquals($path->getValue($instance), APPPATH.'logs/');
+ $this->assertEquals($threshold->getValue($instance), 0);
+ $this->assertEquals($date_fmt->getValue($instance), 'Y-m-d H:i:s');
+ $this->assertEquals($file_ext->getValue($instance), 'log');
+ $this->assertEquals($file_perms->getValue($instance), 0600);
+ $this->assertEquals($enabled->getValue($instance), TRUE);
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_format_line()
+ {
+ $this->ci_set_config('log_path', '');
+ $this->ci_set_config('log_threshold', 0);
+ $instance = new CI_Log();
+
+ $format_line = new ReflectionMethod($instance, '_format_line');
+ $format_line->setAccessible(TRUE);
+ $this->assertEquals(
+ $format_line->invoke($instance, 'LEVEL', 'Timestamp', 'Message'),
+ "LEVEL - Timestamp --> Message\n"
+ );
+ }
+} \ No newline at end of file
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index bab76dffb..4dd31f4b1 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -12,7 +12,8 @@ class Security_test extends CI_TestCase {
$this->ci_set_config('csrf_token_name', 'ci_csrf_token');
$this->ci_set_config('csrf_cookie_name', 'ci_csrf_cookie');
- $this->security = new Mock_Core_Security();
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $this->security = new Mock_Core_Security('UTF-8');
}
// --------------------------------------------------------------------
@@ -96,7 +97,7 @@ class Security_test extends CI_TestCase {
$xss_clean_return = $this->security->xss_clean($harm_string, TRUE);
- $this->assertTrue($xss_clean_return);
+// $this->assertTrue($xss_clean_return);
}
// --------------------------------------------------------------------
@@ -115,7 +116,18 @@ class Security_test extends CI_TestCase {
public function test_xss_clean_entity_double_encoded()
{
$input = '<a href="&#38&#35&#49&#48&#54&#38&#35&#57&#55&#38&#35&#49&#49&#56&#38&#35&#57&#55&#38&#35&#49&#49&#53&#38&#35&#57&#57&#38&#35&#49&#49&#52&#38&#35&#49&#48&#53&#38&#35&#49&#49&#50&#38&#35&#49&#49&#54&#38&#35&#53&#56&#38&#35&#57&#57&#38&#35&#49&#49&#49&#38&#35&#49&#49&#48&#38&#35&#49&#48&#50&#38&#35&#49&#48&#53&#38&#35&#49&#49&#52&#38&#35&#49&#48&#57&#38&#35&#52&#48&#38&#35&#52&#57&#38&#35&#52&#49">Clickhere</a>';
- $this->assertEquals('<a >Clickhere</a>', $this->security->xss_clean($input));
+ $this->assertEquals('<a>Clickhere</a>', $this->security->xss_clean($input));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function text_xss_clean_js_link_removal()
+ {
+ // This one is to prevent a false positive
+ $this->assertEquals(
+ "<a href=\"javascrip\n<t\n:alert\n&#40;1&#41;\"\n>",
+ $this->security->xss_clean("<a href=\"javascrip\n<t\n:alert\n(1)\"\n>")
+ );
}
// --------------------------------------------------------------------
@@ -123,29 +135,113 @@ class Security_test extends CI_TestCase {
public function test_xss_clean_js_img_removal()
{
$input = '<img src="&#38&#35&#49&#48&#54&#38&#35&#57&#55&#38&#35&#49&#49&#56&#38&#35&#57&#55&#38&#35&#49&#49&#53&#38&#35&#57&#57&#38&#35&#49&#49&#52&#38&#35&#49&#48&#53&#38&#35&#49&#49&#50&#38&#35&#49&#49&#54&#38&#35&#53&#56&#38&#35&#57&#57&#38&#35&#49&#49&#49&#38&#35&#49&#49&#48&#38&#35&#49&#48&#50&#38&#35&#49&#48&#53&#38&#35&#49&#49&#52&#38&#35&#49&#48&#57&#38&#35&#52&#48&#38&#35&#52&#57&#38&#35&#52&#49">Clickhere';
- $this->assertEquals('<img >', $this->security->xss_clean($input));
+ $this->assertEquals('<img>', $this->security->xss_clean($input));
}
// --------------------------------------------------------------------
- public function test_xss_clean_sanitize_naughty_html()
+ public function test_xss_clean_sanitize_naughty_html_tags()
{
- $input = '<blink>';
- $this->assertEquals('&lt;blink&gt;', $this->security->xss_clean($input));
+ $this->assertEquals('&lt;unclosedTag', $this->security->xss_clean('<unclosedTag'));
+ $this->assertEquals('&lt;blink&gt;', $this->security->xss_clean('<blink>'));
+ $this->assertEquals('<fubar>', $this->security->xss_clean('<fubar>'));
+
+ $this->assertEquals(
+ '<img svg=""> src="x">',
+ $this->security->xss_clean('<img <svg=""> src="x">')
+ );
+
+ $this->assertEquals(
+ '<img src="b on=">on=">"x onerror="alert&#40;1&#41;">',
+ $this->security->xss_clean('<img src="b on="<x">on=">"x onerror="alert(1)">')
+ );
+
+ $this->assertEquals(
+ "\n>&lt;!-\n<b d=\"'e><iframe onload=alert&#40;1&#41; src=x>\n<a HREF=\">\n",
+ $this->security->xss_clean("\n><!-\n<b\n<c d=\"'e><iframe onload=alert(1) src=x>\n<a HREF=\"\">\n")
+ );
}
// --------------------------------------------------------------------
- public function test_remove_evil_attributes()
+ public function test_xss_clean_sanitize_naughty_html_attributes()
{
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo onAttribute="bar">', FALSE));
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo onAttributeNoQuotes=bar>', FALSE));
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo onAttributeWithSpaces = bar>', FALSE));
- $this->assertEquals('<foo prefixOnAttribute="bar">', $this->security->remove_evil_attributes('<foo prefixOnAttribute="bar">', FALSE));
- $this->assertEquals('<foo>onOutsideOfTag=test</foo>', $this->security->remove_evil_attributes('<foo>onOutsideOfTag=test</foo>', FALSE));
- $this->assertEquals('onNoTagAtAll = true', $this->security->remove_evil_attributes('onNoTagAtAll = true', FALSE));
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo fscommand=case-insensitive>', FALSE));
- $this->assertEquals('<foo [removed]>', $this->security->remove_evil_attributes('<foo seekSegmentTime=whatever>', FALSE));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttribute="bar">'));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttributeNoQuotes=bar>'));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo onAttributeWithSpaces = bar>'));
+ $this->assertEquals('<foo prefixOnAttribute="bar">', $this->security->xss_clean('<foo prefixOnAttribute="bar">'));
+ $this->assertEquals('<foo>onOutsideOfTag=test</foo>', $this->security->xss_clean('<foo>onOutsideOfTag=test</foo>'));
+ $this->assertEquals('onNoTagAtAll = true', $this->security->xss_clean('onNoTagAtAll = true'));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo fscommand=case-insensitive>'));
+ $this->assertEquals('<foo xss=removed>', $this->security->xss_clean('<foo seekSegmentTime=whatever>'));
+
+ $this->assertEquals(
+ '<foo bar=">" baz=\'>\' xss=removed>',
+ $this->security->xss_clean('<foo bar=">" baz=\'>\' onAfterGreaterThan="quotes">')
+ );
+ $this->assertEquals(
+ '<foo bar=">" baz=\'>\' xss=removed>',
+ $this->security->xss_clean('<foo bar=">" baz=\'>\' onAfterGreaterThan=noQuotes>')
+ );
+
+ $this->assertEquals(
+ '<img src="x" on=""> on=&lt;svg&gt; onerror=alert&#40;1&#41;>',
+ $this->security->xss_clean('<img src="x" on=""> on=<svg> onerror=alert(1)>')
+ );
+
+ $this->assertEquals(
+ '<img src="on=\'">"&lt;svg&gt; onerror=alert&#40;1&#41; onmouseover=alert&#40;1&#41;>',
+ $this->security->xss_clean('<img src="on=\'">"<svg> onerror=alert(1) onmouseover=alert(1)>')
+ );
+
+ $this->assertEquals(
+ '<img src="x"> on=\'x\' onerror=``,alert&#40;1&#41;>',
+ $this->security->xss_clean('<img src="x"> on=\'x\' onerror=``,alert(1)>')
+ );
+
+ $this->assertEquals(
+ '<a xss=removed>',
+ $this->security->xss_clean('<a< onmouseover="alert(1)">')
+ );
+
+ $this->assertEquals(
+ '<img src="x"> on=\'x\' onerror=,xssm()>',
+ $this->security->xss_clean('<img src="x"> on=\'x\' onerror=,xssm()>')
+ );
+
+ $this->assertEquals(
+ '<image src="<>" xss=removed>',
+ $this->security->xss_clean('<image src="<>" onerror=\'alert(1)\'>')
+ );
+
+ $this->assertEquals(
+ '<b xss=removed>',
+ $this->security->xss_clean('<b "=<= onmouseover=alert(1)>')
+ );
+
+ $this->assertEquals(
+ '<b xss=removed xss=removed>1">',
+ $this->security->xss_clean('<b a=<=" onmouseover="alert(1),1>1">')
+ );
+
+ $this->assertEquals(
+ '<b x=" onmouseover=alert&#40;1&#41;//">',
+ $this->security->xss_clean('<b "="< x=" onmouseover=alert(1)//">')
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * @depends test_xss_clean_sanitize_naughty_html_tags
+ * @depends test_xss_clean_sanitize_naughty_html_attributes
+ */
+ public function test_naughty_html_plus_evil_attributes()
+ {
+ $this->assertEquals(
+ '&lt;svg<img src="x" xss=removed>',
+ $this->security->xss_clean('<svg<img > src="x" onerror="location=/javascript/.source+/:alert/.source+/(1)/.source">')
+ );
}
// --------------------------------------------------------------------
@@ -180,6 +276,12 @@ class Security_test extends CI_TestCase {
$this->assertEquals('<div>Hello <b>Booya</b></div>', $decoded);
+ $this->assertEquals('colon:', $this->security->entity_decode('colon&colon;'));
+ $this->assertEquals("NewLine\n", $this->security->entity_decode('NewLine&NewLine;'));
+ $this->assertEquals("Tab\t", $this->security->entity_decode('Tab&Tab;'));
+ $this->assertEquals("lpar(", $this->security->entity_decode('lpar&lpar;'));
+ $this->assertEquals("rpar)", $this->security->entity_decode('rpar&rpar;'));
+
// Issue #3057 (https://github.com/bcit-ci/CodeIgniter/issues/3057)
$this->assertEquals(
'&foo should not include a semicolon',
@@ -209,7 +311,8 @@ class Security_test extends CI_TestCase {
'<img src="mdn-logo-sm.png" alt="MD Logo" srcset="mdn-logo-HD.png 2x, mdn-logo-small.png 15w, mdn-banner-HD.png 100w 2x" />',
'<img sqrc="/img/sunset.gif" height="100%" width="100%">',
'<img srqc="/img/sunset.gif" height="100%" width="100%">',
- '<img srcq="/img/sunset.gif" height="100%" width="100%">'
+ '<img srcq="/img/sunset.gif" height="100%" width="100%">',
+ '<img src=non-quoted.attribute foo="bar">'
);
$urls = array(
@@ -220,7 +323,8 @@ class Security_test extends CI_TestCase {
'mdn-logo-sm.png',
'<img sqrc="/img/sunset.gif" height="100%" width="100%">',
'<img srqc="/img/sunset.gif" height="100%" width="100%">',
- '<img srcq="/img/sunset.gif" height="100%" width="100%">'
+ '<img srcq="/img/sunset.gif" height="100%" width="100%">',
+ 'non-quoted.attribute'
);
for ($i = 0; $i < count($imgtags); $i++)
@@ -243,7 +347,7 @@ class Security_test extends CI_TestCase {
// leave csrf_cookie_name as blank to test _csrf_set_hash function
$this->ci_set_config('csrf_cookie_name', '');
- $this->security = new Mock_Core_Security();
+ $this->security = new Mock_Core_Security('UTF-8');
$this->assertNotEmpty($this->security->get_csrf_hash());
}
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index 42dff3639..f862c666e 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -119,8 +119,13 @@ class URI_test extends CI_TestCase {
*/
// --------------------------------------------------------------------
+ /**
+ * @runInSeparateProcess
+ */
public function test_filter_uri_passing()
{
+ define('UTF8_ENABLED', FALSE);
+
$this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-');
$str = 'abc01239~%.:_-';
@@ -129,8 +134,12 @@ class URI_test extends CI_TestCase {
// --------------------------------------------------------------------
+ /**
+ * @runInSeparateProcess
+ */
public function test_filter_uri_throws_error()
{
+ define('UTF8_ENABLED', FALSE);
$this->setExpectedException('RuntimeException');
$this->uri->config->set_item('enable_query_strings', FALSE);
diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php
index 7e6ffd930..f40bb9848 100644
--- a/tests/codeigniter/core/Utf8_test.php
+++ b/tests/codeigniter/core/Utf8_test.php
@@ -1,31 +1,27 @@
<?php
+/**
+ * @runTestsInSeparateProcesses
+ */
class Utf8_test extends CI_TestCase {
- public function set_up()
+ public function test___constructUTF8_ENABLED()
{
- $this->ci_set_config('charset', 'UTF-8');
- $this->utf8 = new Mock_Core_Utf8();
- $this->ci_instance_var('utf8', $this->utf8);
+ if ( ! defined('PREG_BAD_UTF8_ERROR') OR (ICONV_ENABLED === FALSE && MB_ENABLED === FALSE))
+ {
+ return $this->markTestSkipped('PCRE_UTF8 and/or both ext/mbstring & ext/iconv are unavailable');
+ }
+
+ new CI_Utf8('UTF-8');
+ $this->assertTrue(UTF8_ENABLED);
}
// --------------------------------------------------------------------
- /**
- * __construct() test
- *
- * @covers CI_Utf8::__construct
- */
- public function test___construct()
+ public function test__constructUTF8_DISABLED()
{
- if (defined('PREG_BAD_UTF8_ERROR') && (ICONV_ENABLED === TRUE OR MB_ENABLED === TRUE) && strtoupper(config_item('charset')) === 'UTF-8')
- {
- $this->assertTrue(UTF8_ENABLED);
- }
- else
- {
- $this->assertFalse(UTF8_ENABLED);
- }
+ new CI_Utf8('WINDOWS-1251');
+ $this->assertFalse(UTF8_ENABLED);
}
// --------------------------------------------------------------------
@@ -37,8 +33,9 @@ class Utf8_test extends CI_TestCase {
*/
public function test_is_ascii()
{
- $this->assertTrue($this->utf8->is_ascii('foo bar'));
- $this->assertFalse($this->utf8->is_ascii('теÑÑ‚'));
+ $utf8 = new CI_Utf8('UTF-8');
+ $this->assertTrue($utf8->is_ascii('foo bar'));
+ $this->assertFalse($utf8->is_ascii('теÑÑ‚'));
}
// --------------------------------------------------------------------
@@ -51,21 +48,22 @@ class Utf8_test extends CI_TestCase {
*/
public function test_clean_string()
{
- $this->assertEquals('foo bar', $this->utf8->clean_string('foo bar'));
+ $utf8 = new CI_Utf8('UTF-8');
+ $this->assertEquals('foo bar', $utf8->clean_string('foo bar'));
$illegal_utf8 = "\xc0теÑÑ‚";
if (MB_ENABLED)
{
- $this->assertEquals('теÑÑ‚', $this->utf8->clean_string($illegal_utf8));
+ $this->assertEquals('теÑÑ‚', $utf8->clean_string($illegal_utf8));
}
elseif (ICONV_ENABLED)
{
// This is a known issue, iconv doesn't always work with //IGNORE
- $this->assertTrue(in_array($this->utf8->clean_string($illegal_utf8), array('теÑÑ‚', ''), TRUE));
+ $this->assertTrue(in_array($utf8->clean_string($illegal_utf8), array('теÑÑ‚', ''), TRUE));
}
else
{
- $this->assertEquals($illegal_utf8, $this->utf8->clean_string($illegal_utf8));
+ $this->assertEquals($illegal_utf8, $utf8->clean_string($illegal_utf8));
}
}
@@ -78,14 +76,15 @@ class Utf8_test extends CI_TestCase {
*/
public function test_convert_to_utf8()
{
+ $utf8 = new CI_Utf8('UTF-8');
if (MB_ENABLED OR ICONV_ENABLED)
{
- $this->assertEquals('теÑÑ‚', $this->utf8->convert_to_utf8('òåñò', 'WINDOWS-1251'));
+ $this->assertEquals('теÑÑ‚', $utf8->convert_to_utf8('òåñò', 'WINDOWS-1251'));
}
else
{
- $this->assertFalse($this->utf8->convert_to_utf8('òåñò', 'WINDOWS-1251'));
+ $this->assertFalse($utf8->convert_to_utf8('òåñò', 'WINDOWS-1251'));
}
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/core/compat/password_test.php b/tests/codeigniter/core/compat/password_test.php
index 8a507d14a..77f5eba4e 100644
--- a/tests/codeigniter/core/compat/password_test.php
+++ b/tests/codeigniter/core/compat/password_test.php
@@ -8,11 +8,6 @@ class password_test extends CI_TestCase {
{
return $this->markTestSkipped('ext/standard/password is available on PHP 5.5');
}
- elseif ( ! is_php('5.3.7'))
- {
- $this->assertFalse(defined('PASSWORD_BCRYPT'));
- return $this->markTestSkipped("PHP versions prior to 5.3.7 don't have the '2y' Blowfish version");
- }
// defined as of HHVM 2.3.0, which is also when they introduce password_*() as well
// Note: Do NOT move this after the CRYPT_BLOWFISH check
elseif (defined('HHVM_VERSION'))
diff --git a/tests/codeigniter/core/compat/standard_test.php b/tests/codeigniter/core/compat/standard_test.php
index 4077a5c7c..54424bb9b 100644
--- a/tests/codeigniter/core/compat/standard_test.php
+++ b/tests/codeigniter/core/compat/standard_test.php
@@ -10,18 +10,6 @@ class standard_test extends CI_TestCase {
}
$this->assertTrue(function_exists('array_column'));
-
- if ( ! is_php('5.4'))
- {
- $this->assertTrue(function_exists('hex2bin'));
- }
-
- if ( ! is_php('5.3'))
- {
- $this->assertTrue(function_exists('array_replace'));
- $this->assertTrue(function_exists('array_replace_recursive'));
- $this->assertTrue(function_exists('quoted_printable_encode'));
- }
}
// ------------------------------------------------------------------------
@@ -337,212 +325,6 @@ class standard_test extends CI_TestCase {
array_column($input, 'b', 'a')
);
}
-
- // ------------------------------------------------------------------------
-
- /**
- * hex2bin() tests
- *
- * @depends test_bootstrap
- */
- public function test_hex2bin()
- {
- if (is_php('5.4'))
- {
- return $this->markTestSkipped('hex2bin() is already available on PHP 5.4');
- }
-
- $this->assertEquals("\x03\x04", hex2bin("0304"));
- $this->assertEquals('', hex2bin(''));
- $this->assertEquals("\x01\x02\x03", hex2bin(new FooHex()));
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * array_replace(), array_replace_recursive() tests
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_array_replace_recursive()
- {
- if (is_php('5.3'))
- {
- return $this->markTestSkipped('array_replace() and array_replace_recursive() are already available on PHP 5.3');
- }
-
- $array1 = array(
- 0 => 'dontclobber',
- '1' => 'unclobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => TRUE,
- 1 => array(
- 'testsubarray1' => 'dontclobber2',
- 'testsubarray2' => 'dontclobber3'
- )
- )
- );
-
- $array2 = array(
- 1 => 'clobbered',
- 'test3' => array(
- 'testarray2' => FALSE
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- );
-
- // array_replace()
- $this->assertEquals(
- array(
- 0 => 'dontclobber',
- 1 => 'clobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => FALSE
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- ),
- array_replace($array1, $array2)
- );
-
- // array_replace_recursive()
- $this->assertEquals(
- array(
- 0 => 'dontclobber',
- 1 => 'clobbered',
- 'test2' => 0.0,
- 'test3' => array(
- 'testarray2' => FALSE,
- 1 => array(
- 'testsubarray1' => 'dontclobber2',
- 'testsubarray2' => 'dontclobber3'
- )
- ),
- 'test4' => array(
- 'clobbered3' => array(0, 1, 2)
- )
- ),
- array_replace_recursive($array1, $array2)
- );
- }
-
- // ------------------------------------------------------------------------
-
- /**
- * quoted_printable_encode() tests
- *
- * Borrowed from PHP's own tests
- *
- * @depends test_bootstrap
- */
- public function test_quoted_printable_encode()
- {
- if (is_php('5.3'))
- {
- 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:
- // NB this appears to be a bug in cclient; a space at end of string should be encoded as =20
- $this->assertEquals("String with space at end ", quoted_printable_encode("String with space at end "));
- $this->assertEquals("String with tabs =09=09 in middle", quoted_printable_encode("String with tabs \t\t in middle"));
- $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"
- ."=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"
- ."=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"
- ."=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"
- ."=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"
- ."=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"
- ."=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"
- ."=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",
- $d = quoted_printable_encode(str_repeat("\0", 200))
- );
- $this->assertEquals(str_repeat("\x0", 200), quoted_printable_decode($d));
- $this->assertEquals(
- "=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=\r\n"
- ."=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=\r\n"
- ."=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=\r\n"
- ."=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=\r\n"
- ."=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=\r\n"
- ."=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=\r\n"
- ."=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=\r\n"
- ."=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=\r\n"
- ."=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =\r\n"
- ."=D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=\r\n"
- ."=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=\r\n"
- ."=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=\r\n"
- ."=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=\r\n"
- ."=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=\r\n"
- ."=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=\r\n"
- ."=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=\r\n"
- ."=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=\r\n"
- ."=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=\r\n"
- ."=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=\r\n"
- ."=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =\r\n"
- ."=D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=\r\n"
- ."=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=\r\n"
- ."=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=\r\n"
- ."=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=\r\n"
- ."=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=\r\n"
- ."=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=\r\n"
- ."=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=\r\n"
- ."=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=\r\n"
- ."=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=\r\n"
- ."=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=\r\n"
- ."=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=\r\n"
- ."=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =\r\n"
- ."=D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=\r\n"
- ."=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=\r\n"
- ."=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=\r\n"
- ."=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=\r\n"
- ."=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=\r\n"
- ."=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=\r\n"
- ."=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=\r\n"
- ."=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=\r\n"
- ."=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=\r\n"
- ."=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=\r\n"
- ."=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =\r\n"
- ."=D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=\r\n"
- ."=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=\r\n"
- ."=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=\r\n"
- ."=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=\r\n"
- ."=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=\r\n"
- ."=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=\r\n"
- ."=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=\r\n"
- ."=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=\r\n"
- ."=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=\r\n"
- ."=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=\r\n"
- ."=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=\r\n"
- ."=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =\r\n"
- ."=D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=\r\n"
- ."=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=\r\n"
- ."=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=\r\n"
- ."=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=8E=D0=BD=D0=B8=\r\n"
- ."=D0=BA=D0=BE=D0=B4=D0=B5=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B0 =D0=B2 =D1=\r\n"
- ."=8E=D0=BD=D0=B8=D0=BA=D0=BE=D0=B4=D0=B5",
- $d = quoted_printable_encode(str_repeat('Ñтрока в юникоде', 50))
- );
- $this->assertEquals(str_repeat('Ñтрока в юникоде', 50), quoted_printable_decode($d));
- $this->assertEquals('this is a foo', quoted_printable_encode(new FooObject()));
- }
}
// ------------------------------------------------------------------------
@@ -562,19 +344,3 @@ class Bar {
return 'first_name';
}
}
-
-class FooHex {
-
- public function __toString()
- {
- return '010203';
- }
-}
-
-class FooObject
-{
- public function __toString()
- {
- return 'this is a foo';
- }
-} \ No newline at end of file
diff --git a/tests/codeigniter/database/DB_driver_test.php b/tests/codeigniter/database/DB_driver_test.php
index 26416d3fc..13e9abf84 100644
--- a/tests/codeigniter/database/DB_driver_test.php
+++ b/tests/codeigniter/database/DB_driver_test.php
@@ -7,8 +7,6 @@ class DB_driver_test extends CI_TestCase {
$config = Mock_Database_DB::config(DB_DRIVER);
sscanf(DB_DRIVER, '%[^/]/', $driver_name);
$driver = $this->{$driver_name}($config[DB_DRIVER]);
-
- $this->assertTrue($driver->initialize());
}
protected function pdo($config)
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
index 25bd4accb..54b2a4e18 100644
--- a/tests/codeigniter/database/query_builder/join_test.php
+++ b/tests/codeigniter/database/query_builder/join_test.php
@@ -37,6 +37,29 @@ class Join_test extends CI_TestCase {
// ------------------------------------------------------------------------
+ public function test_join_escape_is_null()
+ {
+ $expected = 'SELECT '.$this->db->escape_identifiers('field')
+ ."\nFROM ".$this->db->escape_identifiers('table1')
+ ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NULL';
+
+ $this->assertEquals(
+ $expected,
+ $this->db->select('field')->from('table1')->join('table2', 'field IS NULL')->get_compiled_select()
+ );
+
+ $expected = 'SELECT '.$this->db->escape_identifiers('field')
+ ."\nFROM ".$this->db->escape_identifiers('table1')
+ ."\nJOIN ".$this->db->escape_identifiers('table2').' ON '.$this->db->escape_identifiers('field').' IS NOT NULL';
+
+ $this->assertEquals(
+ $expected,
+ $this->db->select('field')->from('table1')->join('table2', 'field IS NOT NULL')->get_compiled_select()
+ );
+ }
+
+ // ------------------------------------------------------------------------
+
public function test_join_escape_multiple_conditions()
{
// We just need a valid query produced, not one that makes sense
@@ -55,4 +78,24 @@ class Join_test extends CI_TestCase {
$this->assertEquals($expected, $result);
}
+ // ------------------------------------------------------------------------
+
+ public function test_join_escape_multiple_conditions_with_parentheses()
+ {
+ // We just need a valid query produced, not one that makes sense
+ $fields = array($this->db->protect_identifiers('table1.field1'), $this->db->protect_identifiers('table2.field2'));
+
+ $expected = 'SELECT '.implode(', ', $fields)
+ ."\nFROM ".$this->db->escape_identifiers('table1')
+ ."\nRIGHT JOIN ".$this->db->escape_identifiers('table2').' ON '.implode(' = ', $fields)
+ .' AND ('.$fields[0]." = 'foo' OR ".$fields[1].' IS NULL)';
+
+ $result = $this->db->select('table1.field1, table2.field2')
+ ->from('table1')
+ ->join('table2', "table1.field1 = table2.field2 AND (table1.field1 = 'foo' OR table2.field2 IS NULL)", 'RIGHT')
+ ->get_compiled_select();
+
+ $this->assertEquals($expected, $result);
+ }
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/where_test.php b/tests/codeigniter/database/query_builder/where_test.php
index 20b7a567c..46a7fa2eb 100644
--- a/tests/codeigniter/database/query_builder/where_test.php
+++ b/tests/codeigniter/database/query_builder/where_test.php
@@ -123,4 +123,12 @@ class Where_test extends CI_TestCase {
$this->assertEquals('Musician', $jobs[1]['name']);
}
+ // ------------------------------------------------------------------------
+
+ public function test_issue4093()
+ {
+ $input = 'bar and baz or qux';
+ $sql = $this->db->where('foo', $input)->get_compiled_select('dummy');
+ $this->assertEquals("'".$input."'", substr($sql, -20));
+ }
} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/cookie_helper_test.php b/tests/codeigniter/helpers/cookie_helper_test.php
index fba68f20f..e984be21c 100644
--- a/tests/codeigniter/helpers/cookie_helper_test.php
+++ b/tests/codeigniter/helpers/cookie_helper_test.php
@@ -28,10 +28,9 @@ class Cookie_helper_test extends CI_TestCase {
{
$_COOKIE['foo'] = 'bar';
- $security = new Mock_Core_Security();
- $utf8 = new Mock_Core_Utf8();
+ $security = new Mock_Core_Security('UTF-8');
$input_cls = $this->ci_core_class('input');
- $this->ci_instance_var('input', new Mock_Core_Input($security, $utf8));
+ $this->ci_instance_var('input', new CI_Input($security));
$this->assertEquals('bar', get_cookie('foo', FALSE));
$this->assertEquals('bar', get_cookie('foo', TRUE));
@@ -56,4 +55,4 @@ class Cookie_helper_test extends CI_TestCase {
$this->markTestSkipped('Need to find a way to overcome a headers already set exception');
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/date_helper_test.php b/tests/codeigniter/helpers/date_helper_test.php
index c80e92cd0..8d0317dcb 100644
--- a/tests/codeigniter/helpers/date_helper_test.php
+++ b/tests/codeigniter/helpers/date_helper_test.php
@@ -10,12 +10,20 @@ class Date_helper_test extends CI_TestCase {
// ------------------------------------------------------------------------
+ public function test_nice_date()
+ {
+ $this->assertEquals('2016-11-01', nice_date('201611', 'Y-m-d'));
+ $this->assertEquals('2016-11-23', nice_date('20161123', 'Y-m-d'));
+ }
+
+ // ------------------------------------------------------------------------
+
public function test_now_local()
{
/*
// This stub job, is simply to cater $config['time_reference']
- $config = $this->getMock('CI_Config');
+ $config = $this->getMockBuilder('CI_Config')->getMock();
$config->expects($this->any())
->method('item')
->will($this->returnValue('local'));
@@ -37,7 +45,7 @@ class Date_helper_test extends CI_TestCase {
/*
// This stub job, is simply to cater $config['time_reference']
- $config = $this->getMock('CI_Config');
+ $config = $this->getMockBuilder('CI_Config')->getMock();
$config->expects($this->any())
->method('item')
->will($this->returnValue('UTC'));
@@ -65,106 +73,6 @@ class Date_helper_test extends CI_TestCase {
// ------------------------------------------------------------------------
- public function test_standard_date_rfc822()
- {
- $this->assertEquals(
- date(DATE_RFC822, $this->time),
- standard_date('DATE_RFC822', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_atom()
- {
- $this->assertEquals(
- date(DATE_ATOM, $this->time),
- standard_date('DATE_ATOM', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_cookie()
- {
- $this->assertEquals(
- date(DATE_COOKIE, $this->time),
- standard_date('DATE_COOKIE', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_iso8601()
- {
- $this->assertEquals(
- date(DATE_ISO8601, $this->time),
- standard_date('DATE_ISO8601', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc850()
- {
- $this->assertEquals(
- date(DATE_RFC850, $this->time),
- standard_date('DATE_RFC850', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc1036()
- {
- $this->assertEquals(
- date(DATE_RFC1036, $this->time),
- standard_date('DATE_RFC1036', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc1123()
- {
- $this->assertEquals(
- date(DATE_RFC1123, $this->time),
- standard_date('DATE_RFC1123', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rfc2822()
- {
- $this->assertEquals(
- date(DATE_RFC2822, $this->time),
- standard_date('DATE_RFC2822', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_rss()
- {
- $this->assertEquals(
- date(DATE_RSS, $this->time),
- standard_date('DATE_RSS', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
- public function test_standard_date_w3c()
- {
- $this->assertEquals(
- date(DATE_W3C, $this->time),
- standard_date('DATE_W3C', $this->time)
- );
- }
-
- // ------------------------------------------------------------------------
-
public function test_timespan()
{
$this->ci_vfs_clone('system/language/english/date_lang.php');
@@ -288,7 +196,7 @@ class Date_helper_test extends CI_TestCase {
}
$this->assertArrayHasKey('UP3', timezones());
- $this->assertEquals(0, timezones('non_existant'));
+ $this->assertEquals(0, timezones('non_existent'));
}
// ------------------------------------------------------------------------
diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php
deleted file mode 100644
index 529e96910..000000000
--- a/tests/codeigniter/helpers/email_helper_test.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-class Email_helper_test extends CI_TestCase {
-
- public function set_up()
- {
- $this->helper('email');
- }
-
- public function test_valid_email()
- {
- $this->assertEquals(FALSE, valid_email('test'));
- $this->assertEquals(FALSE, valid_email('test@test@test.com'));
- $this->assertEquals(TRUE, valid_email('test@test.com'));
- $this->assertEquals(TRUE, valid_email('my.test@test.com'));
- $this->assertEquals(TRUE, valid_email('my.test@subdomain.test.com'));
- }
-
- public function test_send_mail()
- {
- $this->markTestSkipped("Can't test");
- }
-
-} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php
index c31817595..5ed8cb5c0 100644
--- a/tests/codeigniter/helpers/file_helper_test.php
+++ b/tests/codeigniter/helpers/file_helper_test.php
@@ -14,19 +14,6 @@ class File_helper_Test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_read_file()
- {
- $this->assertFalse(read_file('does_not_exist'));
-
- $content = 'Jack and Jill went up the mountain to fight a billy goat.';
-
- $file = vfsStream::newFile('my_file.txt')->withContent($content)->at($this->_test_dir);
-
- $this->assertEquals($content, read_file(vfsStream::url('my_file.txt')));
- }
-
- // --------------------------------------------------------------------
-
public function test_octal_permissions()
{
$content = 'Jack and Jill went up the mountain to fight a billy goat.';
@@ -144,4 +131,4 @@ class File_helper_Test extends CI_TestCase {
$this->assertTrue(write_file(vfsStream::url('write.txt'), $content));
}
-} \ 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 b5fe99b96..4ecfaa5f7 100644
--- a/tests/codeigniter/helpers/form_helper_test.php
+++ b/tests/codeigniter/helpers/form_helper_test.php
@@ -271,20 +271,4 @@ EOH;
$this->assertEquals($expected, form_close('</div></div>'));
}
-
- // ------------------------------------------------------------------------
-
- public function test_form_prep()
- {
- $this->assertEquals(
- 'Here is a string containing &quot;quoted&quot; text.',
- form_prep('Here is a string containing "quoted" text.')
- );
-
- $this->assertEquals(
- 'Here is a string containing a &lt;tag&gt;.',
- form_prep('Here is a string containing a <tag>.', TRUE)
- );
- }
-
}
diff --git a/tests/codeigniter/helpers/html_helper_test.php b/tests/codeigniter/helpers/html_helper_test.php
index d66ad895c..5565e011b 100644
--- a/tests/codeigniter/helpers/html_helper_test.php
+++ b/tests/codeigniter/helpers/html_helper_test.php
@@ -9,13 +9,6 @@ class Html_helper_test extends CI_TestCase {
// ------------------------------------------------------------------------
- public function test_br()
- {
- $this->assertEquals('<br /><br />', br(2));
- }
-
- // ------------------------------------------------------------------------
-
public function test_heading()
{
$this->assertEquals('<h1>foobar</h1>', heading('foobar'));
@@ -72,21 +65,26 @@ EOH;
// ------------------------------------------------------------------------
- public function test_NBS()
- {
- $this->assertEquals('&nbsp;&nbsp;&nbsp;', nbs(3));
- }
-
- // ------------------------------------------------------------------------
-
public function test_meta()
{
- $this->assertEquals("<meta name=\"test\" content=\"foo\" />\n", meta('test', 'foo'));
-
- $expect = "<meta name=\"foo\" content=\"\" />\n";
-
- $this->assertEquals($expect, meta(array('name' => 'foo')));
-
+ $this->assertEquals(
+ "<meta name=\"test\" content=\"foo\" />\n",
+ meta('test', 'foo')
+ );
+
+ $this->assertEquals(
+ "<meta name=\"foo\" content=\"\" />\n",
+ meta(array('name' => 'foo'))
+ );
+
+ $this->assertEquals(
+ "<meta charset=\"foo\" />\n",
+ meta(array('name' => 'foo', 'type' => 'charset'))
+ );
+
+ $this->assertEquals(
+ "<meta charset=\"foo\" />\n",
+ meta(array('name' => 'foo', 'type' => 'charset'))
+ );
}
-
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php
index 81ce5e394..4a1e64fae 100644
--- a/tests/codeigniter/helpers/inflector_helper_test.php
+++ b/tests/codeigniter/helpers/inflector_helper_test.php
@@ -93,4 +93,23 @@ class Inflector_helper_test extends CI_TestCase {
}
}
+ // --------------------------------------------------------------------
+
+ public function test_ordinal_format()
+ {
+ $strs = array(
+ 1 => '1st',
+ 2 => '2nd',
+ 4 => '4th',
+ 11 => '11th',
+ 12 => '12th',
+ 13 => '13th',
+ 'something else' => 'something else',
+ );
+
+ foreach ($strs as $str => $expect)
+ {
+ $this->assertEquals($expect, ordinal_format($str));
+ }
+ }
} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/language_helper_test.php b/tests/codeigniter/helpers/language_helper_test.php
index 176da689a..1ddabea3d 100644
--- a/tests/codeigniter/helpers/language_helper_test.php
+++ b/tests/codeigniter/helpers/language_helper_test.php
@@ -5,7 +5,7 @@ class Language_helper_test extends CI_TestCase {
public function test_lang()
{
$this->helper('language');
- $lang = $this->getMock('CI_Lang', array('line'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('line'))->getMock();
$lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
$this->ci_instance_var('lang', $lang);
@@ -13,4 +13,4 @@ class Language_helper_test extends CI_TestCase {
$this->assertEquals('<label for="foo" class="bar"></label>', lang(1, 'foo', array('class' => 'bar')));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php
index 817db2c7e..663e354fe 100644
--- a/tests/codeigniter/helpers/number_helper_test.php
+++ b/tests/codeigniter/helpers/number_helper_test.php
@@ -11,7 +11,7 @@ class Number_helper_test extends CI_TestCase {
// Mock away load, too much going on in there,
// we'll just check for the expected parameter
- $lang = $this->getMock($lang_cls, array('load'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
$lang->expects($this->once())
->method('load')
->with($this->equalTo('number'));
@@ -60,4 +60,4 @@ class Number_helper_test extends CI_TestCase {
$this->assertEquals('112,283.3 TB', byte_format(123456789123456789));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/security_helper_test.php b/tests/codeigniter/helpers/security_helper_test.php
index effd3ec02..d7e3f4734 100644
--- a/tests/codeigniter/helpers/security_helper_test.php
+++ b/tests/codeigniter/helpers/security_helper_test.php
@@ -6,7 +6,7 @@ class Security_helper_tests extends CI_TestCase {
{
$this->helper('security');
$obj = new stdClass;
- $obj->security = new Mock_Core_Security();
+ $obj->security = new Mock_Core_Security('UTF-8');
$this->ci_instance($obj);
}
@@ -25,30 +25,6 @@ class Security_helper_tests extends CI_TestCase {
$this->assertEquals('foo', sanitize_filename($filename));
}
- function test_do_hash()
- {
- $md5 = md5('foo');
- $sha1 = sha1('foo');
-
- $algos = hash_algos();
- $algo_results = array();
- foreach ($algos as $k => $v)
- {
- $algo_results[$v] = hash($v, 'foo');
- }
-
- $this->assertEquals($sha1, do_hash('foo'));
- $this->assertEquals($sha1, do_hash('foo', 'sha1'));
- $this->assertEquals($md5, do_hash('foo', 'md5'));
- $this->assertEquals($md5, do_hash('foo', 'foobar'));
-
- // Test each algorithm available to PHP
- foreach ($algo_results as $algo => $result)
- {
- $this->assertEquals($result, do_hash('foo', $algo));
- }
- }
-
function test_strip_image_tags()
{
$this->assertEquals('http://example.com/spacer.gif', strip_image_tags('http://example.com/spacer.gif'));
@@ -61,4 +37,4 @@ class Security_helper_tests extends CI_TestCase {
$this->assertEquals('&lt;? echo $foo; ?&gt;', encode_php_tags('<? echo $foo; ?>'));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php
index 75701ec13..6de336b01 100644
--- a/tests/codeigniter/helpers/string_helper_test.php
+++ b/tests/codeigniter/helpers/string_helper_test.php
@@ -22,19 +22,6 @@ class String_helper_test extends CI_TestCase {
$this->assertEquals($expected, strip_slashes($str));
}
- public function test_trim_slashes()
- {
- $strs = array(
- '//Slashes//\/' => 'Slashes//\\',
- '/var/www/html/' => 'var/www/html'
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, trim_slashes($str));
- }
- }
-
// --------------------------------------------------------------------
public function test_strip_quotes()
@@ -108,23 +95,6 @@ class String_helper_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_repeater()
- {
- $strs = array(
- 'a' => 'aaaaaaaaaa',
- '&nbsp;' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
- '<br>' => '<br><br><br><br><br><br><br><br><br><br>'
-
- );
-
- foreach ($strs as $str => $expect)
- {
- $this->assertEquals($expect, repeater($str, 10));
- }
- }
-
- // --------------------------------------------------------------------
-
public function test_random_string()
{
$this->assertEquals(16, strlen(random_string('alnum', 16)));
@@ -145,4 +115,4 @@ class String_helper_test extends CI_TestCase {
$this->assertEquals(124, increment_string('123', ''));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php
index 7a7dc0a12..36465f203 100644
--- a/tests/codeigniter/helpers/text_helper_test.php
+++ b/tests/codeigniter/helpers/text_helper_test.php
@@ -2,21 +2,19 @@
class Text_helper_test extends CI_TestCase {
- private $_long_string;
-
public function set_up()
{
$this->helper('text');
-
- $this->_long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.';
}
// ------------------------------------------------------------------------
public function test_word_limiter()
{
- $this->assertEquals('Once upon a time,&#8230;', word_limiter($this->_long_string, 4));
- $this->assertEquals('Once upon a time,&hellip;', word_limiter($this->_long_string, 4, '&hellip;'));
+ $long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.';
+
+ $this->assertEquals('Once upon a time,&#8230;', word_limiter($long_string, 4));
+ $this->assertEquals('Once upon a time,&hellip;', word_limiter($long_string, 4, '&hellip;'));
$this->assertEquals('', word_limiter('', 4));
}
@@ -24,8 +22,10 @@ class Text_helper_test extends CI_TestCase {
public function test_character_limiter()
{
- $this->assertEquals('Once upon a time, a&#8230;', character_limiter($this->_long_string, 20));
- $this->assertEquals('Once upon a time, a&hellip;', character_limiter($this->_long_string, 20, '&hellip;'));
+ $long_string = 'Once upon a time, a framework had no tests. It sad. So some nice people began to write tests. The more time that went on, the happier it became. Everyone was happy.';
+
+ $this->assertEquals('Once upon a time, a&#8230;', character_limiter($long_string, 20));
+ $this->assertEquals('Once upon a time, a&hellip;', character_limiter($long_string, 20, '&hellip;'));
$this->assertEquals('Short', character_limiter('Short', 20));
$this->assertEquals('Short', character_limiter('Short', 5));
}
@@ -103,8 +103,13 @@ class Text_helper_test extends CI_TestCase {
// ------------------------------------------------------------------------
+ /**
+ * @runInSeparateProcess
+ */
public function test_highlight_phrase()
{
+ define('UTF8_ENABLED', FALSE);
+
$strs = array(
'this is a phrase' => '<mark>this is</mark> a phrase',
'this is another' => '<mark>this is</mark> another',
@@ -171,4 +176,4 @@ class Text_helper_test extends CI_TestCase {
$this->assertEquals(strpos(word_wrap($string), "\n"), 73);
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php
index 24823a634..c5b0f80b7 100644
--- a/tests/codeigniter/helpers/url_helper_test.php
+++ b/tests/codeigniter/helpers/url_helper_test.php
@@ -7,8 +7,13 @@ class Url_helper_test extends CI_TestCase {
$this->helper('url');
}
+ /**
+ * @runInSeparateProcess
+ */
public function test_url_title()
{
+ define('UTF8_ENABLED', FALSE);
+
$words = array(
'foo bar /' => 'foo-bar',
'\ testing 12' => 'testing-12'
@@ -22,8 +27,13 @@ class Url_helper_test extends CI_TestCase {
// --------------------------------------------------------------------
+ /**
+ * @runInSeparateProcess
+ */
public function test_url_title_extra_dashes()
{
+ define('UTF8_ENABLED', FALSE);
+
$words = array(
'_foo bar_' => 'foo_bar',
'_What\'s wrong with CSS?_' => 'Whats_wrong_with_CSS'
@@ -76,4 +86,4 @@ class Url_helper_test extends CI_TestCase {
}
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Calendar_test.php b/tests/codeigniter/libraries/Calendar_test.php
index 54879fec9..ad1f45e8c 100644
--- a/tests/codeigniter/libraries/Calendar_test.php
+++ b/tests/codeigniter/libraries/Calendar_test.php
@@ -5,9 +5,9 @@ class Calendar_test extends CI_TestCase {
public function set_up()
{
// Required for get_total_days()
- $this->ci_instance_var('load', $this->getMock('CI_Loader', array('helper')));
+ $this->ci_instance_var('load', $this->getMockBuilder('CI_Loader')->setMethods(array('helper'))->getMock());
- $lang = $this->getMock('CI_Lang', array('load', 'line'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load', 'line'))->getMock();
$lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
$this->ci_instance_var('lang', $lang);
@@ -219,4 +219,4 @@ class Calendar_test extends CI_TestCase {
$this->assertEquals($array, $this->calendar->default_template());
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Driver_test.php b/tests/codeigniter/libraries/Driver_test.php
index c62cbee45..e4401e688 100644
--- a/tests/codeigniter/libraries/Driver_test.php
+++ b/tests/codeigniter/libraries/Driver_test.php
@@ -16,7 +16,7 @@ class Driver_test extends CI_TestCase {
// Mock Loader->get_package_paths
$paths = 'get_package_paths';
- $ldr = $this->getMock('CI_Loader', array($paths));
+ $ldr = $this->getMockBuilder('CI_Loader')->setMethods(array($paths))->getMock();
$ldr->expects($this->any())->method($paths)->will($this->returnValue(array(APPPATH, BASEPATH)));
$this->ci_instance_var('load', $ldr);
@@ -175,4 +175,4 @@ class Driver_test extends CI_TestCase {
$this->assertEquals($return, $child->$method());
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Encrypt_test.php b/tests/codeigniter/libraries/Encrypt_test.php
index ced763301..adbca31b2 100644
--- a/tests/codeigniter/libraries/Encrypt_test.php
+++ b/tests/codeigniter/libraries/Encrypt_test.php
@@ -10,6 +10,10 @@ class Encrypt_test extends CI_TestCase {
{
return;
}
+ elseif (version_compare(PHP_VERSION, '7.1.0-alpha', '>='))
+ {
+ return $this->markTestSkipped('ext/mcrypt is deprecated since PHP 7.1 and will generate notices here.');
+ }
$this->encrypt = new Mock_Libraries_Encrypt();
$this->ci_instance_var('encrypt', $this->encrypt);
@@ -72,4 +76,4 @@ class Encrypt_test extends CI_TestCase {
$this->assertEquals('cfb', $this->encrypt->get_mode());
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
index cbcae3133..96e52ada8 100644
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -240,6 +240,10 @@ class Encryption_test extends CI_TestCase {
{
return $this->markTestSkipped('Cannot test MCrypt because it is not available.');
}
+ elseif (version_compare(PHP_VERSION, '7.1.0-alpha', '>='))
+ {
+ return $this->markTestSkipped('ext/mcrypt is deprecated since PHP 7.1 and will generate notices here.');
+ }
$this->assertTrue(is_resource($this->encryption->__driver_get_handle('mcrypt', 'rijndael-128', 'cbc')));
}
@@ -274,6 +278,10 @@ class Encryption_test extends CI_TestCase {
$this->markTestSkipped('Both MCrypt and OpenSSL support are required for portability tests.');
return;
}
+ elseif (version_compare(PHP_VERSION, '7.1.0-alpha', '>='))
+ {
+ return $this->markTestSkipped('ext/mcrypt is deprecated since PHP 7.1 and will generate notices here.');
+ }
$message = 'This is a message encrypted via MCrypt and decrypted via OpenSSL, or vice-versa.';
@@ -377,4 +385,4 @@ class Encryption_test extends CI_TestCase {
$this->assertEquals('stream', $this->encryption->mode);
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index 26d82ec93..035410724 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -8,15 +8,13 @@ class Form_validation_test extends CI_TestCase {
// Create a mock loader since load->helper() looks in the wrong directories for unit tests,
// We'll use CI_TestCase->helper() instead
- $loader = $this->getMock('CI_Loader', array('helper'));
+ $loader = $this->getMockBuilder('CI_Loader')->setMethods(array('helper'))->getMock();
// Same applies for lang
- $lang = $this->getMock('CI_Lang', array('load'));
+ $lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load'))->getMock();
- $this->ci_set_config('charset', 'UTF-8');
- $utf8 = new Mock_Core_Utf8();
- $security = new Mock_Core_Security();
- $input = new Mock_Core_Input($security, $utf8);
+ $security = new Mock_Core_Security('UTF-8');
+ $input = new CI_Input($security);
$this->ci_instance_var('lang', $lang);
$this->ci_instance_var('load', $loader);
@@ -28,13 +26,34 @@ class Form_validation_test extends CI_TestCase {
$this->form_validation = new CI_Form_validation();
}
+ public function test_empty_array_input()
+ {
+ $this->assertFalse(
+ $this->run_rules(
+ array(array('field' => 'foo', 'label' => 'Foo Label', 'rules' => 'required')),
+ array('foo' => array())
+ )
+ );
+ }
+
public function test_rule_required()
{
- $rules = array(array('field' => 'foo', 'label' => 'foo_label', 'rules' => 'required'));
- $this->assertTrue($this->run_rules($rules, array('foo' => 'bar')));
+ $rules = array(array('field' => 'foo', 'label' => 'Foo', 'rules' => 'is_numeric'));
+
+ // Empty, not required
+ $this->assertTrue($this->run_rules($rules, array('foo' => '')));
+
+ // Not required, but also not empty
+ $this->assertTrue($this->run_rules($rules, array('foo' => '123')));
+ $this->assertFalse($this->run_rules($rules, array('foo' => 'bar')));
+
+ // Required variations
+ $rules[0]['rules'] .= '|required';
+ $this->assertTrue($this->run_rules($rules, array('foo' => '123')));
$this->assertFalse($this->run_rules($rules, array('foo' => '')));
$this->assertFalse($this->run_rules($rules, array('foo' => ' ')));
+ $this->assertFalse($this->run_rules($rules, array('foo' => 'bar')));
}
public function test_rule_matches()
@@ -45,9 +64,9 @@ class Form_validation_test extends CI_TestCase {
);
$values_base = array('foo' => 'sample');
- $this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => ''))));
$this->assertTrue($this->run_rules($rules, array_merge($values_base, array('bar' => 'sample'))));
+ $this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => ''))));
$this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => 'Sample'))));
$this->assertFalse($this->run_rules($rules, array_merge($values_base, array('bar' => ' sample'))));
}
@@ -229,7 +248,17 @@ class Form_validation_test extends CI_TestCase {
public function test_rule_valid_url()
{
$this->assertTrue($this->form_validation->valid_url('www.codeigniter.com'));
- $this->assertTrue($this->form_validation->valid_url('http://codeigniter.eu'));
+ $this->assertTrue($this->form_validation->valid_url('http://codeigniter.com'));
+
+ // https://bugs.php.net/bug.php?id=51192
+ $this->assertTrue($this->form_validation->valid_url('http://accept-dashes.tld'));
+ $this->assertFalse($this->form_validation->valid_url('http://reject_underscores.tld'));
+
+ // https://github.com/bcit-ci/CodeIgniter/issues/4415
+ $this->assertTrue($this->form_validation->valid_url('http://[::1]/ipv6'));
+
+ // URI scheme case-sensitivity: https://github.com/bcit-ci/CodeIgniter/pull/4758
+ $this->assertTrue($this->form_validation->valid_url('HtTp://127.0.0.1/'));
$this->assertFalse($this->form_validation->valid_url('htt://www.codeIgniter.com'));
$this->assertFalse($this->form_validation->valid_url(''));
@@ -239,7 +268,6 @@ class Form_validation_test extends CI_TestCase {
public function test_rule_valid_email()
{
$this->assertTrue($this->form_validation->valid_email('email@sample.com'));
-
$this->assertFalse($this->form_validation->valid_email('valid_email', '@sample.com'));
}
@@ -265,10 +293,22 @@ class Form_validation_test extends CI_TestCase {
$this->assertFalse($this->form_validation->valid_ip('127.0.0.259'));
}
+ public function test_rule_valid_mac()
+ {
+ $this->assertTrue($this->form_validation->valid_mac("01-23-45-67-89-aB"));
+ $this->assertTrue($this->form_validation->valid_mac("01:23:45:67:89:aB"));
+ $this->assertTrue($this->form_validation->valid_mac("0123.4567.89aB"));
+
+ $this->assertFalse($this->form_validation->valid_mac("-01-23-45-67-89-ab"));
+ $this->assertFalse($this->form_validation->valid_mac("01:23:45:67:89:ab:"));
+ $this->assertFalse($this->form_validation->valid_mac("01:23:45:67:89:ab\n"));
+ $this->assertFalse($this->form_validation->valid_mac("01:23:45:67:89:ag:"));
+ $this->assertFalse($this->form_validation->valid_mac('0123456789ab'));
+ }
+
public function test_rule_valid_base64()
{
$this->assertTrue($this->form_validation->valid_base64(base64_encode('string')));
-
$this->assertFalse($this->form_validation->valid_base64('FA08GG'));
}
@@ -404,6 +444,12 @@ class Form_validation_test extends CI_TestCase {
$this->assertFalse($form_validation->run('fail'));
}
+ public function test_set_rules_exception()
+ {
+ $this->setExpectedException('BadMethodCallException');
+ $this->form_validation->set_rules('foo', 'bar');
+ }
+
public function test_has_rule()
{
$this->form_validation->reset_validation();
@@ -542,20 +588,6 @@ class Form_validation_test extends CI_TestCase {
$this->assertFalse($this->form_validation->regex_match('bar', $regex));
}
- public function test_prep_for_form()
- {
- $this->form_validation->reset_validation();
- $error_msg_unprepped = '<error =\'foobar\'">';
- $error_msg_prepped = '&lt;error =&#39;foobar&#39;&quot;&gt;';
- $this->form_validation->set_rules('foo', 'label', 'required', array('required' => $error_msg_unprepped));
- $_POST = array('foo' => '');
- $this->form_validation->run();
- $error_arr = $this->form_validation->error_array();
-
- $this->assertEquals('', $this->form_validation->prep_for_form(''));
- $this->assertEquals(array('foo' => $error_msg_prepped), $this->form_validation->prep_for_form($error_arr));
- }
-
public function test_prep_url()
{
$this->assertEquals('', $this->form_validation->prep_url(''));
diff --git a/tests/codeigniter/libraries/Session_test.php b/tests/codeigniter/libraries/Session_test.php
index 76a4fcc98..840df076a 100644
--- a/tests/codeigniter/libraries/Session_test.php
+++ b/tests/codeigniter/libraries/Session_test.php
@@ -37,7 +37,8 @@ return;
$ci = $this->ci_instance();
$ldr = $this->ci_core_class('load');
$ci->load = new $ldr();
- $ci->input = new Mock_Core_Input(NULL, NULL);
+ $security = new Mock_Core_Security('UTF-8');
+ $ci->input = new CI_Input($security);
// Make sure string helper is available
$this->ci_vfs_clone('system/helpers/string_helper.php');
@@ -437,4 +438,4 @@ return;
$this->assertNull($this->session->native->userdata($key));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php
index 4fbc11ef0..74a7d2c22 100644
--- a/tests/codeigniter/libraries/Upload_test.php
+++ b/tests/codeigniter/libraries/Upload_test.php
@@ -6,8 +6,8 @@ class Upload_test extends CI_TestCase {
{
$ci = $this->ci_instance();
$ci->upload = new CI_Upload();
- $ci->security = new Mock_Core_Security();
- $ci->lang = $this->getMock('CI_Lang', array('load', 'line'));
+ $ci->security = new Mock_Core_Security('UTF-8');
+ $ci->lang = $this->getMockBuilder('CI_Lang')->setMethods(array('load', 'line'))->getMock();
$ci->lang->expects($this->any())->method('line')->will($this->returnValue(FALSE));
$this->upload = $ci->upload;
}
@@ -25,14 +25,10 @@ class Upload_test extends CI_TestCase {
)
);
- // ReflectionProperty::setAccessible() is not available in PHP 5.2.x
- if (is_php('5.3'))
- {
- $reflection = new ReflectionClass($upload);
- $reflection = $reflection->getProperty('_file_name_override');
- $reflection->setAccessible(TRUE);
- $this->assertEquals('foo', $reflection->getValue($upload));
- }
+ $reflection = new ReflectionClass($upload);
+ $reflection = $reflection->getProperty('_file_name_override');
+ $reflection->setAccessible(TRUE);
+ $this->assertEquals('foo', $reflection->getValue($upload));
$this->assertTrue($upload->file_ext_tolower);
@@ -300,4 +296,4 @@ class Upload_test extends CI_TestCase {
$this->assertEquals('<p>Error test</p>', $this->upload->display_errors());
}
-} \ No newline at end of file
+}
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index 33942768d..a912327ca 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -1,6 +1,6 @@
<?php
-// This autoloader provide convinient way to working with mock object
+// This autoloader provide convenient way to working with mock object
// make the test looks natural. This autoloader support cascade file loading as well
// within mocks directory.
//
@@ -33,7 +33,6 @@ function autoload($class)
$ci_libraries = array(
'Calendar',
- 'Cart',
'Driver_Library',
'Email',
'Encrypt',
@@ -116,4 +115,4 @@ function autoload($class)
}
include_once($file);
-} \ No newline at end of file
+}
diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php
index a2c37b92e..b320aab74 100644
--- a/tests/mocks/ci_testcase.php
+++ b/tests/mocks/ci_testcase.php
@@ -24,9 +24,9 @@ class CI_TestCase extends PHPUnit_Framework_TestCase {
// --------------------------------------------------------------------
- public function __construct()
+ public function __construct($name = null, array $data = [], $dataName = '')
{
- parent::__construct();
+ parent::__construct($name, $data, $dataName);
$this->ci_instance = new stdClass();
}
diff --git a/tests/mocks/core/input.php b/tests/mocks/core/input.php
deleted file mode 100644
index 40e27441f..000000000
--- a/tests/mocks/core/input.php
+++ /dev/null
@@ -1,49 +0,0 @@
-<?php
-
-class Mock_Core_Input extends CI_Input {
-
- /**
- * Since we use GLOBAL to fetch Security and Utf8 classes,
- * we need to use inversion of control to mock up
- * the same process within CI_Input class constructor.
- *
- * @covers CI_Input::__construct()
- */
- public function __construct($security, $utf8)
- {
- $this->_allow_get_array = (config_item('allow_get_array') === TRUE);
- $this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
- $this->_enable_csrf = (config_item('csrf_protection') === TRUE);
-
- // Assign Security and Utf8 classes
- $this->security = $security;
- $this->uni = $utf8;
-
- // Sanitize global arrays
- $this->_sanitize_globals();
- }
-
- public function fetch_from_array($array, $index = '', $xss_clean = FALSE)
- {
- return parent::_fetch_from_array($array, $index, $xss_clean);
- }
-
- /**
- * Lie about being a CLI request
- *
- * We take advantage of this in libraries/Session_test
- */
- public function is_cli_request()
- {
- return FALSE;
- }
-
- public function __set($name, $value)
- {
- if ($name === 'ip_address')
- {
- $this->ip_address = $value;
- }
- }
-
-} \ No newline at end of file
diff --git a/tests/mocks/core/utf8.php b/tests/mocks/core/utf8.php
deleted file mode 100644
index 3a6282e1d..000000000
--- a/tests/mocks/core/utf8.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-class Mock_Core_Utf8 extends CI_Utf8 {
-
- /**
- * We need to define UTF8_ENABLED the same way that
- * CI_Utf8 constructor does.
- */
- public function __construct()
- {
- if (defined('UTF8_ENABLED'))
- {
- return;
- }
-
- parent::__construct();
- }
-
-} \ No newline at end of file
diff --git a/tests/mocks/database/drivers/mysql.php b/tests/mocks/database/drivers/mysql.php
index e0c1fb06c..b7718ebaf 100644
--- a/tests/mocks/database/drivers/mysql.php
+++ b/tests/mocks/database/drivers/mysql.php
@@ -5,7 +5,6 @@ class Mock_Database_Drivers_Mysql extends Mock_Database_DB_Driver {
/**
* Instantiate the database driver
*
- * @param string DB Driver class name
* @param array DB configuration to set
* @return void
*/
diff --git a/tests/mocks/database/drivers/mysqli.php b/tests/mocks/database/drivers/mysqli.php
index 73c35b609..f747aad46 100644
--- a/tests/mocks/database/drivers/mysqli.php
+++ b/tests/mocks/database/drivers/mysqli.php
@@ -5,7 +5,6 @@ class Mock_Database_Drivers_Mysqli extends Mock_Database_DB_Driver {
/**
* Instantiate the database driver
*
- * @param string DB Driver class name
* @param array DB configuration to set
* @return void
*/
diff --git a/tests/mocks/database/drivers/pdo.php b/tests/mocks/database/drivers/pdo.php
index 17768eed7..af1958aea 100644
--- a/tests/mocks/database/drivers/pdo.php
+++ b/tests/mocks/database/drivers/pdo.php
@@ -5,7 +5,6 @@ class Mock_Database_Drivers_PDO extends Mock_Database_DB_Driver {
/**
* Instantiate the database driver
*
- * @param string DB Driver class name
* @param array DB configuration to set
* @return void
*/
diff --git a/tests/mocks/database/drivers/postgre.php b/tests/mocks/database/drivers/postgre.php
index 5a45115fa..8c91e54a9 100644
--- a/tests/mocks/database/drivers/postgre.php
+++ b/tests/mocks/database/drivers/postgre.php
@@ -5,7 +5,6 @@ class Mock_Database_Drivers_Postgre extends Mock_Database_DB_Driver {
/**
* Instantiate the database driver
*
- * @param string DB Driver class name
* @param array DB configuration to set
* @return void
*/
diff --git a/tests/mocks/database/drivers/sqlite.php b/tests/mocks/database/drivers/sqlite.php
index 512467520..b2aec28e6 100644
--- a/tests/mocks/database/drivers/sqlite.php
+++ b/tests/mocks/database/drivers/sqlite.php
@@ -5,7 +5,6 @@ class Mock_Database_Drivers_Sqlite extends Mock_Database_DB_Driver {
/**
* Instantiate the database driver
*
- * @param string DB Driver class name
* @param array DB configuration to set
* @return void
*/