Permalink
Browse files

Improved TravisCI build settings

  • Loading branch information...
corpsee committed Feb 18, 2017
1 parent 9f8a5df commit 9f0580e8020869fea092fd2dbe7d57edc25539df
View
@@ -10,7 +10,7 @@ setup:
test:
php_unit:
config:
- phpunit.xml
- phpunit.mysql.xml
coverage: coverage
php_mess_detector:
View
@@ -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
@@ -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
-------------
@@ -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>
View
@@ -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 @@ public static function findConfigFile($buildPath)
{
$files = [
'phpunit.xml',
'phpunit.mysql.xml',
'phpunit.pgsql.xml',
'phpunit.xml.dist',
'tests/phpunit.xml',
'tests/phpunit.xml.dist',
@@ -20,10 +20,10 @@ protected function setUp()
['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 @@ public function testGetDetails()
$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
@@ -51,3 +51,8 @@
}
\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'));

0 comments on commit 9f0580e

Please sign in to comment.