summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Bootstrap.php7
-rw-r--r--tests/codeigniter/Setup_test.php2
-rw-r--r--tests/codeigniter/core/Input_test.php14
-rw-r--r--tests/codeigniter/core/Loader_test.php39
-rw-r--r--tests/codeigniter/core/Log_test.php2
-rw-r--r--tests/codeigniter/core/Output_test.php2
-rw-r--r--tests/codeigniter/core/Security_test.php5
-rw-r--r--tests/codeigniter/core/compat/mbstring_test.php14
-rw-r--r--tests/codeigniter/database/query_builder/select_test.php2
-rw-r--r--tests/codeigniter/helpers/array_helper_test.php4
-rw-r--r--tests/codeigniter/helpers/file_helper_test.php11
-rw-r--r--tests/codeigniter/helpers/string_helper_test.php2
-rw-r--r--tests/codeigniter/helpers/text_helper_test.php5
-rw-r--r--tests/codeigniter/libraries/Driver_test.php16
-rw-r--r--tests/codeigniter/libraries/Encryption_test.php4
-rw-r--r--tests/codeigniter/libraries/Form_validation_test.php3
-rw-r--r--tests/codeigniter/libraries/Table_test.php12
-rw-r--r--tests/codeigniter/libraries/Useragent_test.php4
-rw-r--r--tests/mocks/autoloader.php4
-rw-r--r--tests/mocks/ci_testcase.php20
-rwxr-xr-xtests/mocks/database/ci_test.sqlitebin19456 -> 19456 bytes
-rw-r--r--tests/mocks/database/config/mysql.php10
-rw-r--r--tests/mocks/database/config/mysqli.php10
-rw-r--r--tests/mocks/database/config/pdo/mysql.php14
-rw-r--r--tests/mocks/database/config/pdo/pgsql.php4
-rw-r--r--tests/mocks/database/config/pgsql.php4
-rw-r--r--tests/mocks/database/schema/skeleton.php10
-rw-r--r--tests/phpunit.xml3
-rw-r--r--tests/travis/mysql.phpunit.xml3
-rw-r--r--tests/travis/mysqli.phpunit.xml3
-rw-r--r--tests/travis/pdo/mysql.phpunit.xml3
-rw-r--r--tests/travis/pdo/pgsql.phpunit.xml3
-rw-r--r--tests/travis/pdo/sqlite.phpunit.xml3
-rw-r--r--tests/travis/pgsql.phpunit.xml3
-rw-r--r--tests/travis/sqlite.phpunit.xml36
35 files changed, 170 insertions, 111 deletions
diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php
index b4e56bdae..ada6a5998 100644
--- a/tests/Bootstrap.php
+++ b/tests/Bootstrap.php
@@ -65,6 +65,13 @@ else
is_php('5.6') && ini_set('php.internal_encoding', 'UTF-8');
+if (is_php('7.0'))
+{
+ $test_case_code = file_get_contents(PROJECT_BASE.'vendor/phpunit/phpunit/src/Framework/TestCase.php');
+ $test_case_code = preg_replace('/^\s+((?:protected|public)(?: static)? function \w+\(\)): void/m', '$1', $test_case_code);
+ file_put_contents(PROJECT_BASE.'vendor/phpunit/phpunit/src/Framework/TestCase.php', $test_case_code);
+}
+
include_once SYSTEM_PATH.'core/compat/mbstring.php';
include_once SYSTEM_PATH.'core/compat/hash.php';
include_once SYSTEM_PATH.'core/compat/password.php';
diff --git a/tests/codeigniter/Setup_test.php b/tests/codeigniter/Setup_test.php
index 5317c56c7..43545822a 100644
--- a/tests/codeigniter/Setup_test.php
+++ b/tests/codeigniter/Setup_test.php
@@ -1,6 +1,6 @@
<?php
-class Setup_test extends PHPUnit_Framework_TestCase {
+class Setup_test extends \PHPUnit\Framework\TestCase {
public function test_bootstrap_constants()
{
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&#40;'Hack'&#41;;[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/Log_test.php b/tests/codeigniter/core/Log_test.php
index 103af342b..927984385 100644
--- a/tests/codeigniter/core/Log_test.php
+++ b/tests/codeigniter/core/Log_test.php
@@ -57,7 +57,7 @@ class Log_test extends CI_TestCase {
$format_line->setAccessible(TRUE);
$this->assertEquals(
$format_line->invoke($instance, 'LEVEL', 'Timestamp', 'Message'),
- "LEVEL - Timestamp --> Message\n"
+ "LEVEL - Timestamp --> Message".PHP_EOL
);
}
}
diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php
index 887c077d7..8c99c1fc5 100644
--- a/tests/codeigniter/core/Output_test.php
+++ b/tests/codeigniter/core/Output_test.php
@@ -8,7 +8,7 @@ class Output_test extends CI_TestCase {
public function set_up()
{
$this->_output_data =<<<HTML
- <html>
+ <html lang="en">
<head>
<title>Basic HTML</title>
</head>
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
+}
diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php
index 93b5c3d46..facda791f 100644
--- a/tests/codeigniter/database/query_builder/select_test.php
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -74,7 +74,7 @@ class Select_test extends CI_TestCase {
->row();
// Average should be 2.5
- $this->assertEquals('2.5', $job_avg->id);
+ $this->assertEquals(2.5, (float) $job_avg->id);
}
// ------------------------------------------------------------------------
diff --git a/tests/codeigniter/helpers/array_helper_test.php b/tests/codeigniter/helpers/array_helper_test.php
index b2409c330..f4e344673 100644
--- a/tests/codeigniter/helpers/array_helper_test.php
+++ b/tests/codeigniter/helpers/array_helper_test.php
@@ -38,8 +38,8 @@ class Array_helper_test extends CI_TestCase {
public function test_elements()
{
- $this->assertInternalType('array', elements('test', $this->my_array));
- $this->assertInternalType('array', elements('foo', $this->my_array));
+ $this->assertEquals('array', gettype(elements('test', $this->my_array)));
+ $this->assertEquals('array', gettype(elements('foo', $this->my_array)));
}
}
diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php
index 5ed8cb5c0..8d7f8e1eb 100644
--- a/tests/codeigniter/helpers/file_helper_test.php
+++ b/tests/codeigniter/helpers/file_helper_test.php
@@ -6,10 +6,7 @@ class File_helper_Test extends CI_TestCase {
{
$this->helper('file');
- vfsStreamWrapper::register();
- vfsStreamWrapper::setRoot(new vfsStreamDirectory('testDir'));
-
- $this->_test_dir = vfsStreamWrapper::getRoot();
+ $this->_test_dir = vfsStream::setup('');
}
// --------------------------------------------------------------------
@@ -119,8 +116,8 @@ class File_helper_Test extends CI_TestCase {
// --------------------------------------------------------------------
- public function test_write_file()
- {
+ public function test_write_file()
+ {
$content = 'Jack and Jill went up the mountain to fight a billy goat.';
$file = vfsStream::newFile('write.txt', 0777)
@@ -129,6 +126,6 @@ class File_helper_Test extends CI_TestCase {
->at($this->_test_dir);
$this->assertTrue(write_file(vfsStream::url('write.txt'), $content));
- }
+ }
}
diff --git a/tests/codeigniter/helpers/string_helper_test.php b/tests/codeigniter/helpers/string_helper_test.php
index 6de336b01..4f15909ff 100644
--- a/tests/codeigniter/helpers/string_helper_test.php
+++ b/tests/codeigniter/helpers/string_helper_test.php
@@ -99,7 +99,7 @@ class String_helper_test extends CI_TestCase {
{
$this->assertEquals(16, strlen(random_string('alnum', 16)));
$this->assertEquals(32, strlen(random_string('unique', 16)));
- $this->assertInternalType('string', random_string('numeric', 16));
+ $this->assertEquals('string', gettype(random_string('numeric', 16)));
}
// --------------------------------------------------------------------
diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php
index 36465f203..0713775da 100644
--- a/tests/codeigniter/helpers/text_helper_test.php
+++ b/tests/codeigniter/helpers/text_helper_test.php
@@ -64,6 +64,11 @@ class Text_helper_test extends CI_TestCase {
public function test_convert_accented_characters()
{
+ if (substr(PHP_VERSION, 0, 3) === '7.4')
+ {
+ return $this->markTestSkipped('For some reason all PHP 7.4 instances on GitHub Actions trigger a parse error when foreign_chars.php is loaded');
+ }
+
$this->ci_vfs_clone('application/config/foreign_chars.php');
$this->assertEquals('AAAeEEEIIOOEUUUeY', convert_accented_characters('ÀÂÄÈÊËÎÏÔŒÙÛÜŸ'));
$this->assertEquals('a e i o u n ue', convert_accented_characters('á é í ó ú ñ ü'));
diff --git a/tests/codeigniter/libraries/Driver_test.php b/tests/codeigniter/libraries/Driver_test.php
index e4401e688..ea5cfa235 100644
--- a/tests/codeigniter/libraries/Driver_test.php
+++ b/tests/codeigniter/libraries/Driver_test.php
@@ -5,6 +5,8 @@
*/
class Driver_test extends CI_TestCase {
+ private $name;
+
/**
* Set up test framework
*/
@@ -50,8 +52,8 @@ class Driver_test extends CI_TestCase {
// Was driver loaded?
$this->assertObjectHasAttribute($driver, $this->lib);
- $this->assertAttributeInstanceOf($class, $driver, $this->lib);
- $this->assertAttributeInstanceOf('CI_Driver', $driver, $this->lib);
+ $this->assertInstanceOf($class, $this->lib->$driver);
+ $this->assertInstanceOf('CI_Driver', $this->lib->$driver);
// Was decorate called?
$this->assertObjectHasAttribute($prop, $this->lib->$driver);
@@ -85,8 +87,8 @@ class Driver_test extends CI_TestCase {
// Was driver loaded?
$this->assertObjectHasAttribute($driver, $this->lib);
- $this->assertAttributeInstanceOf($class, $driver, $this->lib);
- $this->assertAttributeInstanceOf('CI_Driver', $driver, $this->lib);
+ $this->assertInstanceOf($class, $this->lib->$driver);
+ $this->assertInstanceOf('CI_Driver', $this->lib->$driver);
// Do we get an error for a non-existent driver?
$this->setExpectedException('RuntimeException', 'CI Error: Unable to load the requested driver: CI_'.
@@ -119,9 +121,9 @@ class Driver_test extends CI_TestCase {
// Was driver loaded?
$this->assertObjectHasAttribute($driver, $this->lib);
- $this->assertAttributeInstanceOf($class, $driver, $this->lib);
- $this->assertAttributeInstanceOf($baseclass, $driver, $this->lib);
- $this->assertAttributeInstanceOf('CI_Driver', $driver, $this->lib);
+ $this->assertInstanceOf($class, $this->lib->$driver);
+ $this->assertInstanceOf($baseclass, $this->lib->$driver);
+ $this->assertInstanceOf('CI_Driver', $this->lib->$driver);
// Create driver extension without base
$driver = 'baseless';
diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
index 8e411d9fa..68bc3d804 100644
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -151,7 +151,7 @@ class Encryption_test extends CI_TestCase {
'hmac_key' => str_repeat("\x0", 16)
);
- $this->assertInternalType('array', $this->encryption->__get_params($params));
+ $this->assertEquals('array', gettype($this->encryption->__get_params($params)));
$params['base64'] = TRUE;
$params['hmac_digest'] = 'sha512';
@@ -217,7 +217,7 @@ class Encryption_test extends CI_TestCase {
/**
* encrypt(), decrypt test with custom parameters
*
- * @depends test___get_params
+ * @depends test__get_params
*/
public function test_encrypt_decrypt_custom()
{
diff --git a/tests/codeigniter/libraries/Form_validation_test.php b/tests/codeigniter/libraries/Form_validation_test.php
index 04bd670ad..1bafd50c3 100644
--- a/tests/codeigniter/libraries/Form_validation_test.php
+++ b/tests/codeigniter/libraries/Form_validation_test.php
@@ -266,6 +266,9 @@ class Form_validation_test extends CI_TestCase {
// URI scheme case-sensitivity: https://github.com/bcit-ci/CodeIgniter/pull/4758
$this->assertTrue($this->form_validation->valid_url('HtTp://127.0.0.1/'));
+ // https://github.com/bcit-ci/CodeIgniter/issues/5755
+ $this->assertFalse($this->form_validation->valid_url('1'));
+
$this->assertFalse($this->form_validation->valid_url('htt://www.codeIgniter.com'));
$this->assertFalse($this->form_validation->valid_url(''));
$this->assertFalse($this->form_validation->valid_url('code igniter'));
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php
index f505a43fc..6efae5d18 100644
--- a/tests/codeigniter/libraries/Table_test.php
+++ b/tests/codeigniter/libraries/Table_test.php
@@ -270,14 +270,14 @@ class Table_test extends CI_TestCase {
$table = $this->table->generate($data);
// Test the table header
- $this->assertContains('<th>Name</th>', $table);
- $this->assertContains('<th>Color</th>', $table);
- $this->assertContains('<th>Size</th>', $table);
+ $this->assertEquals(1, substr_count($table, '<th>Name</th>'));
+ $this->assertEquals(1, substr_count($table, '<th>Color</th>'));
+ $this->assertEquals(1, substr_count($table, '<th>Size</th>'));
// Test the first entry
- $this->assertContains('<td>Fred</td>', $table);
- $this->assertContains('<td>Blue</td>', $table);
- $this->assertContains('<td>Small</td>', $table);
+ $this->assertEquals(1, substr_count($table, '<td>Fred</td>'));
+ $this->assertEquals(1, substr_count($table, '<td>Blue</td>'));
+ $this->assertEquals(1, substr_count($table, '<td>Small</td>'));
}
}
diff --git a/tests/codeigniter/libraries/Useragent_test.php b/tests/codeigniter/libraries/Useragent_test.php
index c02f2bd9d..087544a1a 100644
--- a/tests/codeigniter/libraries/Useragent_test.php
+++ b/tests/codeigniter/libraries/Useragent_test.php
@@ -51,9 +51,9 @@ class UserAgent_test extends CI_TestCase {
public function test_referrer()
{
- $_SERVER['HTTP_REFERER'] = 'http://codeigniter.com/user_guide/';
+ $_SERVER['HTTP_REFERER'] = 'http://codeigniter.com/userguide3/';
$this->assertTrue($this->agent->is_referral());
- $this->assertEquals('http://codeigniter.com/user_guide/', $this->agent->referrer());
+ $this->assertEquals('http://codeigniter.com/userguide3/', $this->agent->referrer());
$this->agent->referer = NULL;
unset($_SERVER['HTTP_REFERER']);
diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php
index a912327ca..4dd53d4af 100644
--- a/tests/mocks/autoloader.php
+++ b/tests/mocks/autoloader.php
@@ -47,10 +47,10 @@ function autoload($class)
'Profiler',
'Table',
'Trackback',
- 'Typography',
+ 'Typography',
'Unit_test',
'Upload',
- 'User_agent',
+ 'User_agent',
'Xmlrpc',
'Zip'
);
diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php
index 4f478fb4e..de46f6df6 100644
--- a/tests/mocks/ci_testcase.php
+++ b/tests/mocks/ci_testcase.php
@@ -1,6 +1,6 @@
<?php
-class CI_TestCase extends PHPUnit_Framework_TestCase {
+class CI_TestCase extends \PHPUnit\Framework\TestCase {
public $ci_vfs_root;
public $ci_app_root;
@@ -35,7 +35,7 @@ class CI_TestCase extends PHPUnit_Framework_TestCase {
public function setUp()
{
// Setup VFS with base directories
- $this->ci_vfs_root = vfsStream::setup();
+ $this->ci_vfs_root = vfsStream::setup('');
$this->ci_app_root = vfsStream::newDirectory('application')->at($this->ci_vfs_root);
$this->ci_base_root = vfsStream::newDirectory('system')->at($this->ci_vfs_root);
$this->ci_view_root = vfsStream::newDirectory('views')->at($this->ci_app_root);
@@ -241,7 +241,7 @@ class CI_TestCase extends PHPUnit_Framework_TestCase {
$dir_root = $root->getChild($dir);
if ($dir_root)
{
- // Yes - recurse into subdir
+ // Yes - recurse into subdir
$root = $dir_root;
}
else
@@ -381,4 +381,18 @@ class CI_TestCase extends PHPUnit_Framework_TestCase {
return parent::__call($method, $args);
}
+ public function setExpectedException($exception_class, $exception_message = '', $exception_code = null)
+ {
+ $use_expect_exception = method_exists($this, 'expectException');
+
+ if ($use_expect_exception)
+ {
+ $this->expectException($exception_class);
+ $exception_message !== '' && $this->expectExceptionMessage($exception_message);
+ }
+ else
+ {
+ parent::setExpectedException($exception_class, $exception_message, $exception_code);
+ }
+ }
}
diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite
index 574d3ae53..721fbd525 100755
--- a/tests/mocks/database/ci_test.sqlite
+++ b/tests/mocks/database/ci_test.sqlite
Binary files differ
diff --git a/tests/mocks/database/config/mysql.php b/tests/mocks/database/config/mysql.php
index a590b9f53..ca30cb9ca 100644
--- a/tests/mocks/database/config/mysql.php
+++ b/tests/mocks/database/config/mysql.php
@@ -5,9 +5,9 @@ return array(
// Typical Database configuration
'mysql' => array(
'dsn' => '',
- 'hostname' => 'localhost',
+ 'hostname' => '127.0.0.1',
'username' => 'travis',
- 'password' => '',
+ 'password' => 'travis',
'database' => 'ci_test',
'dbdriver' => 'mysql'
),
@@ -15,7 +15,7 @@ return array(
// Database configuration with failover
'mysql_failover' => array(
'dsn' => '',
- 'hostname' => 'localhost',
+ 'hostname' => '127.0.0.1',
'username' => 'not_travis',
'password' => 'wrong password',
'database' => 'not_ci_test',
@@ -23,9 +23,9 @@ return array(
'failover' => array(
array(
'dsn' => '',
- 'hostname' => 'localhost',
+ 'hostname' => '127.0.0.1',
'username' => 'travis',
- 'password' => '',
+ 'password' => 'travis',
'database' => 'ci_test',
'dbdriver' => 'mysql',
)
diff --git a/tests/mocks/database/config/mysqli.php b/tests/mocks/database/config/mysqli.php
index 5dd08abb2..fd8fec962 100644
--- a/tests/mocks/database/config/mysqli.php
+++ b/tests/mocks/database/config/mysqli.php
@@ -5,9 +5,9 @@ return array(
// Typical Database configuration
'mysqli' => array(
'dsn' => '',
- 'hostname' => 'localhost',
+ 'hostname' => '127.0.0.1',
'username' => 'travis',
- 'password' => '',
+ 'password' => 'travis',
'database' => 'ci_test',
'dbdriver' => 'mysqli'
),
@@ -15,7 +15,7 @@ return array(
// Database configuration with failover
'mysqli_failover' => array(
'dsn' => '',
- 'hostname' => 'localhost',
+ 'hostname' => '127.0.0.1',
'username' => 'not_travis',
'password' => 'wrong password',
'database' => 'not_ci_test',
@@ -23,9 +23,9 @@ return array(
'failover' => array(
array(
'dsn' => '',
- 'hostname' => 'localhost',
+ 'hostname' => '127.0.0.1',
'username' => 'travis',
- 'password' => '',
+ 'password' => 'travis',
'database' => 'ci_test',
'dbdriver' => 'mysqli',
)
diff --git a/tests/mocks/database/config/pdo/mysql.php b/tests/mocks/database/config/pdo/mysql.php
index 96608f787..89e9fb130 100644
--- a/tests/mocks/database/config/pdo/mysql.php
+++ b/tests/mocks/database/config/pdo/mysql.php
@@ -4,10 +4,10 @@ return array(
// Typical Database configuration
'pdo/mysql' => array(
- 'dsn' => 'mysql:host=localhost;dbname=ci_test',
- 'hostname' => 'localhost',
+ 'dsn' => 'mysql:host=127.0.0.1;dbname=ci_test',
+ 'hostname' => '127.0.0.1',
'username' => 'travis',
- 'password' => '',
+ 'password' => 'travis',
'database' => 'ci_test',
'dbdriver' => 'pdo',
'subdriver' => 'mysql'
@@ -16,7 +16,7 @@ return array(
// Database configuration with failover
'pdo/mysql_failover' => array(
'dsn' => '',
- 'hostname' => 'localhost',
+ 'hostname' => '127.0.0.1',
'username' => 'not_travis',
'password' => 'wrong password',
'database' => 'not_ci_test',
@@ -24,10 +24,10 @@ return array(
'subdriver' => 'mysql',
'failover' => array(
array(
- 'dsn' => 'mysql:host=localhost;dbname=ci_test',
- 'hostname' => 'localhost',
+ 'dsn' => 'mysql:host=127.0.0.1;dbname=ci_test',
+ 'hostname' => '127.0.0.1',
'username' => 'travis',
- 'password' => '',
+ 'password' => 'travis',
'database' => 'ci_test',
'dbdriver' => 'pdo',
'subdriver' => 'mysql'
diff --git a/tests/mocks/database/config/pdo/pgsql.php b/tests/mocks/database/config/pdo/pgsql.php
index e55e3ea77..846c70be9 100644
--- a/tests/mocks/database/config/pdo/pgsql.php
+++ b/tests/mocks/database/config/pdo/pgsql.php
@@ -7,7 +7,7 @@ return array(
'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;',
'hostname' => 'localhost',
'username' => 'postgres',
- 'password' => '',
+ 'password' => 'postgres',
'database' => 'ci_test',
'dbdriver' => 'pdo',
'subdriver' => 'pgsql'
@@ -27,7 +27,7 @@ return array(
'dsn' => 'pgsql:host=localhost;port=5432;dbname=ci_test;',
'hostname' => 'localhost',
'username' => 'postgres',
- 'password' => '',
+ 'password' => 'postgres',
'database' => 'ci_test',
'dbdriver' => 'pdo',
'subdriver' => 'pgsql'
diff --git a/tests/mocks/database/config/pgsql.php b/tests/mocks/database/config/pgsql.php
index 1444b0066..ce4583728 100644
--- a/tests/mocks/database/config/pgsql.php
+++ b/tests/mocks/database/config/pgsql.php
@@ -7,7 +7,7 @@ return array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'postgres',
- 'password' => '',
+ 'password' => 'postgres',
'database' => 'ci_test',
'dbdriver' => 'postgre'
),
@@ -25,7 +25,7 @@ return array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'postgres',
- 'password' => '',
+ 'password' => 'postgres',
'database' => 'ci_test',
'dbdriver' => 'postgre',
)
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
index 888236ff3..e2b6e7d0e 100644
--- a/tests/mocks/database/schema/skeleton.php
+++ b/tests/mocks/database/schema/skeleton.php
@@ -76,7 +76,7 @@ class Mock_Database_Schema_Skeleton {
)
));
self::$forge->add_key('id', TRUE);
- self::$forge->create_table('user', TRUE);
+ self::$forge->create_table('user', TRUE) OR show_error('Unable to create the `user` table');
// Job Table
self::$forge->add_field(array(
@@ -93,7 +93,7 @@ class Mock_Database_Schema_Skeleton {
)
));
self::$forge->add_key('id', TRUE);
- self::$forge->create_table('job', TRUE);
+ self::$forge->create_table('job', TRUE) OR show_error('Unable to create the `job` table');
// Misc Table
self::$forge->add_field(array(
@@ -110,7 +110,7 @@ class Mock_Database_Schema_Skeleton {
)
));
self::$forge->add_key('id', TRUE);
- self::$forge->create_table('misc', TRUE);
+ self::$forge->create_table('misc', TRUE) OR show_error('Unable to create the `misc` table');
}
/**
@@ -143,11 +143,11 @@ class Mock_Database_Schema_Skeleton {
foreach ($data as $table => $dummy_data)
{
- self::$db->truncate($table);
+ self::$db->truncate($table) OR show_error("Unable to truncate `{$table}` table");
foreach ($dummy_data as $single_dummy_data)
{
- self::$db->insert($table, $single_dummy_data);
+ self::$db->insert($table, $single_dummy_data) OR show_error("Unable to insert data into `{$table}` table");
}
}
}
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index 875198c4e..a1626ce91 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -8,7 +8,8 @@
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
- stopOnSkipped="false">
+ stopOnSkipped="false"
+ beStrictAboutTestsThatDoNotTestAnything="false">
<testsuites>
<testsuite name="CodeIgniter Core Test Suite">
<directory suffix="test.php">./codeigniter/core</directory>
diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml
index 06d4a011b..15063fd5a 100644
--- a/tests/travis/mysql.phpunit.xml
+++ b/tests/travis/mysql.phpunit.xml
@@ -8,7 +8,8 @@
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
- stopOnSkipped="false">
+ stopOnSkipped="false"
+ beStrictAboutTestsThatDoNotTestAnything="false">
<php>
<const name="DB_DRIVER" value="mysql"/>
</php>
diff --git a/tests/travis/mysqli.phpunit.xml b/tests/travis/mysqli.phpunit.xml
index 1364f8bfa..c77aaa303 100644
--- a/tests/travis/mysqli.phpunit.xml
+++ b/tests/travis/mysqli.phpunit.xml
@@ -8,7 +8,8 @@
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
- stopOnSkipped="false">
+ stopOnSkipped="false"
+ beStrictAboutTestsThatDoNotTestAnything="false">
<php>
<const name="DB_DRIVER" value="mysqli"/>
</php>
diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml
index 7121edc45..1a9030ddf 100644
--- a/tests/travis/pdo/mysql.phpunit.xml
+++ b/tests/travis/pdo/mysql.phpunit.xml
@@ -8,7 +8,8 @@
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
- stopOnSkipped="false">
+ stopOnSkipped="false"
+ beStrictAboutTestsThatDoNotTestAnything="false">
<php>
<const name="DB_DRIVER" value="pdo/mysql"/>
</php>
diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml
index df3ff986e..22261ee7d 100644
--- a/tests/travis/pdo/pgsql.phpunit.xml
+++ b/tests/travis/pdo/pgsql.phpunit.xml
@@ -8,7 +8,8 @@
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
- stopOnSkipped="false">
+ stopOnSkipped="false"
+ beStrictAboutTestsThatDoNotTestAnything="false">
<php>
<const name="DB_DRIVER" value="pdo/pgsql"/>
</php>
diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml
index 7d867f6d1..4b0ca2fe7 100644
--- a/tests/travis/pdo/sqlite.phpunit.xml
+++ b/tests/travis/pdo/sqlite.phpunit.xml
@@ -8,7 +8,8 @@
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
- stopOnSkipped="false">
+ stopOnSkipped="false"
+ beStrictAboutTestsThatDoNotTestAnything="false">
<php>
<const name="DB_DRIVER" value="pdo/sqlite"/>
</php>
diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml
index bfddbf6b5..8d7979a0f 100644
--- a/tests/travis/pgsql.phpunit.xml
+++ b/tests/travis/pgsql.phpunit.xml
@@ -8,7 +8,8 @@
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
- stopOnSkipped="false">
+ stopOnSkipped="false"
+ beStrictAboutTestsThatDoNotTestAnything="false">
<php>
<const name="DB_DRIVER" value="pgsql"/>
</php>
diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml
index 75c946aee..4eaafc19f 100644
--- a/tests/travis/sqlite.phpunit.xml
+++ b/tests/travis/sqlite.phpunit.xml
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="../Bootstrap.php"
colors="true"
convertNoticesToExceptions="true"
@@ -8,18 +7,21 @@
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
- stopOnSkipped="false">
- <php>
- <const name="DB_DRIVER" value="sqlite"/>
- </php>
- <testsuites>
- <testsuite name="CodeIgniter Core Test Suite">
- <directory suffix="test.php">../codeigniter</directory>
- </testsuite>
- </testsuites>
- <filter>
- <whitelist addUncoveredFilesFromWhitelist="false">
- <directory suffix=".php">../../system</directory>
- </whitelist>
- </filter>
-</phpunit> \ No newline at end of file
+ stopOnSkipped="false"
+ beStrictAboutTestsThatDoNotTestAnything="false"
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
+>
+ <coverage includeUncoveredFiles="false">
+ <include>
+ <directory suffix=".php">../../system</directory>
+ </include>
+ </coverage>
+ <php>
+ <const name="DB_DRIVER" value="sqlite"/>
+ </php>
+ <testsuites>
+ <testsuite name="CodeIgniter Core Test Suite">
+ <directory suffix="test.php">../codeigniter</directory>
+ </testsuite>
+ </testsuites>
+</phpunit>