Skip to content

Commit 1285cef

Browse files
committed
Add: Configure atoum for coveralls/travisCI
Signed-off-by: Yann 'Ze' Richard <ze@nbox.org>
1 parent c7dbb0a commit 1285cef

File tree

2 files changed

+37
-47
lines changed

2 files changed

+37
-47
lines changed

.atoum.php

Lines changed: 34 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,37 @@
99
[fr] http://docs.atoum.org/fr/chapter3.html#Fichier-de-configuration
1010
*/
1111

12-
$report = $script->addDefaultReport();
13-
14-
/*
15-
LOGO
16-
*/
17-
// This will add the atoum logo before each run.
18-
// $report->addField(new atoum\report\fields\runner\atoum\logo());
19-
20-
// This will add a green or red logo after each run depending on its status.
21-
// $report->addField(new atoum\report\fields\runner\result\logo());
22-
23-
/*
24-
CODE COVERAGE SETUP
25-
*/
26-
// Please replace in next line "Project Name" by your project name and "/path/to/destination/directory" by your destination directory path for html files.
27-
$coverage_field = new atoum\report\fields\runner\coverage\html('php-pwned-passwords', __DIR__.'/reports/atoum');
28-
29-
// Please replace in next line http://url/of/web/site by the root url of your code coverage web site.
30-
// $coverage_field->setRootUrl('http://url/of/web/site');
31-
32-
$report->addField($coverage_field);
33-
34-
/*
35-
TEST GENERATOR SETUP
36-
*/
37-
$test_generator = new atoum\test\generator();
38-
39-
// Please replace in next line "/path/to/your/tests/units/classes/directory" by your unit test's directory.
40-
$test_generator->setTestClassesDirectory(__DIR__.'/tests/units/');
41-
42-
// Please replace in next line "your\project\namespace\tests\units" by your unit test's namespace.
43-
$test_generator->setTestClassNamespace('UniversiteRennes2\PwnedPasswords\tests\units');
44-
45-
// Please replace in next line "/path/to/your/classes/directory" by your classes directory.
46-
$test_generator->setTestedClassesDirectory(__DIR__.'/src/PwnedPasswords.php');
47-
48-
// Please replace in next line "your\project\namespace" by your project namespace.
49-
$test_generator->setTestedClassNamespace('UniversiteRennes2\PwnedPasswords');
50-
51-
// Please replace in next line "path/to/your/tests/units/runner.php" by path to your unit test's runner.
52-
// $test_generator->setRunnerPath('path/to/your/tests/units/runner.php');
53-
54-
$script->getRunner()->setTestGenerator($test_generator);
55-
12+
use mageekguy\atoum\reports;
13+
14+
$runner
15+
->addTestsFromDirectory(__DIR__ . '/tests/units/')
16+
->disallowUsageOfUndefinedMethodInMock();
17+
18+
$runner->getScore()->getCoverage();
19+
20+
$travis = getenv('TRAVIS');
21+
if ($travis)
22+
{
23+
$script->addDefaultReport();
24+
$coverallsToken = getenv('COVERALLS_REPO_TOKEN');
25+
if ($coverallsToken)
26+
{
27+
$coverallsReport = new reports\asynchronous\coveralls('classes', $coverallsToken);
28+
$defaultFinder = $coverallsReport->getBranchFinder();
29+
$coverallsReport
30+
->setBranchFinder(function() use ($defaultFinder) {
31+
if (($branch = getenv('TRAVIS_BRANCH')) === false)
32+
{
33+
$branch = $defaultFinder();
34+
}
35+
return $branch;
36+
}
37+
)
38+
->setServiceName(getenv('TRAVIS') ? 'travis-ci' : null)
39+
->setServiceJobId(getenv('TRAVIS_JOB_ID') ?: null)
40+
->addDefaultWriter()
41+
;
42+
$runner->addReport($coverallsReport);
43+
$script->testIt();
44+
}
45+
}

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ php:
44
- 7.1
55
- 7.2
66
- 7.3
7-
- hhvm
7+
- nightly
88

99
matrix:
1010
allow_failures:
11-
- php: hhvm
11+
- php: nightly
1212

1313
before_script:
1414
- composer self-update || true
@@ -17,5 +17,5 @@ before_script:
1717

1818
script:
1919
- ./vendor/bin/phpcs -p --standard=./phpcs.xml --extensions=php --warning-severity=0 src/ tests/
20-
- ./vendor/bin/atoum tests/units/PwnedPasswords.php
20+
- php -n -ddate.timezone=Europe/Paris ./vendor/bin/atoum +verbose
2121

0 commit comments

Comments
 (0)