diff --git a/composer.json b/composer.json
index c8068ee4..475f1de7 100644
--- a/composer.json
+++ b/composer.json
@@ -39,7 +39,8 @@
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14",
"sebastian/comparator": ">=1.2.3",
- "squizlabs/php_codesniffer": "^3.5"
+ "squizlabs/php_codesniffer": "^3.5",
+ "symfony/dom-crawler": "^3.0 || ^4.0 || ^5.0"
},
"bin": [
"bin/phpmetrics"
diff --git a/templates/html_report/complexity.php b/templates/html_report/complexity.php
index 30f27246..8eeb41dd 100644
--- a/templates/html_report/complexity.php
+++ b/templates/html_report/complexity.php
@@ -59,13 +59,14 @@
WMC |
Class cycl. |
Max method cycl. |
+ Relative system complexity |
Relative data complexity |
Relative structural complexity |
Bugs |
Defects |
has('junit')) { ?>
Unit testsuites calling it |
- Relative system complexity |
+
- );">
+ >
|
diff --git a/templates/html_report/coupling.php b/templates/html_report/coupling.php
index 948165d2..9c21d77f 100644
--- a/templates/html_report/coupling.php
+++ b/templates/html_report/coupling.php
@@ -26,7 +26,7 @@
|
- );">
+ >
|
diff --git a/templates/html_report/index.php b/templates/html_report/index.php
index bb906037..c7dd6c59 100644
--- a/templates/html_report/index.php
+++ b/templates/html_report/index.php
@@ -147,7 +147,7 @@
foreach ($classesS as $class) { ?>
- );">
+ >
|
diff --git a/templates/html_report/junit.php b/templates/html_report/junit.php
index 52f33545..f54aa2e7 100644
--- a/templates/html_report/junit.php
+++ b/templates/html_report/junit.php
@@ -82,7 +82,7 @@ classes never called by tests
|
- );">
+ >
|
diff --git a/templates/html_report/loc.php b/templates/html_report/loc.php
index e8b0093b..e860bae3 100644
--- a/templates/html_report/loc.php
+++ b/templates/html_report/loc.php
@@ -57,7 +57,7 @@
|
- );">
+ >
|
diff --git a/templates/html_report/oop.php b/templates/html_report/oop.php
index 8c0af93d..5371e0e7 100644
--- a/templates/html_report/oop.php
+++ b/templates/html_report/oop.php
@@ -77,7 +77,7 @@
|
- );">
+ >
|
diff --git a/tests/Report/Html/ComplexityReportRegressionTest.php b/tests/Report/Html/ComplexityReportRegressionTest.php
new file mode 100644
index 00000000..70e58062
--- /dev/null
+++ b/tests/Report/Html/ComplexityReportRegressionTest.php
@@ -0,0 +1,91 @@
+set('groups', $groups);
+
+ if ($junitEnabled) {
+ $config->set('junit', ['file' => '/tmp/junit.xml']);
+ }
+
+ // prepares destination
+ $destination = implode(DIRECTORY_SEPARATOR, [
+ sys_get_temp_dir(),
+ 'phpmetrics-html' . uniqid('', true)
+ ]);
+
+ $config->set('report-html', $destination);
+
+ // generates report
+ $metrics = new Metrics();
+ $reporter->generate($metrics);
+
+ // ensure complexity report contains expected table header columns
+ $content = file_get_contents(sprintf('%s/complexity.html', $destination));
+ $actualTableHeader = $this->getActualTableHeader($content);
+
+ $this->assertEquals($expectedTableHeader, $actualTableHeader);
+ }
+
+ public function tableHeaderDataProvider()
+ {
+ $defaultTableHeader = [
+ 'Class',
+ 'WMC',
+ 'Class cycl.',
+ 'Max method cycl.',
+ 'Relative system complexity',
+ 'Relative data complexity',
+ 'Relative structural complexity',
+ 'Bugs',
+ 'Defects',
+ ];
+
+ $junitTableHeader = array_merge($defaultTableHeader, [
+ 'Unit testsuites calling it'
+ ]);
+
+ return [
+ 'junit disabled' => [false, $defaultTableHeader],
+ 'junit enabled' => [true, $junitTableHeader],
+ ];
+ }
+
+ private function getActualTableHeader($content)
+ {
+ $tableHeaderColumnNodes = (new Crawler($content))
+ ->filterXPath('.//table[contains(concat(" ",normalize-space(@class)," ")," js-sort-table ")]/thead/tr')
+ ->children();
+
+ return array_map(function (DomNode $node) {
+ return $node->textContent;
+ }, iterator_to_array($tableHeaderColumnNodes));
+ }
+}