Skip to content

Commit

Permalink
Support PHP 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Jan 14, 2022
1 parent c740b62 commit 18b0e01
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 46 deletions.
51 changes: 21 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
/.idea
/.vagrant
/vendor
.phpunit.result.cache
after.sh
aliases
composer.lock
Homestead.yaml
Vagrantfile
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 4 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
7 changes: 6 additions & 1 deletion tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', []);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/config/database.ci.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => '127.0.0.1',
'port' => '1433',
'port' => getenv('SQLSRV_PORT'),
'database' => 'test',
'username' => 'sa',
'password' => 'Password!',
Expand Down
6 changes: 3 additions & 3 deletions tests/config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '3306',
'database' => 'homestead',
'database' => 'laravel-upsert',
'username' => 'homestead',
'password' => 'secret',
'unix_socket' => '',
Expand All @@ -19,7 +19,7 @@
'driver' => 'pgsql',
'host' => '127.0.0.1',
'port' => '5432',
'database' => 'homestead',
'database' => 'laravel-upsert',
'username' => 'homestead',
'password' => 'secret',
'charset' => 'utf8',
Expand All @@ -36,7 +36,7 @@
'driver' => 'sqlsrv',
'host' => '127.0.0.1',
'port' => '1433',
'database' => 'homestead',
'database' => 'laravel-upsert',
'username' => 'sa',
'password' => 'Password!',
'charset' => 'utf8',
Expand Down

0 comments on commit 18b0e01

Please sign in to comment.