Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] PLD-2 Applying tests #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build
composer.lock
vendor
.idea
/tests/Performance/history.db
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
},
"autoload-dev": {
"psr-4": {
"League\\Database\\": "tests"
"League\\Database\\Tests\\": "tests/Tests",
"League\\Database\\Performance\\": "tests/Performance"
}
},
"scripts": {
Expand All @@ -44,7 +45,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.2.x-dev"
}
},
"config": {
Expand Down
15 changes: 15 additions & 0 deletions phpbench.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="thephpleague Test Suite">
<directory>tests</directory>
<testsuite name="Database Test Suite">
<directory>tests/Tests</directory>
</testsuite>
</testsuites>
<filter>
Expand Down
Empty file added tests/Performance/.gitkeep
Empty file.
2 changes: 1 addition & 1 deletion tests/Tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace League\Database;
namespace League\Database\Tests;

use PHPUnit\Framework\TestCase;

Expand Down
Empty file added tests/bootstrap.php
Empty file.
21 changes: 21 additions & 0 deletions tests/travis/install-mysql-5.7.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -ex

echo "Installing MySQL 5.7..."

sudo service mysql stop
sudo apt-get remove "^mysql.*"
sudo apt-get autoremove
sudo apt-get autoclean
echo mysql-apt-config mysql-apt-config/select-server select mysql-5.7 | sudo debconf-set-selections
wget http://dev.mysql.com/get/mysql-apt-config_0.8.6-1_all.deb
sudo DEBIAN_FRONTEND=noninteractive dpkg -i mysql-apt-config_0.8.6-1_all.deb
sudo rm -rf /var/lib/apt/lists/*
sudo apt-get clean
sudo apt-get update -q
sudo apt-get install -q -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" mysql-server libmysqlclient-dev
sudo mysql_upgrade

echo "Restart mysql..."
sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;"
35 changes: 35 additions & 0 deletions tests/travis/mariadb.travis.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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"
verbose="true"
failOnRisky="true"
bootstrap="../bootstrap.php"
>
<php>
<env name="TYPE" value="mysql"/>
<env name="HOST" value="localhost" />
<env name="USERNAME" value="travis" />
<env name="PASSWORD" value="" />
<env name="DB_NAME" value="tests" />
<env name="DB_PORT" value="3306"/>
</php>

<testsuites>
<testsuite name="Database Test Suite">
<directory>./../Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./../../src</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>

</phpunit>
35 changes: 35 additions & 0 deletions tests/travis/mysql.travis.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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"
verbose="true"
failOnRisky="true"
bootstrap="../bootstrap.php"
>
<php>
<env name="TYPE" value="mysql"/>
<env name="HOST" value="localhost" />
<env name="USERNAME" value="travis" />
<env name="PASSWORD" value="" />
<env name="DB_NAME" value="tests" />
<env name="DB_PORT" value="3306"/>
</php>

<testsuites>
<testsuite name="Database Test Suite">
<directory>./../Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./../../src</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>

</phpunit>
35 changes: 35 additions & 0 deletions tests/travis/pgsql.travis.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?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"
verbose="true"
failOnRisky="true"
bootstrap="../bootstrap.php"
>
<php>
<env name="TYPE" value="pgsql"/>
<env name="HOST" value="localhost" />
<env name="USERNAME" value="postgres" />
<env name="PASSWORD" value="" />
<env name="DB_NAME" value="tests" />
<env name="DB_PORT" value="5432"/>
</php>

<testsuites>
<testsuite name="Database Test Suite">
<directory>./../Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./../../src</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>

</phpunit>
26 changes: 26 additions & 0 deletions tests/travis/sqlite.travis.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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"
verbose="true"
failOnRisky="true"
bootstrap="../bootstrap.php"
>
<testsuites>
<testsuite name="Database Test Suite">
<directory>./../Tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./../../src</directory>
</whitelist>
</filter>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>

</phpunit>