From af8cbdeed7b43951301e906bf73cabd948a9299a Mon Sep 17 00:00:00 2001 From: sapics Date: Sat, 16 Jan 2021 16:10:19 +0900 Subject: Fix error in core/Output.php for php8.0 Fix error in array_shift array_map('array_shift', $this->headers) causes error as array_shift(): Argument bcit-ci#1 ($array) must be passed by reference, value given --- system/core/Output.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/core/Output.php b/system/core/Output.php index c56aff4b0..02c6d151b 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -300,9 +300,13 @@ class CI_Output { public function get_header($header) { // Combine headers already sent with our batched headers + $headers = array(); + foreach ($this->headers as $value) + { + $headers[] = $value[0]; + } $headers = array_merge( - // We only need [x][0] from our multi-dimensional array - array_map('array_shift', $this->headers), + $headers, headers_list() ); -- cgit v1.2.3-24-g4f1b From 624ddad97028087ee4d61ab90827b944a192f65e Mon Sep 17 00:00:00 2001 From: sapics Date: Sat, 16 Jan 2021 16:10:57 +0900 Subject: Fix error in pdo/pgsql for php8.0 From PHP8.0, default PDO::ATTR_ERRMODE is changed from PDO::ERRMODE_SILENT to PDO::ERRMODE_EXCEPTION. Reference: https://wiki.php.net/rfc/pdo_default_errmode --- system/database/DB_driver.php | 2 +- system/database/drivers/pdo/pdo_driver.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index cba96d9a2..a213d5cba 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -825,7 +825,7 @@ abstract class CI_DB_driver { { return $this->_trans_status; } - + // -------------------------------------------------------------------- /** diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index d0a2bf959..b2178b684 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -131,6 +131,14 @@ class CI_DB_pdo_driver extends CI_DB { $this->options[PDO::ATTR_PERSISTENT] = TRUE; } + // From PHP8.0, default PDO::ATTR_ERRMODE is changed + // from PDO::ERRMODE_SILENT to PDO::ERRMODE_EXCEPTION + // as https://wiki.php.net/rfc/pdo_default_errmode + if ( ! isset($this->options[PDO::ATTR_ERRMODE])) + { + $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; + } + try { return new PDO($this->dsn, $this->username, $this->password, $this->options); -- cgit v1.2.3-24-g4f1b From 5ad670dea78cc0f0c0fd690220a243a905cb06bf Mon Sep 17 00:00:00 2001 From: sapics Date: Sat, 16 Jan 2021 16:13:37 +0900 Subject: Replace travis-ci to github actions for php8.0 --- .github/workflows/test-phpunit.yml | 106 +++++++++++++++++++++++++++++ .travis.yml | 109 ------------------------------ tests/mocks/database/config/mysql.php | 10 +-- tests/mocks/database/config/mysqli.php | 10 +-- tests/mocks/database/config/pdo/mysql.php | 14 ++-- tests/mocks/database/config/pdo/pgsql.php | 4 +- tests/mocks/database/config/pgsql.php | 4 +- 7 files changed, 127 insertions(+), 130 deletions(-) create mode 100644 .github/workflows/test-phpunit.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml new file mode 100644 index 000000000..bba336ce7 --- /dev/null +++ b/.github/workflows/test-phpunit.yml @@ -0,0 +1,106 @@ +name: PHPUnit + +on: [push, pull_request] + +jobs: + tests: + runs-on: ubuntu-18.04 + if: "!contains(github.event.head_commit.message, '[ci skip]')" + env: + PHP_INI_VALUES: assert.exception=1, zend.assertions=1 + + strategy: + fail-fast: false + matrix: + php: [ '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6', '5.5', '5.4' ] + DB: [ 'pdo/mysql', 'pdo/pgsql', 'pdo/sqlite', 'mysqli', 'pgsql', 'sqlite' ] + compiler: [ default ] + include: + - php: '8.0' + DB: 'pdo/mysql' + compiler: jit + - php: '8.0' + DB: 'pdo/pgsql' + compiler: jit + - php: '8.0' + DB: 'pdo/sqlite' + compiler: jit + - php: '8.0' + DB: 'mysqli' + compiler: jit + - php: '8.0' + DB: 'pgsql' + compiler: jit + - php: '8.0' + DB: 'sqlite' + compiler: jit + - php: '5.6' + DB: 'mysql' + compiler: default + - php: '5.5' + DB: 'mysql' + compiler: default + - php: '5.4' + DB: 'mysql' + compiler: default + + services: + postgres: + image: postgres:12 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: ci_test + ports: + - 5432:5432 + options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3 + + mysql: + image: mysql:5.7 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: true + MYSQL_USER: travis + MYSQL_PASSWORD: travis + MYSQL_DATABASE: ci_test + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Override PHP ini values for JIT compiler + if: matrix.compiler == 'jit' + run: echo "PHP_INI_VALUES::assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit=1255, opcache.jit_buffer_size=64M" >> $GITHUB_ENV + + - name: Install PHP${{ matrix.php }} - DB ${{ matrix.DB }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: composer, pecl + extensions: imagick, sqlite3, pgsql, mysqli, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite + ini-values: ${{ env.PHP_INI_VALUES }} + coverage: xdebug + + - name: Setup composer for PHP8.0+ + run: if [ '${{ matrix.php }}' = '8.0' ] || [ '${{ matrix.php }}' = '8.1' ] ; then sed -i 's/phpunit\/phpunit/sminnee\/phpunit/g' composer.json; composer config -g platform.php 7.4.11; fi + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Fix error in vfsStream + run: sed -i s/name{0}/name[0]/ vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStream.php + + - name: PHPUnit Test + run: | + 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/${{ matrix.DB }}.phpunit.xml + env: + XDEBUG_MODE: coverage diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5070c24c2..000000000 --- a/.travis.yml +++ /dev/null @@ -1,109 +0,0 @@ -language: php -os: linux -dist: xenial - -php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - nightly - -env: - - DB=mysqli - - DB=pgsql - - DB=sqlite - - DB=pdo/mysql - - DB=pdo/pgsql - - DB=pdo/sqlite - -services: - - mysql - - postgresql - -cache: - directories: - - $HOME/.composer/cache - -before_script: - - sh -c "composer install --no-progress" - - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - - 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 - -jobs: - allow_failures: - - php: nightly - - php: hhvm-3.30 - include: - - php: 5.4 - dist: trusty - env: DB=mysql - - php: 5.4 - dist: trusty - env: DB=mysqli - - php: 5.4 - dist: trusty - env: DB=pgsql - - php: 5.4 - dist: trusty - env: DB=sqlite - - php: 5.4 - dist: trusty - env: DB=pdo/mysql - - php: 5.4 - dist: trusty - env: DB=pdo/pgsql - - php: 5.4 - dist: trusty - env: DB=pdo/sqlite - - php: 5.5 - dist: trusty - env: DB=mysql - - php: 5.5 - dist: trusty - env: DB=mysqli - - php: 5.5 - dist: trusty - env: DB=pgsql - - php: 5.5 - dist: trusty - env: DB=sqlite - - php: 5.5 - dist: trusty - env: DB=pdo/mysql - - php: 5.5 - dist: trusty - env: DB=pdo/pgsql - - php: 5.5 - dist: trusty - env: DB=pdo/sqlite - - php: 5.6 - dist: xenial - env: DB=mysql - - php: hhvm-3.30 - dist: trusty - env: DB=mysql - - php: hhvm-3.30 - dist: trusty - env: DB=mysqli - - php: hhvm-3.30 - dist: trusty - env: DB=sqlite - - php: hhvm-3.30 - dist: trusty - env: DB=pdo/mysql - - php: hhvm-3.30 - dist: trusty - env: DB=pdo/sqlite - -branches: - only: - - develop - - 3.0-stable - - 3.1-stable - - /^feature\/.+$/ 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', ) -- cgit v1.2.3-24-g4f1b From 5afd6af3f3293a27db5377b3f97ca88df07174b1 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Sun, 26 Sep 2021 23:56:39 +0300 Subject: Adds PHP 8 in Travis --- .travis.yml | 1 + system/core/Output.php | 9 ++++-- tests/codeigniter/core/Loader_test.php | 39 +++++++++++++++--------- tests/codeigniter/core/Log_test.php | 2 +- tests/codeigniter/core/compat/mbstring_test.php | 4 +-- tests/codeigniter/helpers/array_helper_test.php | 4 +-- tests/codeigniter/helpers/string_helper_test.php | 2 +- tests/codeigniter/libraries/Driver_test.php | 16 +++++----- tests/codeigniter/libraries/Encryption_test.php | 4 +-- tests/codeigniter/libraries/Table_test.php | 12 ++++---- tests/travis/mysql.phpunit.xml | 3 +- tests/travis/mysqli.phpunit.xml | 3 +- tests/travis/pdo/mysql.phpunit.xml | 3 +- tests/travis/pdo/pgsql.phpunit.xml | 3 +- tests/travis/pdo/sqlite.phpunit.xml | 3 +- tests/travis/pgsql.phpunit.xml | 3 +- tests/travis/sqlite.phpunit.xml | 3 +- 17 files changed, 70 insertions(+), 44 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf86bace1..d3a09573d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ php: - 7.2 - 7.3 - 7.4 + - 8.0 - nightly env: diff --git a/system/core/Output.php b/system/core/Output.php index c56aff4b0..a2397763d 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -299,10 +299,15 @@ class CI_Output { */ public function get_header($header) { + // We only need [x][0] from our multi-dimensional array + $header_lines = array_map(function ($headers) + { + return array_shift($headers); + }, $this->headers); + // Combine headers already sent with our batched headers $headers = array_merge( - // We only need [x][0] from our multi-dimensional array - array_map('array_shift', $this->headers), + $header_lines, headers_list() ); 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 927984385..564241ce2 100644 --- a/tests/codeigniter/core/Log_test.php +++ b/tests/codeigniter/core/Log_test.php @@ -2,7 +2,7 @@ class Log_test extends CI_TestCase { public function test_configuration() - { + {$this->markTestSkipped('test'); $path = new ReflectionProperty('CI_Log', '_log_path'); $path->setAccessible(TRUE); $threshold = new ReflectionProperty('CI_Log', '_threshold'); diff --git a/tests/codeigniter/core/compat/mbstring_test.php b/tests/codeigniter/core/compat/mbstring_test.php index 415222446..8b8629efc 100644 --- a/tests/codeigniter/core/compat/mbstring_test.php +++ b/tests/codeigniter/core/compat/mbstring_test.php @@ -27,7 +27,7 @@ class mbstring_test extends CI_TestCase { // ------------------------------------------------------------------------ /** - * @depends test_boostrap + * @depends test_bootstrap */ public function test_mb_strpos() { @@ -39,7 +39,7 @@ class mbstring_test extends CI_TestCase { // ------------------------------------------------------------------------ /** - * @depends test_boostrap + * @depends test_bootstrap */ public function test_mb_substr() { 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/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/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/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('Name', $table); - $this->assertContains('Color', $table); - $this->assertContains('Size', $table); + $this->assertEquals(1, substr_count($table, 'Name')); + $this->assertEquals(1, substr_count($table, 'Color')); + $this->assertEquals(1, substr_count($table, 'Size')); // Test the first entry - $this->assertContains('Fred', $table); - $this->assertContains('Blue', $table); - $this->assertContains('Small', $table); + $this->assertEquals(1, substr_count($table, 'Fred')); + $this->assertEquals(1, substr_count($table, 'Blue')); + $this->assertEquals(1, substr_count($table, 'Small')); } } 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"> 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"> 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"> 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"> 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"> 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"> diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml index 75c946aee..0c4da0d1b 100644 --- a/tests/travis/sqlite.phpunit.xml +++ b/tests/travis/sqlite.phpunit.xml @@ -8,7 +8,8 @@ stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" - stopOnSkipped="false"> + stopOnSkipped="false" + beStrictAboutTestsThatDoNotTestAnything="false"> -- cgit v1.2.3-24-g4f1b From 9f6925398097a4f655827dc4030c82d435e27ae8 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Sun, 26 Sep 2021 23:56:39 +0300 Subject: Adds PHP 8 in Travis --- .travis.yml | 1 + system/core/Output.php | 9 ++++-- tests/codeigniter/core/Loader_test.php | 39 +++++++++++++++--------- tests/codeigniter/core/Log_test.php | 2 +- tests/codeigniter/core/compat/mbstring_test.php | 4 +-- tests/codeigniter/helpers/array_helper_test.php | 4 +-- tests/codeigniter/helpers/string_helper_test.php | 2 +- tests/codeigniter/libraries/Driver_test.php | 16 +++++----- tests/codeigniter/libraries/Encryption_test.php | 4 +-- tests/codeigniter/libraries/Table_test.php | 12 ++++---- tests/travis/mysql.phpunit.xml | 3 +- tests/travis/mysqli.phpunit.xml | 3 +- tests/travis/pdo/mysql.phpunit.xml | 3 +- tests/travis/pdo/pgsql.phpunit.xml | 3 +- tests/travis/pdo/sqlite.phpunit.xml | 3 +- tests/travis/pgsql.phpunit.xml | 3 +- tests/travis/sqlite.phpunit.xml | 3 +- 17 files changed, 70 insertions(+), 44 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf86bace1..d3a09573d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ php: - 7.2 - 7.3 - 7.4 + - 8.0 - nightly env: diff --git a/system/core/Output.php b/system/core/Output.php index c56aff4b0..a2397763d 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -299,10 +299,15 @@ class CI_Output { */ public function get_header($header) { + // We only need [x][0] from our multi-dimensional array + $header_lines = array_map(function ($headers) + { + return array_shift($headers); + }, $this->headers); + // Combine headers already sent with our batched headers $headers = array_merge( - // We only need [x][0] from our multi-dimensional array - array_map('array_shift', $this->headers), + $header_lines, headers_list() ); 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 927984385..564241ce2 100644 --- a/tests/codeigniter/core/Log_test.php +++ b/tests/codeigniter/core/Log_test.php @@ -2,7 +2,7 @@ class Log_test extends CI_TestCase { public function test_configuration() - { + {$this->markTestSkipped('test'); $path = new ReflectionProperty('CI_Log', '_log_path'); $path->setAccessible(TRUE); $threshold = new ReflectionProperty('CI_Log', '_threshold'); diff --git a/tests/codeigniter/core/compat/mbstring_test.php b/tests/codeigniter/core/compat/mbstring_test.php index 415222446..8b8629efc 100644 --- a/tests/codeigniter/core/compat/mbstring_test.php +++ b/tests/codeigniter/core/compat/mbstring_test.php @@ -27,7 +27,7 @@ class mbstring_test extends CI_TestCase { // ------------------------------------------------------------------------ /** - * @depends test_boostrap + * @depends test_bootstrap */ public function test_mb_strpos() { @@ -39,7 +39,7 @@ class mbstring_test extends CI_TestCase { // ------------------------------------------------------------------------ /** - * @depends test_boostrap + * @depends test_bootstrap */ public function test_mb_substr() { 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/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/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/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('Name', $table); - $this->assertContains('Color', $table); - $this->assertContains('Size', $table); + $this->assertEquals(1, substr_count($table, 'Name')); + $this->assertEquals(1, substr_count($table, 'Color')); + $this->assertEquals(1, substr_count($table, 'Size')); // Test the first entry - $this->assertContains('Fred', $table); - $this->assertContains('Blue', $table); - $this->assertContains('Small', $table); + $this->assertEquals(1, substr_count($table, 'Fred')); + $this->assertEquals(1, substr_count($table, 'Blue')); + $this->assertEquals(1, substr_count($table, 'Small')); } } 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"> 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"> 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"> 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"> 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"> 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"> diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml index 75c946aee..0c4da0d1b 100644 --- a/tests/travis/sqlite.phpunit.xml +++ b/tests/travis/sqlite.phpunit.xml @@ -8,7 +8,8 @@ stopOnError="false" stopOnFailure="false" stopOnIncomplete="false" - stopOnSkipped="false"> + stopOnSkipped="false" + beStrictAboutTestsThatDoNotTestAnything="false"> -- cgit v1.2.3-24-g4f1b From bd5fab166ccff8c0bae963cd9d83a65c226cefa2 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 4 Oct 2021 19:40:47 +0300 Subject: Fixes CREATE TABLE IF NOT EXISTS on pdo_pgsql_forge; checking for dummy data DB operations result returns --- system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php | 7 +++++++ tests/mocks/database/schema/skeleton.php | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php index 187cb2d09..4c3a5aaea 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php +++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_forge.php @@ -53,6 +53,13 @@ class CI_DB_pdo_pgsql_forge extends CI_DB_pdo_forge { */ protected $_drop_table_if = 'DROP TABLE IF EXISTS'; + /** + * CREATE TABLE IF statement + * + * @var string + */ + protected $_create_table_if = 'CREATE TABLE IF NOT EXISTS'; + /** * UNSIGNED support * diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index 888236ff3..e14aa4af4 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) || 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) || 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) || 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) || 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) || show_error("Unable to insert data into `{$table}` table"); } } } -- cgit v1.2.3-24-g4f1b From 6858cdf44b5f05e624cd2315a31ba162956180e7 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Mon, 4 Oct 2021 23:30:05 +0300 Subject: whoops :) --- tests/codeigniter/core/Log_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeigniter/core/Log_test.php b/tests/codeigniter/core/Log_test.php index 564241ce2..927984385 100644 --- a/tests/codeigniter/core/Log_test.php +++ b/tests/codeigniter/core/Log_test.php @@ -2,7 +2,7 @@ class Log_test extends CI_TestCase { public function test_configuration() - {$this->markTestSkipped('test'); + { $path = new ReflectionProperty('CI_Log', '_log_path'); $path->setAccessible(TRUE); $threshold = new ReflectionProperty('CI_Log', '_threshold'); -- cgit v1.2.3-24-g4f1b From bf7dab3eeba78bc920a7b026558cf820aefd1f3d Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Tue, 5 Oct 2021 12:01:25 +0300 Subject: Fixes styleguide ORs --- tests/mocks/database/schema/skeleton.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php index e14aa4af4..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) || show_error('Unable to create the `user` table'); + 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) || show_error('Unable to create the `job` table'); + 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) || show_error('Unable to create the `misc` table'); + 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) || show_error("Unable to truncate `{$table}` 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) || show_error("Unable to insert data into `{$table}` table"); + self::$db->insert($table, $single_dummy_data) OR show_error("Unable to insert data into `{$table}` table"); } } } -- cgit v1.2.3-24-g4f1b From d49ffb0cbbb19b552bf8f33cbfe9e52505eae21e Mon Sep 17 00:00:00 2001 From: ddonatek Date: Tue, 2 Nov 2021 23:53:06 +0100 Subject: Added another SVG mimetype Some MIME detection programs/libraries identify SVG files without `` declaration as `image/svg` --- application/config/mimes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index f5407ff89..b2e989fea 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -162,7 +162,7 @@ return array( 'cdr' => array('application/cdr', 'application/coreldraw', 'application/x-cdr', 'application/x-coreldraw', 'image/cdr', 'image/x-cdr', 'zz-application/zz-winassoc-cdr'), 'wma' => array('audio/x-ms-wma', 'video/x-ms-asf'), 'jar' => array('application/java-archive', 'application/x-java-application', 'application/x-jar', 'application/x-compressed'), - 'svg' => array('image/svg+xml', 'application/xml', 'text/xml'), + 'svg' => array('image/svg+xml', 'image/svg', 'application/xml', 'text/xml'), 'vcf' => 'text/x-vcard', 'srt' => array('text/srt', 'text/plain'), 'vtt' => array('text/vtt', 'text/plain'), -- cgit v1.2.3-24-g4f1b From 298b06e5d823370a49dd49661cc8cc08f9a51ead Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 17 Nov 2021 17:33:37 +0000 Subject: chore: update to phpunit 9 --- composer.json | 2 +- tests/codeigniter/core/Security_test.php | 2 +- tests/travis/sqlite.phpunit.xml | 35 ++++++++++++++++---------------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index a20d0f336..722c9b7d9 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,6 @@ }, "require-dev": { "mikey179/vfsstream": "1.6.*", - "phpunit/phpunit": "4.* || 5.* || 8.*" + "phpunit/phpunit": "4.* || 5.* || 9.*" } } diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 64efdf9c8..e6a980e7a 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -253,7 +253,7 @@ class Security_test extends CI_TestCase { // Perform hash $this->security->xss_hash(); - $this->assertRegExp('#^[0-9a-f]{32}$#iS', $this->security->xss_hash); + $this->assertMatchesRegularExpression('#^[0-9a-f]{32}$#iS', $this->security->xss_hash); } // -------------------------------------------------------------------- diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml index 0c4da0d1b..4eaafc19f 100644 --- a/tests/travis/sqlite.phpunit.xml +++ b/tests/travis/sqlite.phpunit.xml @@ -1,6 +1,5 @@ - - - - - - - - ../codeigniter - - - - - ../../system - - - \ No newline at end of file + beStrictAboutTestsThatDoNotTestAnything="false" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" +> + + + ../../system + + + + + + + + ../codeigniter + + + -- cgit v1.2.3-24-g4f1b From e7110e559a0c46d5001368c25ed246ff303d3afe Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 3 Dec 2021 11:46:17 +0000 Subject: chore: back to travis --- .github/workflows/test-phpunit.yml | 106 ----------------------------------- .travis.yml | 112 +++++++++++++++++++++++++++++++++++++ composer.json | 6 ++ 3 files changed, 118 insertions(+), 106 deletions(-) delete mode 100644 .github/workflows/test-phpunit.yml create mode 100644 .travis.yml diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml deleted file mode 100644 index bba336ce7..000000000 --- a/.github/workflows/test-phpunit.yml +++ /dev/null @@ -1,106 +0,0 @@ -name: PHPUnit - -on: [push, pull_request] - -jobs: - tests: - runs-on: ubuntu-18.04 - if: "!contains(github.event.head_commit.message, '[ci skip]')" - env: - PHP_INI_VALUES: assert.exception=1, zend.assertions=1 - - strategy: - fail-fast: false - matrix: - php: [ '8.0', '7.4', '7.3', '7.2', '7.1', '7.0', '5.6', '5.5', '5.4' ] - DB: [ 'pdo/mysql', 'pdo/pgsql', 'pdo/sqlite', 'mysqli', 'pgsql', 'sqlite' ] - compiler: [ default ] - include: - - php: '8.0' - DB: 'pdo/mysql' - compiler: jit - - php: '8.0' - DB: 'pdo/pgsql' - compiler: jit - - php: '8.0' - DB: 'pdo/sqlite' - compiler: jit - - php: '8.0' - DB: 'mysqli' - compiler: jit - - php: '8.0' - DB: 'pgsql' - compiler: jit - - php: '8.0' - DB: 'sqlite' - compiler: jit - - php: '5.6' - DB: 'mysql' - compiler: default - - php: '5.5' - DB: 'mysql' - compiler: default - - php: '5.4' - DB: 'mysql' - compiler: default - - services: - postgres: - image: postgres:12 - env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - POSTGRES_DB: ci_test - ports: - - 5432:5432 - options: --health-cmd=pg_isready --health-interval=10s --health-timeout=5s --health-retries=3 - - mysql: - image: mysql:5.7 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: true - MYSQL_USER: travis - MYSQL_PASSWORD: travis - MYSQL_DATABASE: ci_test - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Override PHP ini values for JIT compiler - if: matrix.compiler == 'jit' - run: echo "PHP_INI_VALUES::assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit=1255, opcache.jit_buffer_size=64M" >> $GITHUB_ENV - - - name: Install PHP${{ matrix.php }} - DB ${{ matrix.DB }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - tools: composer, pecl - extensions: imagick, sqlite3, pgsql, mysqli, pdo, pdo_mysql, pdo_pgsql, pdo_sqlite - ini-values: ${{ env.PHP_INI_VALUES }} - coverage: xdebug - - - name: Setup composer for PHP8.0+ - run: if [ '${{ matrix.php }}' = '8.0' ] || [ '${{ matrix.php }}' = '8.1' ] ; then sed -i 's/phpunit\/phpunit/sminnee\/phpunit/g' composer.json; composer config -g platform.php 7.4.11; fi - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - name: Cache composer dependencies - uses: actions/cache@v2 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- - - name: Install composer dependencies - run: composer install --no-progress --prefer-dist --optimize-autoloader - - - name: Fix error in vfsStream - run: sed -i s/name{0}/name[0]/ vendor/mikey179/vfsstream/src/main/php/org/bovigo/vfs/vfsStream.php - - - name: PHPUnit Test - run: | - 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/${{ matrix.DB }}.phpunit.xml - env: - XDEBUG_MODE: coverage diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..bf86bace1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,112 @@ +language: php +os: linux +dist: xenial + +php: + - 5.6 + - 7.0 + - 7.1 + - 7.2 + - 7.3 + - 7.4 + - nightly + +env: + global: + - XDEBUG_MODE=coverage + jobs: + - DB=mysqli + - DB=pgsql + - DB=sqlite + - DB=pdo/mysql + - DB=pdo/pgsql + - DB=pdo/sqlite + +services: + - mysql + - postgresql + +cache: + directories: + - $HOME/.composer/cache + +before_script: + - sh -c "composer install --no-progress" + - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" + - 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: 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: + - php: nightly + - php: hhvm-3.30 + include: + - php: 5.4 + dist: trusty + env: DB=mysql + - php: 5.4 + dist: trusty + env: DB=mysqli + - php: 5.4 + dist: trusty + env: DB=pgsql + - php: 5.4 + dist: trusty + env: DB=sqlite + - php: 5.4 + dist: trusty + env: DB=pdo/mysql + - php: 5.4 + dist: trusty + env: DB=pdo/pgsql + - php: 5.4 + dist: trusty + env: DB=pdo/sqlite + - php: 5.5 + dist: trusty + env: DB=mysql + - php: 5.5 + dist: trusty + env: DB=mysqli + - php: 5.5 + dist: trusty + env: DB=pgsql + - php: 5.5 + dist: trusty + env: DB=sqlite + - php: 5.5 + dist: trusty + env: DB=pdo/mysql + - php: 5.5 + dist: trusty + env: DB=pdo/pgsql + - php: 5.5 + dist: trusty + env: DB=pdo/sqlite + - php: 5.6 + dist: xenial + env: DB=mysql + - php: hhvm-3.30 + dist: trusty + env: DB=mysql + - php: hhvm-3.30 + dist: trusty + env: DB=mysqli + - php: hhvm-3.30 + dist: trusty + env: DB=sqlite + - php: hhvm-3.30 + dist: trusty + env: DB=pdo/mysql + - php: hhvm-3.30 + dist: trusty + env: DB=pdo/sqlite + +branches: + only: + - develop + - 3.0-stable + - 3.1-stable + - /^feature\/.+$/ diff --git a/composer.json b/composer.json index 722c9b7d9..3f423e17a 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,12 @@ "suggest": { "paragonie/random_compat": "Provides better randomness in PHP 5.x" }, + "scripts": { + "test:coverage": [ + "@putenv XDEBUG_MODE=coverage", + "phpunit --color=always --coverage-text --configuration tests/travis/sqlite.phpunit.xml" + ] + }, "require-dev": { "mikey179/vfsstream": "1.6.*", "phpunit/phpunit": "4.* || 5.* || 9.*" -- cgit v1.2.3-24-g4f1b