1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-20 20:51:53 +02:00

Improved flexibility of codeception.yml

- MOD: Reduced code duplication in ./lib/config.php
- MOD: Replaced PHP 7.1 samples with PHP 7.2 samples in README.md
- NEW: ./config.sample.yml now supports customized database dumps, which
       affects the Codeception database populator
- NEW: Code coverage reports now take into account the configured
       `app_path`, which obviates a separate codeception.sample.yml file
       and reduces the complexity in setting up this test harness

@CaMer0n and @SimSync: I'm aware that you previously needed a separate
codeception.yml file because the coverage reports didn't use the
`app_path` from `config.yml`. This has been fixed. I'd like to keep just
one place for custom configurations (config.yml) so that we can keep
tests reproducible and avoid inconsistencies if/when codeception.yml
gets updated in the future.
This commit is contained in:
Nick Liu 2018-08-06 07:25:05 -05:00
parent 4edf051945
commit 3a0dd50e7c
No known key found for this signature in database
GPG Key ID: 1167C5F9C9897637
5 changed files with 32 additions and 20 deletions

View File

@ -36,9 +36,9 @@ e107 Test Suites
```
* **All tests with code coverage report:**
```sh
/opt/cpanel/ea-php71/root/usr/bin/php -d zend_extension=/opt/alt/php71/usr/lib64/php/modules/xdebug.so -d allow_url_fopen=On ./vendor/bin/codecept run --coverage --coverage-xml --coverage-html
/opt/cpanel/ea-php72/root/usr/bin/php -d zend_extension=/opt/alt/php72/usr/lib64/php/modules/xdebug.so -d allow_url_fopen=On ./vendor/bin/codecept run --coverage --coverage-xml --coverage-html
```
> **Note:** This command is specific to cPanel EasyApache PHP 7.1 and CloudLinux PHP Selector. See the "Code Coverage" section below for details.
> **Note:** This command is specific to cPanel EasyApache PHP 7.2 and CloudLinux PHP Selector. See the "Code Coverage" section below for details.
* **Unit tests:**
```sh
./vendor/bin/codecept run unit
@ -144,9 +144,9 @@ The reports may take minutes to be generated.
These commands run all tests and generate a code coverage report in HTML format and [Clover](https://bitbucket.org/atlassian/clover) XML format:
* Using [cPanel EasyApache 4](https://documentation.cpanel.net/display/EA4/PHP+Home) with PHP 7.1 and Xdebug from [CloudLinux PHP Selector](https://docs.cloudlinux.com/php_selector.html):
* Using [cPanel EasyApache 4](https://documentation.cpanel.net/display/EA4/PHP+Home) with PHP 7.2 and Xdebug from [CloudLinux PHP Selector](https://docs.cloudlinux.com/php_selector.html):
```sh
/opt/cpanel/ea-php71/root/usr/bin/php -d zend_extension=/opt/alt/php71/usr/lib64/php/modules/xdebug.so -d allow_url_fopen=On ./vendor/bin/codecept run --coverage --coverage-xml --coverage-html
/opt/cpanel/ea-php72/root/usr/bin/php -d zend_extension=/opt/alt/php72/usr/lib64/php/modules/xdebug.so -d allow_url_fopen=On ./vendor/bin/codecept run --coverage --coverage-xml --coverage-html
```
* Using the Xdebug module that you installed with PECL:
```sh

View File

@ -10,8 +10,8 @@ settings:
coverage:
enabled: true
include:
- e107/*.php
- e107/**/*.php
- '%app_path%/*.php'
- '%app_path%/**/*.php'
params:
- lib/config.php
extensions:
@ -30,5 +30,5 @@ modules:
dsn: 'mysql:host=%manual.db.host%;port=%manual.db.port%;dbname=%manual.db.dbname%'
user: '%manual.db.user%'
password: '%manual.db.password%'
populate: true
dump: 'tests/_data/e107_v2.1.8.sample.sql'
populate: '%db_dump.enabled%'
dump: '%db_dump.path%'

View File

@ -4,6 +4,18 @@
# Absolute path begins with "/"; relative path does not begin with "/"
app_path: 'e107/'
# Configure this section to customize the database populator
db_dump:
# If set to true, the populator will populate the database with the dump specified in the "path" key
# If set to false, the test database needs to be set up separately
# Affects all modes of deployment
enabled: true
# Path (absolute or relative) to the database dump of a testable installation of the app
# Absolute path begins with "/"; relative path does not begin with "/"
path: 'tests/_data/e107_v2.1.8.sample.sql'
# Configure this section for automated test deployments to cPanel
cpanel:

2
e107

@ -1 +1 @@
Subproject commit dec471da617000d7cfeac5d8cd5b5a2ad6a69646
Subproject commit e2460e0b3aa2fe562c2484b5742365a72fa334c1

View File

@ -2,17 +2,17 @@
use Symfony\Component\Yaml\Yaml;
$params_sample = [];
$params = [];
$params_local = [];
if (file_exists(codecept_root_dir() . '/config.sample.yml'))
$params_sample = Yaml::parse(file_get_contents(codecept_root_dir() . '/config.sample.yml'));
if (file_exists(codecept_root_dir() . '/config.yml'))
$params = Yaml::parse(file_get_contents(codecept_root_dir() . '/config.yml'));
if (file_exists(codecept_root_dir() . '/config.local.yml'))
$params_local = Yaml::parse(file_get_contents(codecept_root_dir() . '/config.local.yml'));
foreach ([
'config.sample.yml',
'config.yml',
'config.local.yml'
] as $config_filename)
{
$absolute_config_path = codecept_root_dir() . '/' . $config_filename;
if (file_exists($absolute_config_path))
$params = array_merge($params, Yaml::parse(file_get_contents($absolute_config_path)));
}
$params_merged = array_merge($params_sample, $params, $params_local);
return $params_merged;
return $params;