Improved TravisCI build settings
This commit is contained in:
parent
9f8a5df810
commit
9f0580e802
|
@ -10,7 +10,7 @@ setup:
|
||||||
test:
|
test:
|
||||||
php_unit:
|
php_unit:
|
||||||
config:
|
config:
|
||||||
- phpunit.xml
|
- phpunit.mysql.xml
|
||||||
coverage: coverage
|
coverage: coverage
|
||||||
|
|
||||||
php_mess_detector:
|
php_mess_detector:
|
||||||
|
|
16
.travis.yml
16
.travis.yml
|
@ -1,5 +1,11 @@
|
||||||
language: php
|
language: php
|
||||||
|
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- $HOME/.composer/cache
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.6
|
- 5.6
|
||||||
- 7.0
|
- 7.0
|
||||||
|
@ -8,12 +14,20 @@ php:
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
||||||
|
env:
|
||||||
|
- TYPE=mysql
|
||||||
|
- TYPE=pgsql
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- composer selfupdate
|
- composer selfupdate
|
||||||
- composer install
|
- 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:
|
script:
|
||||||
- ./vendor/bin/phpunit
|
- vendor/bin/phpunit --configuration phpunit.$TYPE.xml --coverage-text
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email:
|
email:
|
||||||
|
|
14
README.md
14
README.md
|
@ -191,13 +191,19 @@ Tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /path/to/php-censor
|
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`.
|
For database B8Framework tests create empty 'b8_test' database on 'localhost' with user/password: `root/<empty>'`
|
||||||
Otherwise database tests will be skipped.
|
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
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
|
@ -11,6 +11,12 @@
|
||||||
syntaxCheck="false"
|
syntaxCheck="false"
|
||||||
bootstrap="./tests/bootstrap.php"
|
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>
|
<testsuites>
|
||||||
<testsuite name="B8Framework Test Suite">
|
<testsuite name="B8Framework Test Suite">
|
||||||
<directory suffix="Test.php">./tests/B8Framework</directory>
|
<directory suffix="Test.php">./tests/B8Framework</directory>
|
58
phpunit.pgsql.xml
Normal file
58
phpunit.pgsql.xml
Normal 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>
|
|
@ -257,6 +257,8 @@ class PhpUnitOptions
|
||||||
{
|
{
|
||||||
$files = [
|
$files = [
|
||||||
'phpunit.xml',
|
'phpunit.xml',
|
||||||
|
'phpunit.mysql.xml',
|
||||||
|
'phpunit.pgsql.xml',
|
||||||
'phpunit.xml.dist',
|
'phpunit.xml.dist',
|
||||||
'tests/phpunit.xml',
|
'tests/phpunit.xml',
|
||||||
'tests/phpunit.xml.dist',
|
'tests/phpunit.xml.dist',
|
||||||
|
|
|
@ -20,10 +20,10 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
|
||||||
['host' => 'localhost'],
|
['host' => 'localhost'],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'type' => 'mysql',
|
'type' => DB_TYPE,
|
||||||
'name' => 'b8_test',
|
'name' => DB_NAME,
|
||||||
'username' => 'root',
|
'username' => DB_USER,
|
||||||
'password' => 'root',
|
'password' => DB_PASS,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
@ -56,9 +56,9 @@ class DatabaseTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$details = Database::getConnection('read')->getDetails();
|
$details = Database::getConnection('read')->getDetails();
|
||||||
$this->assertTrue(is_array($details));
|
$this->assertTrue(is_array($details));
|
||||||
$this->assertTrue(($details['db'] == 'b8_test'));
|
$this->assertTrue(($details['db'] == DB_NAME));
|
||||||
$this->assertTrue(($details['user'] == 'root'));
|
$this->assertTrue(($details['user'] == DB_USER));
|
||||||
$this->assertTrue(($details['pass'] == 'root'));
|
$this->assertTrue(($details['pass'] == DB_PASS));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -51,3 +51,8 @@ if (!defined('APP_URL') && !empty($config)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
\PHPCensor\Helper\Lang::init($config, 'en');
|
\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'));
|
||||||
|
|
Loading…
Reference in a new issue