From 83feb62e6367bb5a6d6cb1bc28f3f88d3738c9bc Mon Sep 17 00:00:00 2001 From: Sabina Talipova <87288324+sabina-talipova@users.noreply.github.com> Date: Fri, 3 Mar 2023 10:50:02 +1300 Subject: [PATCH] ENH Add CMS5 compatibility and re-enable builds (#69) --- .github/workflows/ci.yml | 18 ++++++++++++++++++ _config.php | 1 - _config/config.yml | 0 code/SQLite3Database.php | 6 +++--- code/SQLite3Query.php | 22 +++++----------------- code/SQLite3SchemaManager.php | 4 ++-- composer.json | 3 ++- phpunit.xml.dist | 8 ++++++++ 8 files changed, 38 insertions(+), 24 deletions(-) delete mode 100644 _config.php create mode 100644 _config/config.yml create mode 100644 phpunit.xml.dist diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a148387..fa1e422 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,3 +14,21 @@ jobs: # Only run cron on the silverstripe account if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule') uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 + with: + # set phpunit to false to prevent automatic generation of mysql phpunit jobs + phpunit: false + preserve_vendor_tests: true + extra_jobs: | + - php: 8.1 + db: sqlite3 + composer_args: --prefer-lowest + phpunit: true + phpunit_suite: all + - php: 8.1 + db: sqlite3 + phpunit: true + phpunit_suite: all + - php: 8.2 + db: sqlite3 + phpunit: true + phpunit_suite: all diff --git a/_config.php b/_config.php deleted file mode 100644 index b3d9bbc..0000000 --- a/_config.php +++ /dev/null @@ -1 +0,0 @@ -handle->reset(); - $i=0; - while ($i <= $row && $result = @$this->handle->fetchArray(SQLITE3_ASSOC)) { - $i++; - } - return $result; - } - /** * @todo This looks terrible but there is no SQLite3::get_num_rows() implementation */ @@ -62,7 +53,7 @@ class SQLite3Query extends Query if (!$this->handle->numColumns()) { return 0; } - + $this->handle->reset(); $c=0; while ($this->handle->fetchArray()) { @@ -72,13 +63,10 @@ class SQLite3Query extends Query return $c; } - #[\ReturnTypeWillChange] - public function getIterator() + public function getIterator(): Traversable { - if ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) { - return $data; - } else { - return false; + while ($data = $this->handle->fetchArray(SQLITE3_ASSOC)) { + yield $data; } } } diff --git a/code/SQLite3SchemaManager.php b/code/SQLite3SchemaManager.php index e88f122..a0bffa0 100644 --- a/code/SQLite3SchemaManager.php +++ b/code/SQLite3SchemaManager.php @@ -692,7 +692,7 @@ class SQLite3SchemaManager extends DBSchemaManager return (bool)$this->preparedQuery( 'SELECT "name" FROM "sqlite_master" WHERE "type" = ? AND "name" = ?', array('table', $tableName) - )->first(); + )->record(); } /** @@ -715,7 +715,7 @@ class SQLite3SchemaManager extends DBSchemaManager $classnameinfo = $this->preparedQuery( "SELECT EnumList FROM SQLiteEnums WHERE TableColumn = ?", array($tablefield) - )->first(); + )->record(); if ($classnameinfo) { $valueList = $classnameinfo['EnumList']; $this->enum_map[$tablefield] = $valueList; diff --git a/composer.json b/composer.json index 614578b..124c45d 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,8 @@ "silverstripe/vendor-plugin": "^2" }, "require-dev": { - "squizlabs/php_codesniffer": "^3" + "squizlabs/php_codesniffer": "^3", + "phpunit/phpunit": "^9.5" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..85a26e9 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,8 @@ + + + + + vendor/silverstripe/framework/tests/php + + +