From e24aee746aa9279378b78abaa6bf4a6ae87f5e1b Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 31 May 2021 13:15:00 +0300 Subject: don't mark no-assertions tests as failed --- tests/phpunit.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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"> ./codeigniter/core -- cgit v1.2.3-24-g4f1b From 460135db1101957a3233b7d78fb2bb78e3508f75 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 31 May 2021 13:16:33 +0300 Subject: Travis: PHP 7.4 seems to fail if XDEBUG_MODE=coverage is not set --- .travis.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5070c24c2..031aba6c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,13 +11,15 @@ php: - 7.4 - nightly -env: - - DB=mysqli - - DB=pgsql - - DB=sqlite - - DB=pdo/mysql - - DB=pdo/pgsql - - DB=pdo/sqlite + global: + - XDEBUG_MODE=coverage + jobs: + - DB=mysqli + - DB=pgsql + - DB=sqlite + - DB=pdo/mysql + - DB=pdo/pgsql + - DB=pdo/sqlite services: - mysql -- cgit v1.2.3-24-g4f1b From 5fe5a94930d58f2d6dcdda2a3b0d97978b3c3c8d Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 31 May 2021 13:17:51 +0300 Subject: Travis: ignore mbstring.func_overload=7 for PHP >= 7.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 031aba6c7..8657358ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ before_script: - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" -script: php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 -d mbstring.internal_encoding=UTF-8 vendor/bin/phpunit --coverage-text --configuration tests/travis/$DB.phpunit.xml +script: test $(php -r 'echo PHP_VERSION_ID;') -lt 70300 && php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 -d mbstring.internal_encoding=UTF-8 vendor/bin/phpunit --coverage-text --configuration tests/travis/$DB.phpunit.xml || php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.internal_encoding=UTF-8 vendor/bin/phpunit --coverage-text --configuration tests/travis/$DB.phpunit.xml jobs: allow_failures: -- cgit v1.2.3-24-g4f1b From 56de63c5bdfd7962d2e64d6d9b0a5b7914d4ec6c Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 31 May 2021 13:23:32 +0300 Subject: Upgrade to latest mikey179/vfsstream --- composer.json | 2 +- tests/codeigniter/helpers/file_helper_test.php | 5 +---- tests/codeigniter/helpers/text_helper_test.php | 7 +------ tests/mocks/ci_testcase.php | 2 +- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 39c7e77c4..aac516c8a 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "paragonie/random_compat": "Provides better randomness in PHP 5.x" }, "require-dev": { - "mikey179/vfsstream": "1.1.*", + "mikey179/vfsstream": "1.6.*", "phpunit/phpunit": "4.* || 5.*" } } diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php index dd74ee46b..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(''); } // -------------------------------------------------------------------- diff --git a/tests/codeigniter/helpers/text_helper_test.php b/tests/codeigniter/helpers/text_helper_test.php index e51d96a29..36465f203 100644 --- a/tests/codeigniter/helpers/text_helper_test.php +++ b/tests/codeigniter/helpers/text_helper_test.php @@ -64,12 +64,7 @@ class Text_helper_test extends CI_TestCase { public function test_convert_accented_characters() { - $path = 'application/config/foreign_chars.php'; - $this->ci_vfs_clone($path); - if (is_php('7.4')) - { - copy(PROJECT_BASE.$path, APPPATH.'../'.$path); - } + $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/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index 8dc4682ef..fbd56af03 100644 --- a/tests/mocks/ci_testcase.php +++ b/tests/mocks/ci_testcase.php @@ -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); -- cgit v1.2.3-24-g4f1b From 81c793551d2bd6c2919a9a46462d464965c8207f Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 31 May 2021 13:28:25 +0300 Subject: Adding PHPUnit 8 --- composer.json | 2 +- tests/Bootstrap.php | 7 +++++++ tests/codeigniter/Setup_test.php | 2 +- tests/mocks/ci_testcase.php | 16 +++++++++++++++- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index aac516c8a..a20d0f336 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,6 @@ }, "require-dev": { "mikey179/vfsstream": "1.6.*", - "phpunit/phpunit": "4.* || 5.*" + "phpunit/phpunit": "4.* || 5.* || 8.*" } } 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 @@ expectException($exception_class); + $exception_message !== '' && $this->expectExceptionMessage($exception_message); + } + else + { + parent::setExpectedException($exception_class, $exception_message, $exception_code); + } + } } -- cgit v1.2.3-24-g4f1b From d1d3e69e90ecdfa9ebe1a766198438815b30eee6 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 31 May 2021 13:32:13 +0300 Subject: other test fixes --- tests/codeigniter/core/Input_test.php | 14 +++++++++++--- tests/codeigniter/database/query_builder/select_test.php | 2 +- 2 files changed, 12 insertions(+), 4 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/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); } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From c7e171e0d83d7092d459c2754a1ee3aba33e43ef Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 31 May 2021 13:49:15 +0300 Subject: Fixes travis yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8657358ed..bf86bace1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,7 @@ php: - 7.4 - nightly +env: global: - XDEBUG_MODE=coverage jobs: -- cgit v1.2.3-24-g4f1b