summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter/core
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r--tests/codeigniter/core/Input_test.php14
-rw-r--r--tests/codeigniter/core/Loader_test.php39
-rw-r--r--tests/codeigniter/core/Security_test.php5
-rw-r--r--tests/codeigniter/core/compat/mbstring_test.php14
4 files changed, 47 insertions, 25 deletions
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index 07a99e136..93d1b7118 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -18,6 +18,14 @@ class Input_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function tear_down()
+ {
+ $_POST = [];
+ $_GET = [];
+ }
+
+ // --------------------------------------------------------------------
+
public function test_get_not_exists()
{
$this->assertSame(array(), $this->input->get());
@@ -93,7 +101,7 @@ class Input_test extends CI_TestCase {
public function test_post_get_array_notation()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
- $_POST['foo']['bar'] = 'baz';
+ $_POST['foo'] = array('bar' => 'baz');
$barArray = array('bar' => 'baz');
$this->assertEquals('baz', $this->input->get_post('foo[bar]'));
@@ -120,7 +128,7 @@ class Input_test extends CI_TestCase {
public function test_get_post_array_notation()
{
$_SERVER['REQUEST_METHOD'] = 'GET';
- $_GET['foo']['bar'] = 'baz';
+ $_GET['foo'] = array('bar' => 'baz');
$barArray = array('bar' => 'baz');
$this->assertEquals('baz', $this->input->get_post('foo[bar]'));
@@ -169,7 +177,7 @@ class Input_test extends CI_TestCase {
$this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless);
$_SERVER['REQUEST_METHOD'] = 'POST';
- $_POST['foo']['bar'] = 'baz';
+ $_POST['foo'] = array('bar' => 'baz');
$barArray = array('bar' => 'baz');
$this->assertEquals('baz', $this->input->post('foo[bar]'));
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index df698f30c..4fa6d6869 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -36,7 +36,8 @@ class Loader_test extends CI_TestCase {
// Test loading as an array.
$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);
+ $this->assertObjectHasAttribute($lib, $this->ci_obj);
+ $this->assertInstanceOf($class, $this->ci_obj->$lib);
// Create library in VFS
$lib = array('unit_test_lib' => 'unit_test_lib');
@@ -87,14 +88,16 @@ class Loader_test extends CI_TestCase {
$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);
- $this->assertAttributeInstanceOf($ext, $name, $this->ci_obj);
+ $this->assertObjectHasAttribute($name, $this->ci_obj);
+ $this->assertInstanceOf($class, $this->ci_obj->$name);
+ $this->assertInstanceOf($ext, $this->ci_obj->$name);
// Test reloading with object name
$obj = 'exttest';
$this->assertInstanceOf('CI_Loader', $this->load->library($lib, NULL, $obj));
- $this->assertAttributeInstanceOf($class, $obj, $this->ci_obj);
- $this->assertAttributeInstanceOf($ext, $obj, $this->ci_obj);
+ $this->assertObjectHasAttribute($obj, $this->ci_obj);
+ $this->assertInstanceOf($class, $this->ci_obj->$obj);
+ $this->assertInstanceOf($ext, $this->ci_obj->$obj);
// Test reloading
unset($this->ci_obj->$name);
@@ -137,7 +140,8 @@ class Loader_test extends CI_TestCase {
$obj = 'testy';
$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->assertObjectHasAttribute($obj, $this->ci_obj);
+ $this->assertInstanceOf($class, $this->ci_obj->$obj);
$this->assertEquals($cfg, $this->ci_obj->$obj->config);
// Test is_loaded
@@ -168,7 +172,8 @@ class Loader_test extends CI_TestCase {
// Was the model class instantiated.
$this->assertTrue(class_exists($class), $class.' does not exist');
- $this->assertAttributeInstanceOf($class, $lib, $this->ci_obj);
+ $this->assertObjectHasAttribute($lib, $this->ci_obj);
+ $this->assertInstanceOf($class, $this->ci_obj->$lib);
}
// --------------------------------------------------------------------
@@ -188,12 +193,14 @@ class Loader_test extends CI_TestCase {
// Test loading as an array.
$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);
+ $this->assertObjectHasAttribute($driver, $this->ci_obj);
+ $this->assertInstanceOf($class, $this->ci_obj->$driver);
// Test loading as a library with a name
$obj = 'testdrive';
$this->assertInstanceOf('CI_Loader', $this->load->library($driver, NULL, $obj));
- $this->assertAttributeInstanceOf($class, $obj, $this->ci_obj);
+ $this->assertObjectHasAttribute($obj, $this->ci_obj);
+ $this->assertInstanceOf($class, $this->ci_obj->$obj);
// Test a string given to params
$this->assertInstanceOf('CI_Loader', $this->load->driver($driver, ' '));
@@ -242,8 +249,9 @@ class Loader_test extends CI_TestCase {
// Was the model class instantiated?
$this->assertTrue(class_exists($model));
$this->assertObjectHasAttribute($name, $this->ci_obj);
- $this->assertAttributeInstanceOf($base, $name, $this->ci_obj);
- $this->assertAttributeInstanceOf($model, $name, $this->ci_obj);
+ $this->assertObjectHasAttribute($name, $this->ci_obj);
+ $this->assertInstanceOf($base, $this->ci_obj->$name);
+ $this->assertInstanceOf($model, $this->ci_obj->$name);
// Test name conflict
$obj = 'conflict';
@@ -586,15 +594,18 @@ class Loader_test extends CI_TestCase {
// Verify library
$this->assertTrue(class_exists($lib_class), $lib_class.' does not exist');
- $this->assertAttributeInstanceOf($lib_class, $lib, $this->ci_obj);
+ $this->assertObjectHasAttribute($lib, $this->ci_obj);
+ $this->assertInstanceOf($lib_class, $this->ci_obj->$lib);
// Verify driver
$this->assertTrue(class_exists($drv_class), $drv_class.' does not exist');
- $this->assertAttributeInstanceOf($drv_class, $drv, $this->ci_obj);
+ $this->assertObjectHasAttribute($drv, $this->ci_obj);
+ $this->assertInstanceOf($drv_class, $this->ci_obj->$drv);
// Verify model
$this->assertTrue(class_exists($model), $model.' does not exist');
- $this->assertAttributeInstanceOf($model, $model, $this->ci_obj);
+ $this->assertObjectHasAttribute($model, $this->ci_obj);
+ $this->assertInstanceOf($model, $this->ci_obj->$model);
// Verify config calls
$this->assertEquals($cfg['config'], $this->ci_obj->config->loaded);
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index 64efdf9c8..5132e5887 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -253,7 +253,10 @@ class Security_test extends CI_TestCase {
// Perform hash
$this->security->xss_hash();
- $this->assertRegExp('#^[0-9a-f]{32}$#iS', $this->security->xss_hash);
+ $assertRegExp = class_exists('PHPUnit_Runner_Version')
+ ? 'assertRegExp'
+ : 'assertMatchesRegularExpression';
+ $this->$assertRegExp('#^[0-9a-f]{32}$#iS', $this->security->xss_hash);
}
// --------------------------------------------------------------------
diff --git a/tests/codeigniter/core/compat/mbstring_test.php b/tests/codeigniter/core/compat/mbstring_test.php
index 415222446..39f48ac10 100644
--- a/tests/codeigniter/core/compat/mbstring_test.php
+++ b/tests/codeigniter/core/compat/mbstring_test.php
@@ -27,28 +27,28 @@ class mbstring_test extends CI_TestCase {
// ------------------------------------------------------------------------
/**
- * @depends test_boostrap
+ * @depends test_bootstrap
*/
public function test_mb_strpos()
{
- $this->assertEquals(ICONV_ENABLED ? 3 : 6, mb_strpos('тест', 'с'));
+ $this->assertEquals(ICONV_ENABLED ? 2 : 4, mb_strpos('тест', 'с'));
$this->assertFalse(mb_strpos('тест', 'с', 3));
- $this->assertEquals(ICONV_ENABLED ? 3 : 6, mb_strpos('тест', 'с', 1, 'UTF-8'));
+ $this->assertEquals(ICONV_ENABLED ? 2 : 4, mb_strpos('тест', 'с', 1, 'UTF-8'));
}
// ------------------------------------------------------------------------
/**
- * @depends test_boostrap
+ * @depends test_bootstrap
*/
public function test_mb_substr()
{
$this->assertEquals(ICONV_ENABLED ? 'стинг' : 'естинг', mb_substr('тестинг', 2));
$this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('тестинг', -2));
$this->assertEquals(ICONV_ENABLED ? 'ст' : 'е', mb_substr('тестинг', 2, 2));
- $this->assertEquals(ICONV_ENABLED ? 'стинг' : 'естинг', mb_substr('тестинг', 2, 'UTF-8'));
- $this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('тестинг', -2, 'UTF-8'));
+ $this->assertEquals(ICONV_ENABLED ? 'стинг' : 'естинг', mb_substr('тестинг', 2, NULL, 'UTF-8'));
+ $this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('тестинг', -2, NULL, 'UTF-8'));
$this->assertEquals(ICONV_ENABLED ? 'ст' : 'е', mb_substr('тестинг', 2, 2, 'UTF-8'));
}
-} \ No newline at end of file
+}