Skip to content

Commit

Permalink
Merge pull request #203 from harikt/ci
Browse files Browse the repository at this point in the history
update ci
  • Loading branch information
harikt authored May 21, 2022
2 parents 84a6187 + eb2103c commit 3cadc8b
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 76 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor
composer.lock
/composer.lock
/vendor
/.phpunit.result.cache
/.phpdoc
14 changes: 6 additions & 8 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 0 additions & 16 deletions .travis.yml

This file was deleted.

9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.)

Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment: false
11 changes: 8 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
23 changes: 12 additions & 11 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<phpunit bootstrap="./phpunit.php">
<testsuites>
<testsuite>
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./phpunit.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Aura.SqlQuery test suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
</phpunit>
12 changes: 7 additions & 5 deletions tests/AbstractQueryTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace Aura\SqlQuery;

abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

abstract class AbstractQueryTest extends TestCase
{
protected $query_factory;

Expand All @@ -11,9 +13,9 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase

protected $query;

protected function setUp()
protected function set_up()
{
parent::setUp();
parent::set_up();
$this->query_factory = new QueryFactory($this->db_type);
$this->query = $this->newQuery();
}
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 1 addition & 4 deletions tests/Common/InsertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<c3>> missing from row 1.")
);
$this->query->addRow();
}

Expand Down
34 changes: 13 additions & 21 deletions tests/Common/SelectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

}
Expand Down Expand Up @@ -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');
}

Expand All @@ -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');
}

Expand All @@ -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');
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion tests/QueryFactoryTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace Aura\SqlQuery;

class QueryFactoryTest extends \PHPUnit_Framework_TestCase
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

class QueryFactoryTest extends TestCase
{
/**
* @dataProvider provider
Expand Down
6 changes: 4 additions & 2 deletions tests/QuoterTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php
namespace Aura\SqlQuery;

class QuoterTest extends \PHPUnit_Framework_TestCase
use Yoast\PHPUnitPolyfills\TestCases\TestCase;

class QuoterTest extends TestCase
{
public function setUp()
protected function set_up()
{
// use double-quotes for identifier quoting
$this->quoter = new Quoter('`', '`');
Expand Down

0 comments on commit 3cadc8b

Please sign in to comment.