diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..30faa7b --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,60 @@ +name: Continuous Integration + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + operating-system: + - ubuntu-latest + php-version: + - '5.4' + - '5.5' + - '5.6' + - '7.0' + - '7.1' + - '7.2' + - '7.3' + - '7.4' + - '8.0' + - '8.1' + steps: + - name: Checkout + uses: actions/checkout@v1 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: xdebug + tools: composer:2.2 + ini-values: assert.exception=1, zend.assertions=1 + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache 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 dependencies + run: composer install --no-interaction --prefer-dist + + - name: Run test suite + run: php -d xdebug.mode=coverage ./vendor/bin/phpunit --coverage-clover=coverage.xml + + - name: Upload coverage report + uses: codecov/codecov-action@v2 + with: + fail_ci_if_error: false \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7579f74..6c8342b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ -vendor -composer.lock +/composer.lock +/vendor +/.phpunit.result.cache +/.phpdoc diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 7c7c845..552f1f2 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,10 +1,8 @@ +build: + nodes: + analysis: + tests: + override: + - php-scrutinizer-run filter: paths: ["src/*"] -tools: - external_code_coverage: true - php_code_coverage: true - php_sim: true - php_mess_detector: true - php_pdepend: true - php_analyzer: true - php_cpd: true diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 06742be..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -sudo: false -language: php -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7 -before_script: - - composer self-update - - composer install -script: - - vendor/bin/phpunit --coverage-clover=coverage.clover -after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover diff --git a/README.md b/README.md index 3ef7779..5f3799e 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,18 @@ although [PDO](http://php.net/PDO) in general is recommended. This library requires PHP 5.3.9 or later; we recommend using the latest available version of PHP as a matter of principle. It has no userland dependencies. +> CI ( From year 2022 ) is only testing from 5.4 onwards. +> Because of the dependency on yoast/phpunit-polyfills which require php >=5.4. + It is installable and autoloadable via Composer as [aura/sqlquery](https://packagist.org/packages/aura/sqlquery). Alternatively, [download a release](https://github.com/auraphp/Aura.SqlQuery/releases) or clone this repository, then require or include its _autoload.php_ file. ### Quality -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/auraphp/Aura.SqlQuery/badges/quality-score.png?b=2.x)](https://scrutinizer-ci.com/g/auraphp/Aura.SqlQuery/?branch=2.x) -[![Code Coverage](https://scrutinizer-ci.com/g/auraphp/Aura.SqlQuery/badges/coverage.png?b=2.x)](https://scrutinizer-ci.com/g/auraphp/Aura.SqlQuery/?branch=2.x) -[![Build Status](https://travis-ci.org/auraphp/Aura.SqlQuery.png?branch=2.x)](https://travis-ci.org/auraphp/Aura.SqlQuery) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/auraphp/Aura.SqlQuery/badges/quality-score.png?b=2.x)](https://scrutinizer-ci.com/g/auraphp/Aura.SqlQuery/) +[![codecov](https://codecov.io/gh/auraphp/Aura.SqlQuery/branch/2.x/graph/badge.svg?token=UASDouLxyc)](https://codecov.io/gh/auraphp/Aura.SqlQuery) +[![Continuous Integration](https://github.com/auraphp/Aura.SqlQuery/actions/workflows/continuous-integration.yml/badge.svg?branch=2.x)](https://github.com/auraphp/Aura.SqlQuery/actions/workflows/continuous-integration.yml) To run the [PHPUnit](http://phpunit.de/manual/) unit tests at the command line, issue `composer install` and then `vendor/bin/phpunit` at the package root. (This requires [Composer](http://getcomposer.org/) to be available as `composer`.) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..69cb760 --- /dev/null +++ b/codecov.yml @@ -0,0 +1 @@ +comment: false diff --git a/composer.json b/composer.json index bd18e5b..39ec68c 100644 --- a/composer.json +++ b/composer.json @@ -32,14 +32,19 @@ "require": { "php": ">=5.3.9" }, - "require-dev": { - "phpunit/phpunit": "~5.7 || ~4.8" - }, "autoload": { "psr-4": { "Aura\\SqlQuery\\": "src/" } }, + "require-dev": { + "yoast/phpunit-polyfills": "~1.0" + }, + "autoload-dev": { + "psr-4": { + "Aura\\SqlQuery\\": "tests/" + } + }, "extra": { "aura": { "type": "library" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a43a7ac..ccc2242 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,13 @@ - - - - ./tests - - - - - ./src - - + + + + + ./src + + + + + ./tests + + diff --git a/tests/AbstractQueryTest.php b/tests/AbstractQueryTest.php index a7eee4c..7c0b5d4 100644 --- a/tests/AbstractQueryTest.php +++ b/tests/AbstractQueryTest.php @@ -1,7 +1,9 @@ query_factory = new QueryFactory($this->db_type); $this->query = $this->newQuery(); } @@ -54,9 +56,9 @@ protected function requoteIdentifiers($string) return $string; } - protected function tearDown() + protected function tear_down() { - parent::tearDown(); + parent::tear_down(); } public function testBindValues() diff --git a/tests/Common/InsertTest.php b/tests/Common/InsertTest.php index a51b9e7..5a6fda0 100644 --- a/tests/Common/InsertTest.php +++ b/tests/Common/InsertTest.php @@ -138,11 +138,8 @@ public function testBulkMissingCol() $this->query->cols(array('c2' => 'v2-1', 'c1' => 'v1-1')); // failed to add c3, should blow up + $this->expectException('Aura\SqlQuery\Exception'); - $this->setExpectedException( - 'Aura\SqlQuery\Exception', - $this->requoteIdentifiers("Column <> missing from row 1.") - ); $this->query->addRow(); } diff --git a/tests/Common/SelectTest.php b/tests/Common/SelectTest.php index 93df12f..a2d3560 100644 --- a/tests/Common/SelectTest.php +++ b/tests/Common/SelectTest.php @@ -10,7 +10,7 @@ class SelectTest extends AbstractQueryTest public function testExceptionWithNoCols() { $this->query->from('t1'); - $this->setExpectedException('Aura\SqlQuery\Exception'); + $this->expectException('Aura\SqlQuery\Exception'); $this->query->__toString(); } @@ -143,10 +143,9 @@ public function testDuplicateFromTable() $this->query->cols(array('*')); $this->query->from('t1'); - $this->setExpectedException( - 'Aura\SqlQuery\Exception', - "Cannot reference 'FROM t1' after 'FROM t1'" - ); + // "Cannot reference 'FROM t1' after 'FROM t1'" + $this->expectException('Aura\SqlQuery\Exception'); + $this->query->from('t1'); } @@ -156,10 +155,9 @@ public function testDuplicateFromAlias() $this->query->cols(array('*')); $this->query->from('t1'); - $this->setExpectedException( - 'Aura\SqlQuery\Exception', - "Cannot reference 'FROM t2 AS t1' after 'FROM t1'" - ); + // "Cannot reference 'FROM t2 AS t1' after 'FROM t1'" + $this->expectException('Aura\SqlQuery\Exception'); + $this->query->from('t2 AS t1'); } @@ -184,10 +182,8 @@ public function testDuplicateSubSelectTableRef() $this->query->cols(array('*')); $this->query->from('t1'); - $this->setExpectedException( - 'Aura\SqlQuery\Exception', - "Cannot reference 'FROM (SELECT ...) AS t1' after 'FROM t1'" - ); + // "Cannot reference 'FROM (SELECT ...) AS t1' after 'FROM t1'" + $this->expectException('Aura\SqlQuery\Exception'); $sub = 'SELECT * FROM t2'; $this->query->fromSubSelect($sub, 't1'); @@ -273,10 +269,8 @@ public function testDuplicateJoinRef() $this->query->cols(array('*')); $this->query->from('t1'); - $this->setExpectedException( - 'Aura\SqlQuery\Exception', - "Cannot reference 'NATURAL JOIN t1' after 'FROM t1'" - ); + // "Cannot reference 'NATURAL JOIN t1' after 'FROM t1'" + $this->expectException('Aura\SqlQuery\Exception'); $this->query->join('natural', 't1'); } @@ -401,10 +395,8 @@ public function testDuplicateJoinSubSelectRef() $this->query->cols(array('*')); $this->query->from('t1'); - $this->setExpectedException( - 'Aura\SqlQuery\Exception', - "Cannot reference 'NATURAL JOIN (SELECT ...) AS t1' after 'FROM t1'" - ); + // "Cannot reference 'NATURAL JOIN (SELECT ...) AS t1' after 'FROM t1'" + $this->expectException('Aura\SqlQuery\Exception'); $sub2 = 'SELECT * FROM t3'; $this->query->joinSubSelect('natural', $sub2, 't1'); diff --git a/tests/QueryFactoryTest.php b/tests/QueryFactoryTest.php index a5ca3cb..9f75969 100644 --- a/tests/QueryFactoryTest.php +++ b/tests/QueryFactoryTest.php @@ -1,7 +1,9 @@ quoter = new Quoter('`', '`');