-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkahlan-config.php
More file actions
49 lines (42 loc) · 1.6 KB
/
kahlan-config.php
File metadata and controls
49 lines (42 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
use Kahlan\Filter\Filters;
use Kahlan\Reporter\Coverage;
use Kahlan\Reporter\Coverage\Driver\Xdebug;
use Kahlan\Reporter\Coverage\Driver\Phpdbg;
use Kahlan\Reporter\Coverage\Exporter\Coveralls;
$commandLine = $this->commandLine();
$commandLine->option('ff', 'default', 1);
$commandLine->option('coverage-coveralls', 'default', 'coveralls.json');
Filters::apply($this, 'reporting', function($next) {
// Get the reporter called `'coverage'` from the list of reporters
$reporter = $this->reporters()->get('coverage');
// Abort if no coverage is available.
if (!$reporter || !$this->commandLine()->exists('coverage-coveralls')) {
return $next();
}
// Use the `Coveralls` class to write the JSON coverage into a file
Coveralls::write([
'collector' => $reporter,
'file' => $this->commandLine()->get('coverage-coveralls'),
'service_name' => 'travis-ci',
'service_job_id' => getenv('TRAVIS_JOB_ID') ?: null
]);
return $next();
});
Filters::apply($this, 'coverage', function($next) {
if (!extension_loaded('xdebug') && PHP_SAPI !== 'phpdbg') {
return;
}
$reporters = $this->reporters();
$coverage = new Coverage([
'verbosity' => $this->commandLine()->get('coverage'),
'driver' => PHP_SAPI !== 'phpdbg' ? new Xdebug() : new Phpdbg(),
'path' => $this->commandLine()->get('src'),
'exclude' => [
//Exclude init script
'src/Core/Application.php',
],
'colors' => !$this->commandLine()->get('no-colors')
]);
$reporters->add('coverage', $coverage);
});