diff --git a/src/Util/Configuration.php b/src/Util/Configuration.php index 04ec37c6572..5c16cd06b56 100644 --- a/src/Util/Configuration.php +++ b/src/Util/Configuration.php @@ -184,6 +184,9 @@ private function __construct(string $filename) $this->xpath = new DOMXPath($this->document); } + /** + * @codeCoverageIgnore + */ private function __clone() { } diff --git a/tests/Util/ConfigurationTest.php b/tests/Util/ConfigurationTest.php index 7be7d62c22c..c5935eb379b 100644 --- a/tests/Util/ConfigurationTest.php +++ b/tests/Util/ConfigurationTest.php @@ -75,46 +75,46 @@ public function testFilterConfigurationIsReadCorrectly(): void { $this->assertEquals( [ - 'whitelist' => - [ - 'addUncoveredFilesFromWhitelist' => true, - 'processUncoveredFilesFromWhitelist' => false, - 'include' => - [ - 'directory' => - [ - 0 => - [ - 'path' => '/path/to/files', - 'prefix' => '', - 'suffix' => '.php', - 'group' => 'DEFAULT' - ], - ], - 'file' => - [ - 0 => '/path/to/file', - 1 => '/path/to/file', - ], - ], - 'exclude' => - [ - 'directory' => - [ - 0 => - [ - 'path' => '/path/to/files', - 'prefix' => '', - 'suffix' => '.php', - 'group' => 'DEFAULT' - ], - ], - 'file' => - [ - 0 => '/path/to/file', - ], - ], - ], + 'whitelist' => + [ + 'addUncoveredFilesFromWhitelist' => true, + 'processUncoveredFilesFromWhitelist' => false, + 'include' => + [ + 'directory' => + [ + 0 => + [ + 'path' => '/path/to/files', + 'prefix' => '', + 'suffix' => '.php', + 'group' => 'DEFAULT' + ], + ], + 'file' => + [ + 0 => '/path/to/file', + 1 => '/path/to/file', + ], + ], + 'exclude' => + [ + 'directory' => + [ + 0 => + [ + 'path' => '/path/to/files', + 'prefix' => '', + 'suffix' => '.php', + 'group' => 'DEFAULT' + ], + ], + 'file' => + [ + 0 => '/path/to/file', + ], + ], + ], ], $this->configuration->getFilterConfiguration() ); @@ -124,14 +124,14 @@ public function testGroupConfigurationIsReadCorrectly(): void { $this->assertEquals( [ - 'include' => - [ - 0 => 'name', - ], - 'exclude' => - [ - 0 => 'name', - ], + 'include' => + [ + 0 => 'name', + ], + 'exclude' => + [ + 0 => 'name', + ], ], $this->configuration->getGroupConfiguration() ); @@ -163,38 +163,38 @@ public function testListenerConfigurationIsReadCorrectly(): void $this->assertEquals( [ - 0 => - [ - 'class' => 'MyListener', - 'file' => '/optional/path/to/MyListener.php', - 'arguments' => - [ 0 => + [ + 'class' => 'MyListener', + 'file' => '/optional/path/to/MyListener.php', + 'arguments' => + [ + 0 => + [ + 0 => 'Sebastian', + ], + 1 => 22, + 2 => 'April', + 3 => 19.78, + 4 => null, + 5 => new \stdClass, + 6 => \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MyTestFile.php', + 7 => \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MyRelativePath', + ], + ], [ - 0 => 'Sebastian', + 'class' => 'IncludePathListener', + 'file' => __FILE__, + 'arguments' => [] + ], + [ + 'class' => 'CompactArgumentsListener', + 'file' => '/CompactArgumentsListener.php', + 'arguments' => + [ + 0 => 42 + ], ], - 1 => 22, - 2 => 'April', - 3 => 19.78, - 4 => null, - 5 => new \stdClass, - 6 => \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MyTestFile.php', - 7 => \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'MyRelativePath', - ], - ], - [ - 'class' => 'IncludePathListener', - 'file' => __FILE__, - 'arguments' => [] - ], - [ - 'class' => 'CompactArgumentsListener', - 'file' => '/CompactArgumentsListener.php', - 'arguments' => - [ - 0 => 42 - ], - ], ], $this->configuration->getListenerConfiguration() ); @@ -206,17 +206,22 @@ public function testLoggingConfigurationIsReadCorrectly(): void { $this->assertEquals( [ - 'lowUpperBound' => '50', - 'highLowerBound' => '90', - 'coverage-html' => '/tmp/report', - 'coverage-clover' => '/tmp/clover.xml', - 'json' => '/tmp/logfile.json', - 'plain' => '/tmp/logfile.txt', - 'tap' => '/tmp/logfile.tap', - 'junit' => '/tmp/logfile.xml', - 'testdox-html' => '/tmp/testdox.html', - 'testdox-text' => '/tmp/testdox.txt', - 'testdox-xml' => '/tmp/testdox.xml' + 'lowUpperBound' => '50', + 'highLowerBound' => '90', + 'coverage-html' => '/tmp/report', + 'coverage-clover' => '/tmp/clover.xml', + 'coverage-crap4j' => '/tmp/crap4j.xml', + 'crap4jThreshold' => 50, + 'coverage-text' => '/tmp/coverage.txt', + 'coverageTextShowUncoveredFiles' => true, + 'coverageTextShowOnlySummary' => true, + 'json' => '/tmp/logfile.json', + 'plain' => '/tmp/logfile.txt', + 'tap' => '/tmp/logfile.tap', + 'junit' => '/tmp/logfile.xml', + 'testdox-html' => '/tmp/testdox.html', + 'testdox-text' => '/tmp/testdox.txt', + 'testdox-xml' => '/tmp/testdox.xml' ], $this->configuration->getLoggingConfiguration() ); @@ -226,21 +231,21 @@ public function testPHPConfigurationIsReadCorrectly(): void { $this->assertEquals( [ - 'include_path' => - [ - \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . '.', - '/path/to/lib' - ], - 'ini' => ['foo' => ['value' => 'bar']], - 'const' => ['FOO' => ['value' => false], 'BAR' => ['value' => true]], - 'var' => ['foo' => ['value' => false]], - 'env' => ['foo' => ['value' => true], 'bar' => ['value' => 'true', 'verbatim' => true], 'foo_force' => ['value' => 'forced', 'force' => true]], - 'post' => ['foo' => ['value' => 'bar']], - 'get' => ['foo' => ['value' => 'bar']], - 'cookie' => ['foo' => ['value' => 'bar']], - 'server' => ['foo' => ['value' => 'bar']], - 'files' => ['foo' => ['value' => 'bar']], - 'request'=> ['foo' => ['value' => 'bar']], + 'include_path' => + [ + \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . '.', + '/path/to/lib' + ], + 'ini' => ['foo' => ['value' => 'bar']], + 'const' => ['FOO' => ['value' => false], 'BAR' => ['value' => true]], + 'var' => ['foo' => ['value' => false]], + 'env' => ['foo' => ['value' => true], 'bar' => ['value' => 'true', 'verbatim' => true], 'foo_force' => ['value' => 'forced', 'force' => true]], + 'post' => ['foo' => ['value' => 'bar']], + 'get' => ['foo' => ['value' => 'bar']], + 'cookie' => ['foo' => ['value' => 'bar']], + 'server' => ['foo' => ['value' => 'bar']], + 'files' => ['foo' => ['value' => 'bar']], + 'request'=> ['foo' => ['value' => 'bar']], ], $this->configuration->getPHPConfiguration() ); @@ -255,11 +260,11 @@ public function testPHPConfigurationIsHandledCorrectly(): void $path = \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . '.' . PATH_SEPARATOR . '/path/to/lib'; $this->assertStringStartsWith($path, \ini_get('include_path')); - $this->assertEquals(false, \FOO); - $this->assertEquals(true, \BAR); - $this->assertEquals(false, $GLOBALS['foo']); - $this->assertEquals(true, $_ENV['foo']); - $this->assertEquals(true, \getenv('foo')); + $this->assertFalse(\FOO); + $this->assertTrue(\BAR); + $this->assertFalse($GLOBALS['foo']); + $this->assertTrue($_ENV['foo']); + $this->assertEquals(1, \getenv('foo')); $this->assertEquals('bar', $_POST['foo']); $this->assertEquals('bar', $_GET['foo']); $this->assertEquals('bar', $_COOKIE['foo']); @@ -278,8 +283,8 @@ public function testHandlePHPConfigurationDoesNotOverwrittenExistingEnvArrayVari $_ENV['foo'] = false; $this->configuration->handlePHPConfiguration(); - $this->assertEquals(false, $_ENV['foo']); - $this->assertEquals(true, \getenv('foo')); + $this->assertFalse($_ENV['foo']); + $this->assertEquals(1, \getenv('foo')); } /** @@ -306,7 +311,7 @@ public function testHandlePHPConfigurationDoesNotOverriteVariablesFromPutEnv(): \putenv('foo=putenv'); $this->configuration->handlePHPConfiguration(); - $this->assertEquals(true, $_ENV['foo']); + $this->assertTrue($_ENV['foo']); $this->assertEquals('putenv', \getenv('foo')); } @@ -328,38 +333,38 @@ public function testPHPUnitConfigurationIsReadCorrectly(): void { $this->assertEquals( [ - 'backupGlobals' => true, - 'backupStaticAttributes' => false, - 'beStrictAboutChangesToGlobalState' => false, - 'bootstrap' => '/path/to/bootstrap.php', - 'cacheTokens' => false, - 'columns' => 80, - 'colors' => 'never', - 'stderr' => false, - 'convertDeprecationsToExceptions' => true, - 'convertErrorsToExceptions' => true, - 'convertNoticesToExceptions' => true, - 'convertWarningsToExceptions' => true, - 'forceCoversAnnotation' => false, - 'stopOnFailure' => false, - 'stopOnWarning' => false, - 'reportUselessTests' => false, - 'strictCoverage' => false, - 'disallowTestOutput' => false, - 'enforceTimeLimit' => false, - 'extensionsDirectory' => '/tmp', - 'printerClass' => 'PHPUnit\TextUI\ResultPrinter', - 'testSuiteLoaderClass' => 'PHPUnit\Runner\StandardTestSuiteLoader', - 'defaultTestSuite' => 'My Test Suite', - 'verbose' => false, - 'timeoutForSmallTests' => 1, - 'timeoutForMediumTests' => 10, - 'timeoutForLargeTests' => 60, - 'beStrictAboutResourceUsageDuringSmallTests' => false, - 'disallowTodoAnnotatedTests' => false, - 'failOnWarning' => false, - 'failOnRisky' => false, - 'ignoreDeprecatedCodeUnitsFromCodeCoverage' => false + 'backupGlobals' => true, + 'backupStaticAttributes' => false, + 'beStrictAboutChangesToGlobalState' => false, + 'bootstrap' => '/path/to/bootstrap.php', + 'cacheTokens' => false, + 'columns' => 80, + 'colors' => 'never', + 'stderr' => false, + 'convertDeprecationsToExceptions' => true, + 'convertErrorsToExceptions' => true, + 'convertNoticesToExceptions' => true, + 'convertWarningsToExceptions' => true, + 'forceCoversAnnotation' => false, + 'stopOnFailure' => false, + 'stopOnWarning' => false, + 'reportUselessTests' => false, + 'strictCoverage' => false, + 'disallowTestOutput' => false, + 'enforceTimeLimit' => false, + 'extensionsDirectory' => '/tmp', + 'printerClass' => 'PHPUnit\TextUI\ResultPrinter', + 'testSuiteLoaderClass' => 'PHPUnit\Runner\StandardTestSuiteLoader', + 'defaultTestSuite' => 'My Test Suite', + 'verbose' => false, + 'timeoutForSmallTests' => 1, + 'timeoutForMediumTests' => 10, + 'timeoutForLargeTests' => 60, + 'beStrictAboutResourceUsageDuringSmallTests' => false, + 'disallowTodoAnnotatedTests' => false, + 'failOnWarning' => false, + 'failOnRisky' => false, + 'ignoreDeprecatedCodeUnitsFromCodeCoverage' => false ], $this->configuration->getPHPUnitConfiguration() ); diff --git a/tests/_files/configuration.xml b/tests/_files/configuration.xml index 1fbed0e0534..401db05aa32 100644 --- a/tests/_files/configuration.xml +++ b/tests/_files/configuration.xml @@ -1,5 +1,4 @@ - - - - /path/to/files - /path/to/MyTest.php - - + + + /path/to/files + /path/to/MyTest.php + + - - - name - - - name - - + + + name + + + name + + - - - name - - - name - - + + + name + + + name + + - - - /path/to/files - /path/to/file - - /path/to/file - - - /path/to/files - /path/to/file - - - + + + /path/to/files + /path/to/file + + /path/to/file + + + /path/to/files + /path/to/file + + + - - - - - - Sebastian - - - 22 - April - 19.78 - - - MyTestFile.php - MyRelativePath - - - - 42 - + + + + + + Sebastian + + + 22 + April + 19.78 + + + MyTestFile.php + MyRelativePath + + + + + + 42 + + + - - - - - - - - - - - + + + + + + + + + + + + + - - . - /path/to/lib - - - - - - - - - - - - - - + + . + /path/to/lib + + + + + + + + + + + + + +