Improved TravisCI build settings

This commit is contained in:
Dmitry Khomutov 2017-02-18 10:31:33 +07:00
parent 9f8a5df810
commit 9f0580e802
No known key found for this signature in database
GPG Key ID: 7EB36C9576F9ECB9
8 changed files with 104 additions and 13 deletions

View File

@ -10,7 +10,7 @@ setup:
test:
php_unit:
config:
- phpunit.xml
- phpunit.mysql.xml
coverage: coverage
php_mess_detector:

View File

@ -1,5 +1,11 @@
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache
php:
- 5.6
- 7.0
@ -8,12 +14,20 @@ php:
matrix:
fast_finish: true
env:
- TYPE=mysql
- TYPE=pgsql
install:
- composer selfupdate
- composer install
before_script:
- if [[ "$TYPE" == "mysql" ]]; then mysql -e "create database IF NOT EXISTS b8_test;" -uroot; fi
- if [[ "$TYPE" == "pgsql" ]]; then psql -c 'create database b8_test;' -U postgres; fi
script:
- ./vendor/bin/phpunit
- vendor/bin/phpunit --configuration phpunit.$TYPE.xml --coverage-text
notifications:
email:

View File

@ -191,13 +191,19 @@ Tests
```bash
cd /path/to/php-censor
./vendor/bin/phpunit
# For testing on MySQL DB
./vendor/bin/phpunit --configuration ./phpunit.mysql.xml
# For testing on PostgreSQL
./vendor/bin/phpunit --configuration ./phpunit.pgsql.xml
```
For Phar plugin tests set 'phar.readonly' setting to Off (0) in `php.ini` config. Otherwise tests will be skipped.
For Phar plugin tests set 'phar.readonly' setting to Off (0) in `php.ini` config. Otherwise tests will be skipped.
For database B8Framework tests create empty 'b8_test' database on 'localhost' with user/password: `root/root`.
Otherwise database tests will be skipped.
For database B8Framework tests create empty 'b8_test' database on 'localhost' with user/password: `root/<empty>'`
for MySQL and with user/password: `postgres/<empty>'` for PostgreSQL (You can change default test user, password and
database name in `phpunit.mysql|pgsql.xml` config). If connection failed tests will be skipped.
Documentation
-------------

View File

@ -11,6 +11,12 @@
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
<env name="DB_TYPE" value="mysql" />
<env name="DB_USER" value="root" />
<env name="DB_PASS" value="" />
<env name="DB_NAME" value="b8_test" />
</php>
<testsuites>
<testsuite name="B8Framework Test Suite">
<directory suffix="Test.php">./tests/B8Framework</directory>

58
phpunit.pgsql.xml Normal file
View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./tests/bootstrap.php"
>
<php>
<env name="DB_TYPE" value="pgsql" />
<env name="DB_USER" value="postgres" />
<env name="DB_PASS" value="" />
<env name="DB_NAME" value="b8_test" />
</php>
<testsuites>
<testsuite name="B8Framework Test Suite">
<directory suffix="Test.php">./tests/B8Framework</directory>
</testsuite>
<testsuite name="PHP Censor Helper Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/Helper</directory>
</testsuite>
<testsuite name="PHP Censor Controller Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/Controller</directory>
</testsuite>
<testsuite name="PHP Censor Logging Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/Logging</directory>
</testsuite>
<testsuite name="PHP Censor Model Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/Model</directory>
</testsuite>
<testsuite name="PHP Censor Plugin Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/Plugin</directory>
</testsuite>
<testsuite name="PHP Censor Service Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/Service</directory>
</testsuite>
<testsuite name="PHP Censor Command Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/Command</directory>
</testsuite>
<testsuite name="PHP Censor ProcessControl Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/ProcessControl</directory>
</testsuite>
<testsuite name="PHP Censor Security Test Suite">
<directory suffix="Test.php">./tests/PHPCensor/Security</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>

View File

@ -257,6 +257,8 @@ class PhpUnitOptions
{
$files = [
'phpunit.xml',
'phpunit.mysql.xml',
'phpunit.pgsql.xml',
'phpunit.xml.dist',
'tests/phpunit.xml',
'tests/phpunit.xml.dist',

View File

@ -20,10 +20,10 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
['host' => 'localhost'],
],
],
'type' => 'mysql',
'name' => 'b8_test',
'username' => 'root',
'password' => 'root',
'type' => DB_TYPE,
'name' => DB_NAME,
'username' => DB_USER,
'password' => DB_PASS,
],
],
]);
@ -56,9 +56,9 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
$details = Database::getConnection('read')->getDetails();
$this->assertTrue(is_array($details));
$this->assertTrue(($details['db'] == 'b8_test'));
$this->assertTrue(($details['user'] == 'root'));
$this->assertTrue(($details['pass'] == 'root'));
$this->assertTrue(($details['db'] == DB_NAME));
$this->assertTrue(($details['user'] == DB_USER));
$this->assertTrue(($details['pass'] == DB_PASS));
}
/**

View File

@ -51,3 +51,8 @@ if (!defined('APP_URL') && !empty($config)) {
}
\PHPCensor\Helper\Lang::init($config, 'en');
define('DB_NAME', getenv('DB_NAME'));
define('DB_USER', getenv('DB_USER'));
define('DB_TYPE', getenv('DB_TYPE'));
define('DB_PASS', getenv('DB_PASS'));