From d116a4ef491087339a781b042599c65a9ebd9d71 Mon Sep 17 00:00:00 2001 From: Alessandro Galli Date: Fri, 3 Jun 2016 20:53:09 +0200 Subject: [PATCH] added travis configuration, phpunit testsuite, refactored composer.json --- .gitignore | 1 + .travis.yml | 69 ++++++++++++++++++++++++++++++++++++ composer.json | 15 +++++--- phpunit.xml | 28 +++++++++++++++ tests/unit/StatementTest.php | 21 +++++++++++ 5 files changed, 130 insertions(+), 4 deletions(-) create mode 100644 .travis.yml create mode 100644 phpunit.xml create mode 100644 tests/unit/StatementTest.php diff --git a/.gitignore b/.gitignore index d735770..ce558c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea vendor +bin composer.phar composer.lock diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..4bdb870 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,69 @@ +language: php + +php: + - 5.4 + - 5.5 + - 5.6 + - 7.0 + - hhvm + +matrix: + fast_finish: true + include: + - php: '5.4' + env: COMPOSER_FLAGS="--prefer-lowest" + - php: '5.4' + env: SYMFONY=2.8.* + + - php: '5.5' + env: COMPOSER_FLAGS="--prefer-lowest" + - php: '5.5' + env: SYMFONY=2.8.* + - php: '5.5' + env: SYMFONY=3.0.* + + - php: '5.6' + env: COMPOSER_FLAGS="--prefer-lowest" + - php: '5.6' + env: SYMFONY=2.8.* + - php: '5.6' + env: SYMFONY=3.0.* + - php: '5.6' + env: SYMFONY=3.1.* + + - php: '7.0' + env: COMPOSER_FLAGS="--prefer-lowest" + - php: '7.0' + env: SYMFONY=2.8.* + - php: '7.0' + env: SYMFONY=3.0.* + - php: '7.0' + env: SYMFONY=3.1.* + - php: '7.0' + env: SYMFONY=dev-master + + allow_failures: + - env: SYMFONY=3.1.* + - env: SYMFONY=dev-master + +cache: + directories: + - $HOME/.composer/cache/files + +before_install: + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi; + - composer self-update + - if [ "$SYMFONY" != "" ]; then composer require "symfony/symfony:${SYMFONY}" --no-update; fi; + +install: + - composer update --prefer-dist --no-interaction ${COMPOSER_FLAGS} + +before_script: + - if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "zend_extension=xdebug.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi; + +script: + - bin/phpunit + +notifications: + on_success: never + on_failure: always diff --git a/composer.json b/composer.json index ae74110..5cf2ecf 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,6 @@ "name": "facile-it/doctrine-mysql-come-back", "description": "Auto reconnect on Doctrine MySql has gone away exceptions on doctrine/dbal", "keywords": ["mysql","doctrine","reconnect","refresh","connection","has gone away","exception"], - "require": { - "php" : ">=5.4", - "doctrine/dbal": ">=2.3,<2.6-dev" - }, "license": "Apache License Version 2.0", "authors": [ { @@ -13,8 +9,19 @@ "email": "luca.boeri@facile.it" } ], + "require": { + "php" : ">=5.4", + "doctrine/dbal": ">=2.3,<2.6-dev" + }, + "require-dev": { + "phpunit/phpunit": "^4.8" + }, "autoload": { "psr-4": { "Facile\\DoctrineMySQLComeBack\\Doctrine\\DBAL\\": "src/" } }, + "config": { + "preferred-install": "dist", + "bin-dir": "bin" + }, "minimum-stability": "stable" } diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..ff278f0 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,28 @@ + + + + + + + + + + ./tests/ + + + + + + ./src/ + + ./tests + ./vendor + + + + \ No newline at end of file diff --git a/tests/unit/StatementTest.php b/tests/unit/StatementTest.php new file mode 100644 index 0000000..6f8a41d --- /dev/null +++ b/tests/unit/StatementTest.php @@ -0,0 +1,21 @@ +prophesize('Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Connection'); + $connection + ->prepareUnwrapped($sql) + ->shouldBeCalledTimes(1); + + $statement = new Statement($sql, $connection->reveal()); + + $this->assertInstanceOf('Facile\DoctrineMySQLComeBack\Doctrine\DBAL\Statement', $statement); + } + +}