From 18b0e0139e5784bbb915febb4e1a7f1f08cc95ba Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Fri, 14 Jan 2022 17:55:06 +0100 Subject: [PATCH] Support PHP 8.0 --- .github/workflows/ci.yml | 51 +++++++++++++++--------------------- .gitignore | 5 ---- composer.json | 3 +-- phpunit.xml.dist | 8 +++--- tests/QueryTest.php | 7 ++++- tests/config/database.ci.php | 2 +- tests/config/database.php | 6 ++--- 7 files changed, 36 insertions(+), 46 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 54ed936..192f21b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,17 +5,17 @@ on: [push, pull_request] jobs: tests: runs-on: ubuntu-latest - + strategy: matrix: - php: [7.4, 7.3, 7.2] + php: [8.0, 7.4, 7.3, 7.2] database: [mysql, pgsql, sqlite, sqlsrv] release: [stable, lowest] - include: + include: - php: 7.4 - release: stable + release: stable coverage: xdebug - + services: mysql: image: mysql:5.7 @@ -32,40 +32,30 @@ jobs: POSTGRES_DB: test ports: - 5432/tcp + sqlsrv: + image: mcr.microsoft.com/mssql/server:2019-latest + env: + ACCEPT_EULA: Y + SA_PASSWORD: Password! + options: >- + --name sqlsrv + --health-cmd "echo quit | /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -l 1 -U sa -P Password!" + ports: + - 1433 steps: - - uses: actions/checkout@v1 - - uses: actions/cache@v1 + - uses: actions/checkout@v2 + - uses: actions/cache@v2 with: - path: ~/.composer/cache/files + path: ~/.cache/composer/files key: php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} - - uses: shivammathur/setup-php@v1 + - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} tools: pecl extensions: bcmath, ctype, json, mbstring, openssl, pdo, pdo_${{ matrix.database }}, tokenizer, xml coverage: ${{ matrix.coverage }} - - run: | - PHP_API=$(php -i | sed -n 's/PHP API => //p') - SQLITE=$(wget -qO- https://github.com/staudenmeir/php-sqlite/raw/master/LATEST) - sudo wget -q https://github.com/staudenmeir/php-sqlite/raw/master/$SQLITE/libsqlite3.so -O /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6 - sudo ln -s /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6 /usr/lib/x86_64-linux-gnu/libsqlite3.so - sudo wget -q https://github.com/staudenmeir/php-sqlite/raw/master/$SQLITE/${{ matrix.php }}/pdo_sqlite.so -O /usr/lib/php/$PHP_API/pdo_sqlite.so - if: matrix.database == 'sqlite' - - run: | - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server-2017.list | sudo tee /etc/apt/sources.list.d/mssql-server-2017.list - sudo apt-get update - sudo apt-get install mssql-server=14.0.3192.2-2 - sudo MSSQL_SA_PASSWORD=Password! MSSQL_PID=developer /opt/mssql/bin/mssql-conf -n setup accept-eula - curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - - curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install mssql-tools unixodbc-dev - sudo /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Password! -Q "create database [test]" - sudo pecl install pdo_sqlsrv-5.7.1preview - echo 'extension=pdo_sqlsrv.so' | sudo tee /etc/php/${{ matrix.php }}/cli/conf.d/20-pdo_sqlsrv.ini - sudo sed -i 's/extension="pdo_sqlsrv.so"//' /etc/php/${{ matrix.php }}/cli/php.ini + - run: docker exec sqlsrv /opt/mssql-tools/bin/sqlcmd -S 127.0.0.1 -U sa -P Password! -Q "create database [test]" if: matrix.database == 'sqlsrv' - run: composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-${{ matrix.release }} - run: cp tests/config/database.ci.php tests/config/database.php @@ -76,6 +66,7 @@ jobs: DATABASE: ${{ matrix.database }} MYSQL_PORT: ${{ job.services.mysql.ports[3306] }} PGSQL_PORT: ${{ job.services.pgsql.ports[5432] }} + SQLSRV_PORT: ${{ job.services.sqlsrv.ports[1433] }} - run: | wget -q https://scrutinizer-ci.com/ocular.phar php ocular.phar code-coverage:upload --format=php-clover coverage.xml diff --git a/.gitignore b/.gitignore index c2c86e2..7a55713 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,4 @@ /.idea -/.vagrant /vendor .phpunit.result.cache -after.sh -aliases composer.lock -Homestead.yaml -Vagrantfile diff --git a/composer.json b/composer.json index 72696c7..b029332 100644 --- a/composer.json +++ b/composer.json @@ -9,11 +9,10 @@ } ], "require": { - "php": "^7.2", + "php": "^7.2|^8.0", "illuminate/database": "^6.0" }, "require-dev": { - "laravel/homestead": "^10.0", "orchestra/testbench": "^4.0" }, "autoload": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 3b62f71..4b25fc7 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -15,9 +15,9 @@ ./tests - - + + ./src - - + + diff --git a/tests/QueryTest.php b/tests/QueryTest.php index 96d39a6..a44c011 100644 --- a/tests/QueryTest.php +++ b/tests/QueryTest.php @@ -50,7 +50,12 @@ public function testUpsertWithoutColumns() public function testUpsertWithEmptyColumns() { $this->expectException(QueryException::class); - $this->expectExceptionMessageRegExp('/unique/i'); + + if (method_exists($this, 'expectExceptionMessageMatches')) { + $this->expectExceptionMessageMatches('/unique/i'); + } else { + $this->expectExceptionMessageRegExp('/unique/i'); + } DB::table('users')->upsert(['name' => 'foo', 'active' => true], 'name', []); } diff --git a/tests/config/database.ci.php b/tests/config/database.ci.php index f5920b0..db68fb3 100644 --- a/tests/config/database.ci.php +++ b/tests/config/database.ci.php @@ -35,7 +35,7 @@ 'sqlsrv' => [ 'driver' => 'sqlsrv', 'host' => '127.0.0.1', - 'port' => '1433', + 'port' => getenv('SQLSRV_PORT'), 'database' => 'test', 'username' => 'sa', 'password' => 'Password!', diff --git a/tests/config/database.php b/tests/config/database.php index c1bc454..0203d3d 100644 --- a/tests/config/database.php +++ b/tests/config/database.php @@ -5,7 +5,7 @@ 'driver' => 'mysql', 'host' => '127.0.0.1', 'port' => '3306', - 'database' => 'homestead', + 'database' => 'laravel-upsert', 'username' => 'homestead', 'password' => 'secret', 'unix_socket' => '', @@ -19,7 +19,7 @@ 'driver' => 'pgsql', 'host' => '127.0.0.1', 'port' => '5432', - 'database' => 'homestead', + 'database' => 'laravel-upsert', 'username' => 'homestead', 'password' => 'secret', 'charset' => 'utf8', @@ -36,7 +36,7 @@ 'driver' => 'sqlsrv', 'host' => '127.0.0.1', 'port' => '1433', - 'database' => 'homestead', + 'database' => 'laravel-upsert', 'username' => 'sa', 'password' => 'Password!', 'charset' => 'utf8',