Skip to content

Commit 847ff3f

Browse files
Slamdunksebastianbergmann
authored andcommitted
--no-logging and --no-coverage only disable XML configuration
1 parent 613e70f commit 847ff3f

File tree

3 files changed

+119
-131
lines changed

3 files changed

+119
-131
lines changed

src/TextUI/TestRunner.php

Lines changed: 110 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -343,81 +343,75 @@ public function run(TestSuite $suite, array $arguments = [], array $warnings = [
343343
$coverageFilterFromOption = false;
344344
$codeCoverageReports = 0;
345345

346-
if (!isset($arguments['noLogging'])) {
347-
if (isset($arguments['testdoxHTMLFile'])) {
348-
$result->addListener(
349-
new HtmlResultPrinter(
350-
$arguments['testdoxHTMLFile'],
351-
$arguments['testdoxGroups'],
352-
$arguments['testdoxExcludeGroups']
353-
)
354-
);
355-
}
356-
357-
if (isset($arguments['testdoxTextFile'])) {
358-
$result->addListener(
359-
new TextResultPrinter(
360-
$arguments['testdoxTextFile'],
361-
$arguments['testdoxGroups'],
362-
$arguments['testdoxExcludeGroups']
363-
)
364-
);
365-
}
346+
if (isset($arguments['testdoxHTMLFile'])) {
347+
$result->addListener(
348+
new HtmlResultPrinter(
349+
$arguments['testdoxHTMLFile'],
350+
$arguments['testdoxGroups'],
351+
$arguments['testdoxExcludeGroups']
352+
)
353+
);
354+
}
366355

367-
if (isset($arguments['testdoxXMLFile'])) {
368-
$result->addListener(
369-
new XmlResultPrinter(
370-
$arguments['testdoxXMLFile']
371-
)
372-
);
373-
}
356+
if (isset($arguments['testdoxTextFile'])) {
357+
$result->addListener(
358+
new TextResultPrinter(
359+
$arguments['testdoxTextFile'],
360+
$arguments['testdoxGroups'],
361+
$arguments['testdoxExcludeGroups']
362+
)
363+
);
364+
}
374365

375-
if (isset($arguments['teamcityLogfile'])) {
376-
$result->addListener(
377-
new TeamCity($arguments['teamcityLogfile'])
378-
);
379-
}
366+
if (isset($arguments['testdoxXMLFile'])) {
367+
$result->addListener(
368+
new XmlResultPrinter(
369+
$arguments['testdoxXMLFile']
370+
)
371+
);
372+
}
380373

381-
if (isset($arguments['junitLogfile'])) {
382-
$result->addListener(
383-
new JUnit(
384-
$arguments['junitLogfile'],
385-
$arguments['reportUselessTests']
386-
)
387-
);
388-
}
374+
if (isset($arguments['teamcityLogfile'])) {
375+
$result->addListener(
376+
new TeamCity($arguments['teamcityLogfile'])
377+
);
378+
}
389379

390-
if (isset($arguments['coverageClover'])) {
391-
$codeCoverageReports++;
392-
}
380+
if (isset($arguments['junitLogfile'])) {
381+
$result->addListener(
382+
new JUnit(
383+
$arguments['junitLogfile'],
384+
$arguments['reportUselessTests']
385+
)
386+
);
387+
}
393388

394-
if (isset($arguments['coverageCobertura'])) {
395-
$codeCoverageReports++;
396-
}
389+
if (isset($arguments['coverageClover'])) {
390+
$codeCoverageReports++;
391+
}
397392

398-
if (isset($arguments['coverageCrap4J'])) {
399-
$codeCoverageReports++;
400-
}
393+
if (isset($arguments['coverageCobertura'])) {
394+
$codeCoverageReports++;
395+
}
401396

402-
if (isset($arguments['coverageHtml'])) {
403-
$codeCoverageReports++;
404-
}
397+
if (isset($arguments['coverageCrap4J'])) {
398+
$codeCoverageReports++;
399+
}
405400

406-
if (isset($arguments['coveragePHP'])) {
407-
$codeCoverageReports++;
408-
}
401+
if (isset($arguments['coverageHtml'])) {
402+
$codeCoverageReports++;
403+
}
409404

410-
if (isset($arguments['coverageText'])) {
411-
$codeCoverageReports++;
412-
}
405+
if (isset($arguments['coveragePHP'])) {
406+
$codeCoverageReports++;
407+
}
413408

414-
if (isset($arguments['coverageXml'])) {
415-
$codeCoverageReports++;
416-
}
409+
if (isset($arguments['coverageText'])) {
410+
$codeCoverageReports++;
417411
}
418412

419-
if (isset($arguments['noCoverage'])) {
420-
$codeCoverageReports = 0;
413+
if (isset($arguments['coverageXml'])) {
414+
$codeCoverageReports++;
421415
}
422416

423417
if ($codeCoverageReports > 0 || isset($arguments['xdebugFilterFile'])) {
@@ -904,46 +898,48 @@ private function handleConfiguration(array &$arguments): void
904898

905899
$codeCoverageConfiguration = $arguments['configurationObject']->codeCoverage();
906900

907-
if (!isset($arguments['coverageClover']) && $codeCoverageConfiguration->hasClover()) {
908-
$arguments['coverageClover'] = $codeCoverageConfiguration->clover()->target()->path();
909-
}
901+
if (!isset($arguments['noCoverage'])) {
902+
if (!isset($arguments['coverageClover']) && $codeCoverageConfiguration->hasClover()) {
903+
$arguments['coverageClover'] = $codeCoverageConfiguration->clover()->target()->path();
904+
}
910905

911-
if (!isset($arguments['coverageCobertura']) && $codeCoverageConfiguration->hasCobertura()) {
912-
$arguments['coverageCobertura'] = $codeCoverageConfiguration->cobertura()->target()->path();
913-
}
906+
if (!isset($arguments['coverageCobertura']) && $codeCoverageConfiguration->hasCobertura()) {
907+
$arguments['coverageCobertura'] = $codeCoverageConfiguration->cobertura()->target()->path();
908+
}
914909

915-
if (!isset($arguments['coverageCrap4J']) && $codeCoverageConfiguration->hasCrap4j()) {
916-
$arguments['coverageCrap4J'] = $codeCoverageConfiguration->crap4j()->target()->path();
910+
if (!isset($arguments['coverageCrap4J']) && $codeCoverageConfiguration->hasCrap4j()) {
911+
$arguments['coverageCrap4J'] = $codeCoverageConfiguration->crap4j()->target()->path();
917912

918-
if (!isset($arguments['crap4jThreshold'])) {
919-
$arguments['crap4jThreshold'] = $codeCoverageConfiguration->crap4j()->threshold();
913+
if (!isset($arguments['crap4jThreshold'])) {
914+
$arguments['crap4jThreshold'] = $codeCoverageConfiguration->crap4j()->threshold();
915+
}
920916
}
921-
}
922917

923-
if (!isset($arguments['coverageHtml']) && $codeCoverageConfiguration->hasHtml()) {
924-
$arguments['coverageHtml'] = $codeCoverageConfiguration->html()->target()->path();
918+
if (!isset($arguments['coverageHtml']) && $codeCoverageConfiguration->hasHtml()) {
919+
$arguments['coverageHtml'] = $codeCoverageConfiguration->html()->target()->path();
925920

926-
if (!isset($arguments['reportLowUpperBound'])) {
927-
$arguments['reportLowUpperBound'] = $codeCoverageConfiguration->html()->lowUpperBound();
928-
}
921+
if (!isset($arguments['reportLowUpperBound'])) {
922+
$arguments['reportLowUpperBound'] = $codeCoverageConfiguration->html()->lowUpperBound();
923+
}
929924

930-
if (!isset($arguments['reportHighLowerBound'])) {
931-
$arguments['reportHighLowerBound'] = $codeCoverageConfiguration->html()->highLowerBound();
925+
if (!isset($arguments['reportHighLowerBound'])) {
926+
$arguments['reportHighLowerBound'] = $codeCoverageConfiguration->html()->highLowerBound();
927+
}
932928
}
933-
}
934929

935-
if (!isset($arguments['coveragePHP']) && $codeCoverageConfiguration->hasPhp()) {
936-
$arguments['coveragePHP'] = $codeCoverageConfiguration->php()->target()->path();
937-
}
930+
if (!isset($arguments['coveragePHP']) && $codeCoverageConfiguration->hasPhp()) {
931+
$arguments['coveragePHP'] = $codeCoverageConfiguration->php()->target()->path();
932+
}
938933

939-
if (!isset($arguments['coverageText']) && $codeCoverageConfiguration->hasText()) {
940-
$arguments['coverageText'] = $codeCoverageConfiguration->text()->target()->path();
941-
$arguments['coverageTextShowUncoveredFiles'] = $codeCoverageConfiguration->text()->showUncoveredFiles();
942-
$arguments['coverageTextShowOnlySummary'] = $codeCoverageConfiguration->text()->showOnlySummary();
943-
}
934+
if (!isset($arguments['coverageText']) && $codeCoverageConfiguration->hasText()) {
935+
$arguments['coverageText'] = $codeCoverageConfiguration->text()->target()->path();
936+
$arguments['coverageTextShowUncoveredFiles'] = $codeCoverageConfiguration->text()->showUncoveredFiles();
937+
$arguments['coverageTextShowOnlySummary'] = $codeCoverageConfiguration->text()->showOnlySummary();
938+
}
944939

945-
if (!isset($arguments['coverageXml']) && $codeCoverageConfiguration->hasXml()) {
946-
$arguments['coverageXml'] = $codeCoverageConfiguration->xml()->target()->path();
940+
if (!isset($arguments['coverageXml']) && $codeCoverageConfiguration->hasXml()) {
941+
$arguments['coverageXml'] = $codeCoverageConfiguration->xml()->target()->path();
942+
}
947943
}
948944

949945
$phpunitConfiguration = $arguments['configurationObject']->phpunit();
@@ -1043,31 +1039,33 @@ private function handleConfiguration(array &$arguments): void
10431039

10441040
$loggingConfiguration = $arguments['configurationObject']->logging();
10451041

1046-
if ($loggingConfiguration->hasText()) {
1047-
$arguments['listeners'][] = new DefaultResultPrinter(
1048-
$loggingConfiguration->text()->target()->path(),
1049-
true
1050-
);
1051-
}
1042+
if (!isset($arguments['noLogging'])) {
1043+
if ($loggingConfiguration->hasText()) {
1044+
$arguments['listeners'][] = new DefaultResultPrinter(
1045+
$loggingConfiguration->text()->target()->path(),
1046+
true
1047+
);
1048+
}
10521049

1053-
if (!isset($arguments['teamcityLogfile']) && $loggingConfiguration->hasTeamCity()) {
1054-
$arguments['teamcityLogfile'] = $loggingConfiguration->teamCity()->target()->path();
1055-
}
1050+
if (!isset($arguments['teamcityLogfile']) && $loggingConfiguration->hasTeamCity()) {
1051+
$arguments['teamcityLogfile'] = $loggingConfiguration->teamCity()->target()->path();
1052+
}
10561053

1057-
if (!isset($arguments['junitLogfile']) && $loggingConfiguration->hasJunit()) {
1058-
$arguments['junitLogfile'] = $loggingConfiguration->junit()->target()->path();
1059-
}
1054+
if (!isset($arguments['junitLogfile']) && $loggingConfiguration->hasJunit()) {
1055+
$arguments['junitLogfile'] = $loggingConfiguration->junit()->target()->path();
1056+
}
10601057

1061-
if (!isset($arguments['testdoxHTMLFile']) && $loggingConfiguration->hasTestDoxHtml()) {
1062-
$arguments['testdoxHTMLFile'] = $loggingConfiguration->testDoxHtml()->target()->path();
1063-
}
1058+
if (!isset($arguments['testdoxHTMLFile']) && $loggingConfiguration->hasTestDoxHtml()) {
1059+
$arguments['testdoxHTMLFile'] = $loggingConfiguration->testDoxHtml()->target()->path();
1060+
}
10641061

1065-
if (!isset($arguments['testdoxTextFile']) && $loggingConfiguration->hasTestDoxText()) {
1066-
$arguments['testdoxTextFile'] = $loggingConfiguration->testDoxText()->target()->path();
1067-
}
1062+
if (!isset($arguments['testdoxTextFile']) && $loggingConfiguration->hasTestDoxText()) {
1063+
$arguments['testdoxTextFile'] = $loggingConfiguration->testDoxText()->target()->path();
1064+
}
10681065

1069-
if (!isset($arguments['testdoxXMLFile']) && $loggingConfiguration->hasTestDoxXml()) {
1070-
$arguments['testdoxXMLFile'] = $loggingConfiguration->testDoxXml()->target()->path();
1066+
if (!isset($arguments['testdoxXMLFile']) && $loggingConfiguration->hasTestDoxXml()) {
1067+
$arguments['testdoxXMLFile'] = $loggingConfiguration->testDoxXml()->target()->path();
1068+
}
10711069
}
10721070

10731071
$testdoxGroupConfiguration = $arguments['configurationObject']->testdoxGroups();

tests/end-to-end/no-log-cc-override/_files/phpunit.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44
verbose="false"
55
colors="false"
66
cacheResult="false">
7+
<!--
78
<coverage>
89
<report>
910
<clover outputFile="php://stdout"/>
1011
<crap4j outputFile="php://stdout" threshold="50"/>
11-
<!-- <html outputDirectory="html-coverage" lowUpperBound="50" highLowerBound="90"/> -->
12+
<html outputDirectory="html-coverage" lowUpperBound="50" highLowerBound="90"/>
1213
<php outputFile="php://stdout"/>
1314
<text outputFile="php://stdout" showUncoveredFiles="false" showOnlySummary="false"/>
14-
<!-- <xml outputDirectory="xml-coverage"/> -->
15+
<xml outputDirectory="xml-coverage"/>
1516
</report>
1617
</coverage>
18+
-->
1719

1820
<logging>
1921
<junit outputFile="php://stdout"/>
Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
phpunit -c _files/phpunit.xml --no-logging --log-junit php://stdout --no-coverage --coverage-filter _files/NoLogNoCc.php --coverage-text _files/NoLogNoCcTest.php
2+
phpunit -c _files/phpunit.xml --no-logging --log-junit php://stdout _files/NoLogNoCcTest.php
33
--FILE--
44
<?php declare(strict_types=1);
55
$arguments = [
@@ -8,10 +8,10 @@ $arguments = [
88
'--no-logging',
99
'--log-junit',
1010
'php://stdout',
11-
'--no-coverage',
12-
'--coverage-filter',
13-
\realpath(__DIR__ . '/_files/NoLogNoCc.php'),
14-
'--coverage-text',
11+
// '--no-coverage',
12+
// '--coverage-filter',
13+
// \realpath(__DIR__ . '/_files/NoLogNoCc.php'),
14+
// '--coverage-text',
1515
\realpath(__DIR__ . '/_files/NoLogNoCcTest.php'),
1616
];
1717
\array_splice($_SERVER['argv'], 1, count($arguments), $arguments);
@@ -32,15 +32,3 @@ PHPUnit %s by Sebastian Bergmann and contributors.
3232
Time: %s, Memory: %s
3333

3434
OK (1 test, 1 assertion)
35-
36-
37-
Code Coverage Report:
38-
%s
39-
40-
Summary:
41-
Classes: 100.00% (1/1)
42-
Methods: 100.00% (1/1)
43-
Lines: 100.00% (1/1)
44-
45-
NoLogNoCc
46-
Methods: 100.00% ( 1/ 1) Lines: 100.00% ( 1/ 1)

0 commit comments

Comments
 (0)