Skip to content

Commit

Permalink
Merge pull request #40 from facile-it/functional-tests-and-dbal2.11-fix
Browse files Browse the repository at this point in the history
Fix for DBAL 2.11 and functional tests
  • Loading branch information
Jean85 authored Oct 30, 2020
2 parents f9ac163 + 07326c1 commit 3ea342c
Show file tree
Hide file tree
Showing 25 changed files with 505 additions and 147 deletions.
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/composer.lock export-ignore
/tests export-ignore
/ci export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/docker-compose.yml export-ignore
/Dockerfile export-ignore
/phpunit.xml.dist export-ignore
108 changes: 108 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: "Continuous Integration"

on:
pull_request:
branches:
- "*.x"
- "master"
push:
branches:
- "*.x"
- "master"
schedule:
- cron: "42 3 * * 1"

jobs:
phpunit-mysql:
name: "PHPUnit with MySQL"
runs-on: "ubuntu-20.04"

strategy:
matrix:
php-version:
- "7.3"
- "7.4"
mysql-version:
- "5.7"
- "8.0"
deps:
- "latest"
coverage:
- "false"
extension:
- "mysqli"
- "pdo_mysql"
include:
- php-version: "7.3"
mysql-version: "8.0"
extension: "mysqli"
custom-entrypoint: >-
--entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
- php-version: "7.3"
mysql-version: "8.0"
extension: "pdo_mysql"
custom-entrypoint: >-
--entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
- mysql-version: "5.7"
- mysql-version: "8.0"
# https://stackoverflow.com/questions/60902904/how-to-pass-mysql-native-password-to-mysql-service-in-github-actions
custom-entrypoint: >-
--entrypoint sh mysql:8 -c "exec docker-entrypoint.sh mysqld --default-authentication-plugin=mysql_native_password"
- deps: "lowest"
php-version: "7.3"
mysql-version: "5.7"
extension: "pdo_mysql"
coverage: "true"

services:
mysql:
image: "mysql:${{ matrix.mysql-version }}"

options: >-
--health-cmd "mysqladmin ping --silent"
-e MYSQL_ALLOW_EMPTY_PASSWORD=yes
-e MYSQL_DATABASE=test
${{ matrix.custom-entrypoint }}
ports:
- "3306:3306"

steps:
- name: "Checkout"
uses: "actions/checkout@v2"
with:
fetch-depth: 2

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
ini-values: "zend.assertions=1"
extensions: "${{ matrix.extension }}"

- name: "Cache dependencies installed with composer"
uses: "actions/cache@v2"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"

- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest --prefer-dist"
if: "${{ matrix.deps != 'low' }}"

- name: "Install lowest possible dependencies with composer"
run: "composer update --no-interaction --no-progress --no-suggest --prefer-dist --prefer-lowest"
if: "${{ matrix.deps == 'low' }}"

- name: "Run PHPUnit"
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml"
if: "${{ matrix.coverage != 'true' }}"

- name: "Run PHPUnit with coverage"
run: "vendor/bin/phpunit -c ci/github/phpunit/${{ matrix.extension }}.xml --coverage-clover=coverage.xml"
if: "${{ matrix.coverage == 'true' }}"

- name: "Upload coverage"
run: "wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover ./coverage.xml"
if: "${{ matrix.coverage == 'true' }}"
11 changes: 5 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.idea
vendor
bin
composer.phar
composer.lock
phpunit.xml
/vendor
/composer.phar
/composer.lock
/phpunit.xml
/.phpunit.result.cache
40 changes: 0 additions & 40 deletions .travis.yml

This file was deleted.

11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.9.0] - TBD
### Added
* Added compatibility with doctrine/dbal 2.11
* Added Github Actions for CI
### Changed
* Bumped minimum PHP version to 7.3
* Updated dependencies
* Added functional tests
### Fixed
* Fixed compatiblity with doctrine/dbal 2.11

## [1.8] - 2019-09-05
### Fixed
* Fixed issue about loss of state for Statement class on retry (#34)
Expand Down
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ARG PHP_VERSION=7.4
FROM php:${PHP_VERSION}-cli-alpine

RUN docker-php-ext-install -j$(getconf _NPROCESSORS_ONLN) \
pdo_mysql \
mysqli

RUN set -ex \
&& apk add --no-cache --virtual build-dependencies \
autoconf \
make \
g++ \
&& pecl install -o xdebug-2.9.8 && docker-php-ext-enable xdebug \
&& apk del build-dependencies

ARG COMPOSER_VERSION=2.0.3
RUN curl -sS https://getcomposer.org/installer | php -- \
--install-dir=/usr/local/bin --filename=composer --version=$COMPOSER_VERSION
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Latest Unstable Version](https://poser.pugx.org/facile-it/doctrine-mysql-come-back/v/unstable.svg)](https://packagist.org/packages/facile-it/doctrine-mysql-come-back)
[![Total Downloads](https://poser.pugx.org/facile-it/doctrine-mysql-come-back/downloads.svg)](https://packagist.org/packages/facile-it/doctrine-mysql-come-back)

[![Build status](https://travis-ci.org/facile-it/doctrine-mysql-come-back.svg)]( https://travis-ci.org/facile-it/doctrine-mysql-come-back)
[![Build status](https://github.com/facile-it/doctrine-mysql-come-back/workflows/Continuous%20Integration/badge.svg)]( https://github.com/facile-it/doctrine-mysql-come-back/actions?query=workflow%3A%22Continuous+Integration%22+branch%3Amaster)
[![Scrutinizer score](https://scrutinizer-ci.com/g/facile-it/doctrine-mysql-come-back/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/facile-it/doctrine-mysql-come-back/?branch=master)
[![Test coverage](https://scrutinizer-ci.com/g/facile-it/doctrine-mysql-come-back/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/facile-it/doctrine-mysql-come-back/?branch=master)

Expand Down
32 changes: 32 additions & 0 deletions ci/github/phpunit/mysqli.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="../../../vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
<var name="db_driver" value="mysqli" />
<var name="db_host" value="127.0.0.1" />
<var name="db_port" value="3306"/>
<var name="db_user" value="root" />
<var name="db_pass" value="" />
<var name="db_dbname" value="test" />
</php>

<testsuites>
<testsuite name="doctrine-mysql-come-back Test Suite">
<directory>../../../tests/</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">../../../src</directory>
</include>
</coverage>
</phpunit>
32 changes: 32 additions & 0 deletions ci/github/phpunit/pdo_mysql.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="../../../vendor/autoload.php"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
<php>
<ini name="error_reporting" value="-1" />
<var name="db_driver" value="pdo_mysql" />
<var name="db_host" value="127.0.0.1" />
<var name="db_port" value="3306"/>
<var name="db_user" value="root" />
<var name="db_pass" value="" />
<var name="db_dbname" value="test" />
</php>

<testsuites>
<testsuite name="doctrine-mysql-come-back Test Suite">
<directory>../../../tests/</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">../../../src</directory>
</include>
</coverage>
</phpunit>
18 changes: 11 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,29 @@
}
],
"require": {
"php" : "^5.6 || ^7.0",
"doctrine/dbal": "^2.3"
"php" : "^7.3",
"doctrine/dbal": "^2.11"
},
"require-dev": {
"phpunit/phpunit": "^5.4.3 || ^6.0",
"friendsofphp/php-cs-fixer": "^2.3"
"phpunit/phpunit": "^9.4",
"friendsofphp/php-cs-fixer": "^2.12.17",
"phpspec/prophecy-phpunit": "^2.0"
},
"autoload": {
"psr-4": { "Facile\\DoctrineMySQLComeBack\\Doctrine\\DBAL\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Facile\\DoctrineMySQLComeBack\\Doctrine\\DBAL\\": "tests/unit/" }
"psr-4": {
"Facile\\DoctrineMySQLComeBack\\Doctrine\\DBAL\\FunctionalTest\\": "tests/functional/",
"Facile\\DoctrineMySQLComeBack\\Doctrine\\DBAL\\": "tests/unit/"
}
},
"config": {
"preferred-install": "dist",
"bin-dir": "bin"
"preferred-install": "dist"
},
"minimum-stability": "stable",
"scripts": {
"test": "phpunit",
"phpcs": "php-cs-fixer fix --level=psr2 -v --diff --dry-run src/",
"phpcs-fix": "php-cs-fixer fix --level=psr2 -v --diff src/"
}
Expand Down
44 changes: 44 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: "3.5"

x-mysql-props: &mysql-props
environment:
MYSQL_DATABASE: test
MYSQL_USER: root
MYSQL_PASSWORD: ""
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"

x-php-props: &php-props
build:
context: .
args:
PHP_VERSION: 7.3
volumes:
- ./:/app
working_dir: /app
command: [ "vendor/bin/phpunit" ]
environment:
MYSQL_DATABASE: test
MYSQL_USER: root
MYSQL_PASS: ""

services:
mysql57:
image: mysql:5.7
<<: *mysql-props

mysql80:
image: mysql:8.0
<<: *mysql-props

php:
<<: *php-props
build:
context: .
args:
PHP_VERSION: 7.3
depends_on:
- mysql57
environment:
MYSQL_HOST: mysql57
MYSQL_DRIVER: pdo_mysql
Loading

0 comments on commit 3ea342c

Please sign in to comment.