summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2014-01-20 14:03:43 +0100
committerAndrey Andreev <narf@devilix.net>2014-01-20 14:03:43 +0100
commitea801ab4ab80042638ffddc6056483a1ec43fa80 (patch)
treef75f30c0df6a8f861ca7df22af09fa3240b0bbd6 /tests/codeigniter/core
parent1c08d557a21ecb0f79cd1a1de4e06817a26e0537 (diff)
parent4d0571666d03511ac5b4a1f2a6882ccb1509a209 (diff)
Merge branch 'develop' into feature/user-guide-cleanup
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r--tests/codeigniter/core/Benchmark_test.php26
-rw-r--r--tests/codeigniter/core/Config_test.php10
-rw-r--r--tests/codeigniter/core/Input_test.php59
-rw-r--r--tests/codeigniter/core/Loader_test.php94
-rw-r--r--tests/codeigniter/core/Model_test.php37
-rw-r--r--tests/codeigniter/core/Security_test.php2
-rw-r--r--tests/codeigniter/core/URI_test.php43
-rw-r--r--tests/codeigniter/core/Utf8_test.php13
8 files changed, 191 insertions, 93 deletions
diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php
index a239ba51d..7fd0727e2 100644
--- a/tests/codeigniter/core/Benchmark_test.php
+++ b/tests/codeigniter/core/Benchmark_test.php
@@ -27,10 +27,34 @@ class Benchmark_test extends CI_TestCase {
$this->assertEmpty($this->benchmark->elapsed_time('undefined_point'));
$this->benchmark->mark('code_start');
- sleep(1);
$this->benchmark->mark('code_end');
+ // Override values, because time isn't testable, but make sure the markers were set
+ if (isset($this->benchmark->marker['code_start']) && is_float($this->benchmark->marker['code_start']))
+ {
+ $this->benchmark->marker['code_start'] = 1389956144.1944;
+ }
+
+ if (isset($this->benchmark->marker['code_end']) && is_float($this->benchmark->marker['code_end']))
+ {
+ $this->benchmark->marker['code_end'] = 1389956145.1946;
+ }
+
+ $this->assertEquals('1', $this->benchmark->elapsed_time('code_start', 'code_end', 0));
$this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1));
+ $this->assertEquals('1.00', $this->benchmark->elapsed_time('code_start', 'code_end', 2));
+ $this->assertEquals('1.000', $this->benchmark->elapsed_time('code_start', 'code_end', 3));
+ $this->assertEquals('1.0002', $this->benchmark->elapsed_time('code_start', 'code_end', 4));
+ $this->assertEquals('1.0002', $this->benchmark->elapsed_time('code_start', 'code_end'));
+
+ // Test with non-existing 2nd marker, but again - we need to override the value
+ $this->benchmark->elapsed_time('code_start', 'code_end2');
+ if (isset($this->benchmark->marker['code_end2']) && is_float($this->benchmark->marker['code_end2']))
+ {
+ $this->benchmark->marker['code_end2'] = 1389956146.2046;
+ }
+
+ $this->assertEquals('2.0102', $this->benchmark->elapsed_time('code_start', 'code_end2'));
}
// --------------------------------------------------------------------
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
index e3be8a3fc..ba9a2c070 100644
--- a/tests/codeigniter/core/Config_test.php
+++ b/tests/codeigniter/core/Config_test.php
@@ -24,18 +24,18 @@ class Config_test extends CI_TestCase {
$this->assertEquals($this->cfg['base_url'], $this->config->item('base_url'));
// Bad Config value
- $this->assertFalse($this->config->item('no_good_item'));
+ $this->assertNull($this->config->item('no_good_item'));
// Index
- $this->assertFalse($this->config->item('no_good_item', 'bad_index'));
- $this->assertFalse($this->config->item('no_good_item', 'default'));
+ $this->assertNull($this->config->item('no_good_item', 'bad_index'));
+ $this->assertNull($this->config->item('no_good_item', 'default'));
}
// --------------------------------------------------------------------
public function test_set_item()
{
- $this->assertFalse($this->config->item('not_yet_set'));
+ $this->assertNull($this->config->item('not_yet_set'));
$this->config->set_item('not_yet_set', 'is set');
$this->assertEquals('is set', $this->config->item('not_yet_set'));
@@ -46,7 +46,7 @@ class Config_test extends CI_TestCase {
public function test_slash_item()
{
// Bad Config value
- $this->assertFalse($this->config->slash_item('no_good_item'));
+ $this->assertNull($this->config->slash_item('no_good_item'));
$this->assertEquals($this->cfg['base_url'], $this->config->slash_item('base_url'));
$this->assertEquals($this->cfg['subclass_prefix'].'/', $this->config->slash_item('subclass_prefix'));
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index 5cf25fefa..95833fc91 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -82,11 +82,21 @@ class Input_test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_get_post()
+ public function test_post_get()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['foo'] = 'bar';
+ $this->assertEquals('bar', $this->input->post_get('foo'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_get_post()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_GET['foo'] = 'bar';
+
$this->assertEquals('bar', $this->input->get_post('foo'));
}
@@ -128,13 +138,24 @@ class Input_test extends CI_TestCase {
public function test_valid_ip()
{
- $ip_v4 = '192.18.0.1';
- $this->assertTrue($this->input->valid_ip($ip_v4));
+ $this->assertTrue($this->input->valid_ip('192.18.0.1'));
+ $this->assertTrue($this->input->valid_ip('192.18.0.1', 'ipv4'));
+ $this->assertFalse($this->input->valid_ip('555.0.0.0'));
+ $this->assertFalse($this->input->valid_ip('2001:db8:0:85a3::ac1f:8001', 'ipv4'));
+
+ // v6 tests
+ $this->assertFalse($this->input->valid_ip('192.18.0.1', 'ipv6'));
+
+ $ip_v6 = array(
+ '2001:0db8:0000:85a3:0000:0000:ac1f:8001',
+ '2001:db8:0:85a3:0:0:ac1f:8001',
+ '2001:db8:0:85a3::ac1f:8001'
+ );
- $ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001');
foreach ($ip_v6 as $ip)
{
$this->assertTrue($this->input->valid_ip($ip));
+ $this->assertTrue($this->input->valid_ip($ip, 'ipv6'));
}
}
@@ -161,4 +182,34 @@ class Input_test extends CI_TestCase {
$this->assertTrue($this->input->is_ajax_request());
}
+ // --------------------------------------------------------------------
+
+ public function test_input_stream()
+ {
+ $this->markTestSkipped('TODO: Find a way to test input://');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_set_cookie()
+ {
+ $this->markTestSkipped('TODO: Find a way to test HTTP headers');
+ }
+
+ public function test_ip_address()
+ {
+ // 127.0.0.1 is set in our Bootstrap file
+ $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
+ $this->assertEquals('0.0.0.0', $this->input->ip_address());
+
+ // TODO: Add proxy_ips tests
+
+ // Back to reality
+ $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; // back to reality
+ }
+
} \ No newline at end of file
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index ac2656e75..799bcd967 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -28,18 +28,15 @@ class Loader_test extends CI_TestCase {
$this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_base_root, 'libraries');
// Test is_loaded fail
- $this->assertFalse($this->load->is_loaded($lib));
+ $this->assertFalse($this->load->is_loaded(ucfirst($lib)));
// Test loading as an array.
- $this->assertNull($this->load->library(array($lib)));
+ $this->assertInstanceOf('CI_Loader', $this->load->library(array($lib)));
$this->assertTrue(class_exists($class), $class.' does not exist');
$this->assertAttributeInstanceOf($class, $lib, $this->ci_obj);
- // Test no lib given
- $this->assertNull($this->load->library());
-
// Test a string given to params
- $this->assertNull($this->load->library($lib, ' '));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib, ' '));
// Create library w/o class
$lib = 'bad_test_lib';
@@ -50,7 +47,7 @@ class Loader_test extends CI_TestCase {
'RuntimeException',
'CI Error: Unable to load the requested class: '.ucfirst($lib)
);
- $this->assertNull($this->load->library($lib));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
}
// --------------------------------------------------------------------
@@ -66,7 +63,7 @@ class Loader_test extends CI_TestCase {
$this->ci_vfs_create($ext, '<?php class '.$ext.' extends '.$class.' { }', $this->ci_app_root, 'libraries');
// Test loading with extension
- $this->assertNull($this->load->library($lib));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
$this->assertTrue(class_exists($class), $class.' does not exist');
$this->assertTrue(class_exists($ext), $ext.' does not exist');
$this->assertAttributeInstanceOf($class, $name, $this->ci_obj);
@@ -74,13 +71,13 @@ class Loader_test extends CI_TestCase {
// Test reloading with object name
$obj = 'exttest';
- $this->assertNull($this->load->library($lib, NULL, $obj));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib, NULL, $obj));
$this->assertAttributeInstanceOf($class, $obj, $this->ci_obj);
$this->assertAttributeInstanceOf($ext, $obj, $this->ci_obj);
// Test reloading
unset($this->ci_obj->$name);
- $this->assertNull($this->load->library($lib));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
$this->assertObjectNotHasAttribute($name, $this->ci_obj);
// Create baseless library
@@ -94,7 +91,7 @@ class Loader_test extends CI_TestCase {
'RuntimeException',
'CI Error: Unable to load the requested class: '.$lib
);
- $this->assertNull($this->load->library($lib));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
}
// --------------------------------------------------------------------
@@ -117,13 +114,13 @@ class Loader_test extends CI_TestCase {
// Test object name and config
$obj = 'testy';
- $this->assertNull($this->load->library($lib, NULL, $obj));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib, NULL, $obj));
$this->assertTrue(class_exists($class), $class.' does not exist');
$this->assertAttributeInstanceOf($class, $obj, $this->ci_obj);
$this->assertEquals($cfg, $this->ci_obj->$obj->config);
// Test is_loaded
- $this->assertEquals($obj, $this->load->is_loaded($lib));
+ $this->assertEquals($obj, $this->load->is_loaded(ucfirst($lib)));
}
// --------------------------------------------------------------------
@@ -136,7 +133,7 @@ class Loader_test extends CI_TestCase {
$this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
// Load library
- $this->assertNull($this->load->library($lib));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
// Was the model class instantiated.
$this->assertTrue(class_exists($class), $class.' does not exist');
@@ -158,20 +155,17 @@ class Loader_test extends CI_TestCase {
$this->ci_vfs_create(ucfirst($driver), $content, $this->ci_base_root, 'libraries/'.$dir);
// Test loading as an array.
- $this->assertNull($this->load->driver(array($driver)));
+ $this->assertInstanceOf('CI_Loader', $this->load->driver(array($driver)));
$this->assertTrue(class_exists($class), $class.' does not exist');
$this->assertAttributeInstanceOf($class, $driver, $this->ci_obj);
// Test loading as a library with a name
$obj = 'testdrive';
- $this->assertNull($this->load->library($driver, NULL, $obj));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($driver, NULL, $obj));
$this->assertAttributeInstanceOf($class, $obj, $this->ci_obj);
- // Test no driver given
- $this->assertFalse($this->load->driver());
-
// Test a string given to params
- $this->assertNull($this->load->driver($driver, ' '));
+ $this->assertInstanceOf('CI_Loader', $this->load->driver($driver, ' '));
}
// --------------------------------------------------------------------
@@ -181,19 +175,19 @@ class Loader_test extends CI_TestCase {
$this->ci_set_core_class('model', 'CI_Model');
// Create model in VFS
- $model = 'unit_test_model';
- $class = ucfirst($model);
- $content = '<?php class '.$class.' extends CI_Model {} ';
+ $model = 'Unit_test_model';
+ $content = '<?php class '.$model.' extends CI_Model {} ';
$this->ci_vfs_create($model, $content, $this->ci_app_root, 'models');
// Load model
- $this->assertNull($this->load->model($model));
+ $this->assertInstanceOf('CI_Loader', $this->load->model($model));
// Was the model class instantiated.
- $this->assertTrue(class_exists($class));
+ $this->assertTrue(class_exists($model));
+ $this->assertObjectHasAttribute($model, $this->ci_obj);
// Test no model given
- $this->assertNull($this->load->model(''));
+ $this->assertInstanceOf('CI_Loader', $this->load->model(''));
}
// --------------------------------------------------------------------
@@ -204,22 +198,21 @@ class Loader_test extends CI_TestCase {
$this->ci_core_class('model');
// Create modelin VFS
- $model = 'test_sub_model';
+ $model = 'Test_sub_model';
$base = 'CI_Model';
- $class = ucfirst($model);
$subdir = 'cars';
- $this->ci_vfs_create($model, '<?php class '.$class.' extends '.$base.' { }', $this->ci_app_root,
+ $this->ci_vfs_create($model, '<?php class '.$model.' extends '.$base.' { }', $this->ci_app_root,
array('models', $subdir));
// Load model
$name = 'testors';
- $this->assertNull($this->load->model($subdir.'/'.$model, $name));
+ $this->assertInstanceOf('CI_Loader', $this->load->model($subdir.'/'.$model, $name));
// Was the model class instantiated?
- $this->assertTrue(class_exists($class));
+ $this->assertTrue(class_exists($model));
$this->assertObjectHasAttribute($name, $this->ci_obj);
$this->assertAttributeInstanceOf($base, $name, $this->ci_obj);
- $this->assertAttributeInstanceOf($class, $name, $this->ci_obj);
+ $this->assertAttributeInstanceOf($model, $name, $this->ci_obj);
// Test name conflict
$obj = 'conflict';
@@ -237,7 +230,7 @@ class Loader_test extends CI_TestCase {
{
$this->setExpectedException(
'RuntimeException',
- 'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php'
+ 'CI Error: Unable to locate the model you have specified: Ci_test_nonexistent_model.php'
);
$this->load->model('ci_test_nonexistent_model.php');
@@ -247,8 +240,8 @@ class Loader_test extends CI_TestCase {
// public function testDatabase()
// {
- // $this->assertNull($this->load->database());
- // $this->assertNull($this->load->dbutil());
+ // $this->assertInstanceOf('CI_Loader', $this->load->database());
+ // $this->assertInstanceOf('CI_Loader', $this->load->dbutil());
// }
// --------------------------------------------------------------------
@@ -272,7 +265,7 @@ class Loader_test extends CI_TestCase {
$this->ci_instance_var('output', $output);
// Test view output
- $this->assertNull($this->load->view($view, array($var => $value)));
+ $this->assertInstanceOf('CI_Loader', $this->load->view($view, array($var => $value)));
}
// --------------------------------------------------------------------
@@ -318,8 +311,8 @@ class Loader_test extends CI_TestCase {
$val1 = 'bar';
$key2 = 'boo';
$val2 = 'hoo';
- $this->assertNull($this->load->vars(array($key1 => $val1)));
- $this->assertNull($this->load->vars($key2, $val2));
+ $this->assertInstanceOf('CI_Loader', $this->load->vars(array($key1 => $val1)));
+ $this->assertInstanceOf('CI_Loader', $this->load->vars($key2, $val2));
$this->assertEquals($val1, $this->load->get_var($key1));
$this->assertEquals(array($key1 => $val1, $key2 => $val2), $this->load->get_vars());
}
@@ -340,7 +333,7 @@ class Loader_test extends CI_TestCase {
$this->ci_vfs_create($this->prefix.$helper.'_helper', $content, $this->ci_app_root, 'helpers');
// Load helper
- $this->assertNull($this->load->helper($helper));
+ $this->assertInstanceOf('CI_Loader', $this->load->helper($helper));
$this->assertTrue(function_exists($func), $func.' does not exist');
$this->assertTrue(function_exists($exfunc), $exfunc.' does not exist');
@@ -385,7 +378,7 @@ class Loader_test extends CI_TestCase {
$this->ci_vfs_create($files, NULL, $this->ci_base_root, 'helpers');
// Load helpers
- $this->assertNull($this->load->helpers($helpers));
+ $this->assertInstanceOf('CI_Loader', $this->load->helpers($helpers));
// Verify helper existence
foreach ($funcs as $func) {
@@ -402,7 +395,7 @@ class Loader_test extends CI_TestCase {
$lang = $this->getMock('CI_Lang', array('load'));
$lang->expects($this->once())->method('load')->with($file);
$this->ci_instance_var('lang', $lang);
- $this->assertNull($this->load->language($file));
+ $this->assertInstanceOf('CI_Loader', $this->load->language($file));
}
// --------------------------------------------------------------------
@@ -420,24 +413,24 @@ class Loader_test extends CI_TestCase {
// Add path and verify
$path = APPPATH.$dir.'/';
- $this->assertNull($this->load->add_package_path($path));
+ $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path));
$this->assertContains($path, $this->load->get_package_paths(TRUE));
// Test successful load
- $this->assertNull($this->load->library($lib));
+ $this->assertInstanceOf('CI_Loader', $this->load->library($lib));
$this->assertTrue(class_exists($class), $class.' does not exist');
// Add another path
$path2 = APPPATH.'another/';
- $this->assertNull($this->load->add_package_path($path2));
+ $this->assertInstanceOf('CI_Loader', $this->load->add_package_path($path2));
$this->assertContains($path2, $this->load->get_package_paths(TRUE));
// Remove last path
- $this->assertNull($this->load->remove_package_path());
+ $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path());
$this->assertNotContains($path2, $this->load->get_package_paths(TRUE));
// Remove path and verify restored paths
- $this->assertNull($this->load->remove_package_path($path));
+ $this->assertInstanceOf('CI_Loader', $this->load->remove_package_path($path));
$this->assertEquals($paths, $this->load->get_package_paths(TRUE));
// Test failed load without path
@@ -481,9 +474,8 @@ class Loader_test extends CI_TestCase {
// Create model in VFS package path
$dir = 'testdir';
$path = APPPATH.$dir.'/';
- $model = 'automod';
- $mod_class = ucfirst($model);
- $this->ci_vfs_create($model, '<?php class '.$mod_class.' { }', $this->ci_app_root, array($dir, 'models'));
+ $model = 'Automod';
+ $this->ci_vfs_create($model, '<?php class '.$model.' { }', $this->ci_app_root, array($dir, 'models'));
// Create autoloader config
$cfg = array(
@@ -513,8 +505,8 @@ class Loader_test extends CI_TestCase {
$this->assertAttributeInstanceOf($drv_class, $drv, $this->ci_obj);
// Verify model
- $this->assertTrue(class_exists($mod_class), $mod_class.' does not exist');
- $this->assertAttributeInstanceOf($mod_class, $model, $this->ci_obj);
+ $this->assertTrue(class_exists($model), $model.' does not exist');
+ $this->assertAttributeInstanceOf($model, $model, $this->ci_obj);
// Verify config calls
$this->assertEquals($cfg['config'], $this->ci_obj->config->loaded);
diff --git a/tests/codeigniter/core/Model_test.php b/tests/codeigniter/core/Model_test.php
new file mode 100644
index 000000000..80dc97b3b
--- /dev/null
+++ b/tests/codeigniter/core/Model_test.php
@@ -0,0 +1,37 @@
+<?php
+
+class Model_test extends CI_TestCase {
+
+ private $ci_obj;
+
+ public function set_up()
+ {
+ $loader = $this->ci_core_class('loader');
+ $this->load = new $loader();
+ $this->ci_obj = $this->ci_instance();
+ $this->ci_set_core_class('model', 'CI_Model');
+
+ $model_code =<<<MODEL
+<?php
+class Test_model extends CI_Model {
+
+ public \$property = 'foo';
+
+}
+MODEL;
+
+ $this->ci_vfs_create('Test_model', $model_code, $this->ci_app_root, 'models');
+ $this->load->model('test_model');
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test__get()
+ {
+ $this->assertEquals('foo', $this->ci_obj->test_model->property);
+
+ $this->ci_obj->controller_property = 'bar';
+ $this->assertEquals('bar', $this->ci_obj->test_model->controller_property);
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index 3f6e3b07a..433ad313f 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -5,7 +5,7 @@ class Security_test extends CI_TestCase {
public function set_up()
{
// Set cookie for security test
- $_COOKIE['ci_csrf_cookie'] = md5(uniqid(rand(), TRUE));
+ $_COOKIE['ci_csrf_cookie'] = md5(uniqid(mt_rand(), TRUE));
// Set config for Security class
$this->ci_set_config('csrf_protection', TRUE);
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index 7fa0e6265..6589c1f5a 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -26,6 +26,10 @@ class URI_test extends CI_TestCase {
// --------------------------------------------------------------------
+ /*
+
+ This has been moved to the constructor
+
public function test_fetch_uri_string()
{
define('SELF', 'index.php');
@@ -86,9 +90,14 @@ class URI_test extends CI_TestCase {
// uri_protocol: REQUEST_URI
// uri_protocol: CLI
}
+ */
// --------------------------------------------------------------------
+ /*
+
+ This has been moved into _set_uri_string()
+
public function test_explode_segments()
{
// Let's test the function's ability to clean up this mess
@@ -107,16 +116,15 @@ class URI_test extends CI_TestCase {
$this->assertEquals($a, $this->uri->segments);
}
}
-
+ */
// --------------------------------------------------------------------
public function test_filter_uri()
{
- $this->uri->config->set_item('enable_query_strings', FALSE);
- $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-');
+ $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-');
$str_in = 'abc01239~%.:_-';
- $str = $this->uri->_filter_uri($str_in);
+ $str = $this->uri->filter_uri($str_in);
$this->assertEquals($str, $str_in);
}
@@ -126,11 +134,9 @@ class URI_test extends CI_TestCase {
public function test_filter_uri_escaping()
{
// ensure escaping even if dodgey characters are permitted
+ $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-()$');
- $this->uri->config->set_item('enable_query_strings', FALSE);
- $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-()$');
-
- $str = $this->uri->_filter_uri('$destroy_app(foo)');
+ $str = $this->uri->filter_uri('$destroy_app(foo)');
$this->assertEquals($str, '&#36;destroy_app&#40;foo&#41;');
}
@@ -142,25 +148,8 @@ class URI_test extends CI_TestCase {
$this->setExpectedException('RuntimeException');
$this->uri->config->set_item('enable_query_strings', FALSE);
- $this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-');
- $this->uri->_filter_uri('$this()');
- }
-
- // --------------------------------------------------------------------
-
- public function test_remove_url_suffix()
- {
- $this->uri->config->set_item('url_suffix', '.html');
-
- $this->uri->uri_string = 'controller/method/index.html';
- $this->uri->_remove_url_suffix();
-
- $this->assertEquals($this->uri->uri_string, 'controller/method/index');
-
- $this->uri->uri_string = 'controller/method/index.htmlify.html';
- $this->uri->_remove_url_suffix();
-
- $this->assertEquals($this->uri->uri_string, 'controller/method/index.htmlify');
+ $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-');
+ $this->uri->filter_uri('$this()');
}
// --------------------------------------------------------------------
diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php
index caa7b6986..71299134e 100644
--- a/tests/codeigniter/core/Utf8_test.php
+++ b/tests/codeigniter/core/Utf8_test.php
@@ -11,10 +11,15 @@ class Utf8_test extends CI_TestCase {
public function test_convert_to_utf8()
{
- $this->assertEquals(
- $this->utf8->convert_to_utf8('๒ๅ๑๒', 'WINDOWS-1251'),
- 'ั‚ะตัั‚'
- );
+ $this->assertEquals('ั‚ะตัั‚', $this->utf8->convert_to_utf8('๒ๅ๑๒', 'WINDOWS-1251'));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_is_ascii()
+ {
+ $this->assertTrue($this->utf8->is_ascii_test('foo bar'));
+ $this->assertFalse($this->utf8->is_ascii_test('ั‚ะตัั‚'));
}
} \ No newline at end of file