diff --git a/.gitignore b/.gitignore index a16e58b..6136663 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ build composer.lock vendor .idea +/tests/Performance/history.db diff --git a/.travis.yml b/.travis.yml index 79aa227..dc8faa0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ language: php php: - 7.0 - 7.1 + - hhvm + - nightly # This triggers builds to run on the new TravisCI infrastructure. # See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/ @@ -19,13 +21,59 @@ matrix: - php: 7.0 env: 'COMPOSER_FLAGS="--prefer-stable --prefer-lowest"' +env: + - DB=sqlite + - DB=mysql + - DB=postgres + +before_install: + - mv ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini{,.disabled} || echo "xdebug not available" + - composer self-update + before_script: - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-dist + - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS tests;' -U postgres; fi" + - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS tests_tmp;' -U postgres; fi" + - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'CREATE DATABASE tests;' -U postgres; fi" + - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'CREATE DATABASE tests_tmp;' -U postgres; fi" + - sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'CREATE DATABASE IF NOT EXISTS tests_tmp; CREATE DATABASE IF NOT EXISTS tests;'; fi" + - ENABLE_SECOND_LEVEL_CACHE=0 ./vendor/bin/phpunit -v -c tests/travis/$DB.travis.xml + - ENABLE_SECOND_LEVEL_CACHE=1 ./vendor/bin/phpunit -v -c tests/travis/$DB.travis.xml --exclude-group performance,non-cacheable,locking_functional script: - vendor/bin/phpcs --standard=psr2 src/ - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover +jobs: + include: + - stage: test + env: DB=mariadb + addons: + mariadb: 10.1 + + - stage: test + env: DB=mysql MYSQL_VERSION=5.7 + php: 7.1 + before_script: + - ./tests/travis/install-mysql-$MYSQL_VERSION.sh + sudo: required + + - stage: test + env: DB=mysql MYSQL_VERSION=5.7 + php: nightly + before_script: + - ./tests/travis/install-mysql-$MYSQL_VERSION.sh + sudo: required + + - stage: Benchmark + env: DB=none + before_script: wget https://phpbench.github.io/phpbench/phpbench.phar https://phpbench.github.io/phpbench/phpbench.phar.pubkey + script: php phpbench.phar run -l dots --report=default + + allow_failures: + - php: nightly + - php: hhvm + after_script: - | if [[ "$TRAVIS_PHP_VERSION" != 'hhvm' && "$TRAVIS_PHP_VERSION" != '7.0' ]]; then diff --git a/composer.json b/composer.json index 683dd90..f9ffce1 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,8 @@ }, "autoload-dev": { "psr-4": { - "League\\Database\\": "tests" + "League\\Database\\Tests\\": "tests/Tests", + "League\\Database\\Performance\\": "tests/Performance" } }, "scripts": { @@ -44,7 +45,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.2.x-dev" } }, "config": { diff --git a/phpbench.json b/phpbench.json new file mode 100644 index 0000000..e679f20 --- /dev/null +++ b/phpbench.json @@ -0,0 +1,15 @@ +{ + "bootstrap": "vendor/autoload.php", + "path": "tests/Performance", + + "extensions": [ + "PhpBench\\Extensions\\Dbal\\DbalExtension", + "PhpBench\\Extensions\\XDebug\\XDebugExtension" + ], + + "storage": "dbal", + "storage.dbal.connection": { + "driver": "pdo_sqlite", + "path": "tests/Performance/history.db" + } +} \ No newline at end of file diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 94d8494..2c58044 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,8 +10,8 @@ processIsolation="false" stopOnFailure="false"> - - tests + + tests/Tests diff --git a/tests/Performance/.gitkeep b/tests/Performance/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/Tests/ExampleTest.php b/tests/Tests/ExampleTest.php index 1b2794b..03831cc 100644 --- a/tests/Tests/ExampleTest.php +++ b/tests/Tests/ExampleTest.php @@ -1,6 +1,6 @@ + + + + + + + + + + + + + ./../Tests + + + + + ./../../src + + + + + performance + locking_functional + + + + diff --git a/tests/travis/mysql.travis.xml b/tests/travis/mysql.travis.xml new file mode 100644 index 0000000..7fc873e --- /dev/null +++ b/tests/travis/mysql.travis.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + ./../Tests + + + + + ./../../src + + + + + performance + locking_functional + + + + \ No newline at end of file diff --git a/tests/travis/pgsql.travis.xml b/tests/travis/pgsql.travis.xml new file mode 100644 index 0000000..72883e7 --- /dev/null +++ b/tests/travis/pgsql.travis.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + ./../Tests + + + + + ./../../src + + + + + performance + locking_functional + + + + \ No newline at end of file diff --git a/tests/travis/sqlite.travis.xml b/tests/travis/sqlite.travis.xml new file mode 100644 index 0000000..6cd3f84 --- /dev/null +++ b/tests/travis/sqlite.travis.xml @@ -0,0 +1,26 @@ + + + + + ./../Tests + + + + + ./../../src + + + + + performance + locking_functional + + + + \ No newline at end of file