Skip to content

Commit 4518680

Browse files
authored
Merge pull request #23 from o0h/improve-ci
Improve ci
2 parents e139e57 + 02472c0 commit 4518680

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

.travis.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,50 @@ sudo: false
1313

1414
env:
1515
matrix:
16-
- DB=mysql db_dsn='mysql://travis@127.0.0.1/cakephp_test'
16+
- DB=mysql db_user=root db_host=0.0.0.0 db_name=cakephp_test
1717

1818
global:
19-
- DEFAULT=1
19+
- DEFAULT=1 PREFER_LOWEST="--prefer-lowest"
2020

2121
matrix:
2222
fast_finish: true
2323

2424
include:
2525
- php: 7.3
26-
env: PHPCS=1 DEFAULT=0
26+
env: PREFER_LOWEST="" DB=mysql db_user=root db_host=0.0.0.0 db_name=cakephp_test
27+
28+
- php: '7.4snapshot'
29+
env: PREFER_LOWEST="" DB=mysql db_user=root db_host=0.0.0.0 db_name=cakephp_test
30+
31+
- php: 7.3
32+
env: PHPCS=1 DEFAULT=0 PREFER_LOWEST="
2733

2834
- php: 7.3
29-
env: PHPSTAN=1 DEFAULT=0
35+
env: PHPSTAN=1 DEFAULT=0 PREFER_LOWEST="
36+
3037

3138
cache:
3239
directories:
3340
- vendor
3441
- $HOME/.composer/cache
3542

3643
before_script:
37-
- if [[ $TRAVIS_PHP_VERSION != 7.3 ]]; then phpenv config-rm xdebug.ini; fi
44+
- if [[ $TRAVIS_PHP_VERSION != '7.4snapshot' ]]; then phpenv config-rm xdebug.ini; fi
3845

3946
- composer self-update
40-
- composer install --prefer-dist --no-interaction
47+
- composer update --prefer-stable --prefer-dist --no-interaction $PREFER_LOWEST
4148

4249
- if [[ $DB = 'mysql' ]]; then mysql -e 'CREATE DATABASE cakephp_test; GRANT ALL PRIVILEGES ON cakephp_test.* TO travis@localhost;'; fi
4350

4451
- if [[ $PHPCS = 1 ]]; then composer require cakephp/cakephp-codesniffer:"^3.0"; fi
4552
- if [[ $PHPSTAN = 1 ]]; then composer require phpstan/phpstan; fi
4653

54+
# see: https://github.com/cakephp/chronos/issues/106
55+
- if [[ $TRAVIS_PHP_VERSION != 7.0 && $PREFER_LOWEST != "" ]]; then composer require --prefer-stable --prefer-dist --no-interaction $PREFER_LOWEST cakephp/chronos:^1.0.1; fi
56+
4757
script:
4858
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION != 7.3 ]]; then vendor/bin/phpunit; fi
49-
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.3 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi
59+
- if [[ $DEFAULT = 1 && $TRAVIS_PHP_VERSION = 7.3 ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-clover=clover.xml; fi
5060

5161
- if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs -n -p --extensions=php --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests; fi
5262
- if [[ $PHPSTAN = 1 ]]; then vendor/bin/phpstan analyse -c phpstan.neon -l 7 src; fi

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"require-dev": {
3232
"cakephp/cakephp": "^3.5",
33-
"phpunit/phpunit": "^5.7"
33+
"phpunit/phpunit": "^5.7.14|^6.0"
3434
},
3535
"autoload": {
3636
"psr-4": {

tests/bootstrap.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,28 @@
2727

2828
return;
2929
}
30-
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';
30+
31+
// With PHP7.3 & CakePHP 3.5.0, StaticConfigTrait::parseDsn causes the error in preg_match
32+
// (It has benn fixed in 3.5.1 https://github.com/cakephp/cakephp/commit/91475ccfa58948b2561ffd9631664c1c3edaf300)
33+
// In place of using `db_dsn` uri, set db config with array.
34+
if (getenv('DB') === 'mysql') {
35+
$dbConfig = [
36+
'className' => \Cake\Database\Connection::class,
37+
'driver' => \Cake\Database\Driver\Mysql::class,
38+
'host' => getenv('db_host'),
39+
'username' => getenv('db_user'),
40+
'database' => getenv('db_name'),
41+
'url' => null,
42+
];
43+
\Cake\Datasource\ConnectionManager::setConfig('test', $dbConfig);
44+
\Cake\Datasource\ConnectionManager::setConfig('test_custom_i18n_datasource', $dbConfig);
45+
try {
46+
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';
47+
} catch (\BadMethodCallException $e) {
48+
if (strpos($e->getMessage(), 'Cannot reconfigure existing key') !== 0) {
49+
throw $e;
50+
}
51+
}
52+
} else {
53+
require $root . '/vendor/cakephp/cakephp/tests/bootstrap.php';
54+
}

0 commit comments

Comments
 (0)