diff options
author | George Petculescu <gxgpet@gmail.com> | 2021-05-31 12:28:25 +0200 |
---|---|---|
committer | George Petculescu <gxgpet@gmail.com> | 2021-05-31 12:28:25 +0200 |
commit | 81c793551d2bd6c2919a9a46462d464965c8207f (patch) | |
tree | d1daf5024a3627df8493c8056e202302ca052d10 | |
parent | 56de63c5bdfd7962d2e64d6d9b0a5b7914d4ec6c (diff) |
Adding PHPUnit 8
-rw-r--r-- | composer.json | 2 | ||||
-rw-r--r-- | tests/Bootstrap.php | 7 | ||||
-rw-r--r-- | tests/codeigniter/Setup_test.php | 2 | ||||
-rw-r--r-- | 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 @@ <?php -class Setup_test extends PHPUnit_Framework_TestCase { +class Setup_test extends \PHPUnit\Framework\TestCase { public function test_bootstrap_constants() { diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index fbd56af03..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; @@ -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); + } + } } |