diff --git a/.travis.yml b/.travis.yml index b9cf2563..2524ec67 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,6 +60,7 @@ jobs: allow_failures: - stage: Static Analysis (informative) - stage: Code Coverage + - php: nightly dist: xenial diff --git a/src/CodeCoverage/Generators/template.phtml b/src/CodeCoverage/Generators/template.phtml index 4db2a3e3..0fb4e126 100644 --- a/src/CodeCoverage/Generators/template.phtml +++ b/src/CodeCoverage/Generators/template.phtml @@ -10,12 +10,12 @@ -

Code coverage  %

- $info): ?> -
+name); + + $currentFile = ''; + foreach ($keys as $key) { + $currentFile = $currentFile . ($currentFile !== '' ? '/' : '') . $key; + $arr = &$arr['files'][$key]; + + if (!isset($arr['name'])) { + $arr['name'] = $currentFile; + } + $arr['count'] = isset($arr['count']) ? $arr['count'] + 1 : 1; + $arr['coverage'] = isset($arr['coverage']) ? $arr['coverage'] + $info->coverage : $info->coverage; + } + $arr = $value; +} + +$jsonData = []; +$directories = []; +$allLinesCount = 0; +foreach ($files as $id => $info) { + $code = file_get_contents($info->file); + $lineCount = substr_count($code, "\n") + 1; + $digits = ceil(log10($lineCount)) + 1; + + $allLinesCount += $lineCount; + + $currentId = "F{$id}"; + assignArrayByPath($directories, $info, $currentId); + + $data = (array) $info; + $data['digits'] = $digits; + $data['lineCount'] = $lineCount; + $data['content'] = strtr(highlight_string($code, true), [ + '' => "", + '' => '', + '
' => '
', + ]); + $jsonData[$currentId] = $data; +} ?> + +

+ Code coverage  % + sources have lines of code in files +

+ + + +
+
- class ? " class='$info->class'" : '' ?>> - - - - + + + + + + +
coverage ?> %
name ?>
+  % + +
+
+ path  +
+
+
+ +
+ + + + + addClickListener('tab-item', function(e) { + e.preventDefault(); + let tabs = document.getElementsByClassName('tab-content'); + for (let i = 0; i < tabs.length; i++) { + tabs[i].style.display = 'none'; + } + let tabItems = document.getElementsByClassName('tab-item'); + for (let i = 0; i < tabItems.length; i++) { + tabItems[i].classList.remove('active'); + } + this.classList.add('active'); + + let id = this.href.split('#')[1]; + if (id === 'files') { + initFiles(); + } else { + initDirectories(); + } + + let el = document.getElementById(id); + if (el.style.display === 'block') { + el.style.display = 'none'; + } else { + el.style.display = 'block'; + } + }); + + document.addEventListener("DOMContentLoaded", function(event) { + initFiles(true); + + let el = document.getElementById(window.location.hash.replace(/^#|L\d+$/g, '')); + if (el) { + initFileContent(el); + el.style.display = 'block'; + } + }); + })(); +