Skip to content

Commit

Permalink
MDL-72701 unit tests: Generate default coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Dec 21, 2021
1 parent bb9741d commit 3a70983
Show file tree
Hide file tree
Showing 16 changed files with 29 additions and 561 deletions.
49 changes: 0 additions & 49 deletions admin/tool/dataprivacy/tests/coverage.php

This file was deleted.

41 changes: 0 additions & 41 deletions grade/grading/form/guide/tests/coverage.php

This file was deleted.

41 changes: 0 additions & 41 deletions grade/grading/form/rubric/tests/coverage.php

This file was deleted.

41 changes: 0 additions & 41 deletions grade/grading/tests/coverage.php

This file was deleted.

40 changes: 0 additions & 40 deletions grade/tests/coverage.php

This file was deleted.

48 changes: 0 additions & 48 deletions h5p/tests/coverage.php

This file was deleted.

26 changes: 17 additions & 9 deletions lib/phpunit/classes/coverage_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ class phpunit_coverage_info {
final public function get_includelists(string $plugindir) : array {
$coverages = [];

$includelistfolders = array_merge([
'classes',
'tests/generator',
], $this->includelistfolders);;

$includelistfiles = array_merge([
'externallib.php',
'lib.php',
'locallib.php',
'renderer.php',
'rsslib.php',
], $this->includelistfiles);

if (!empty($plugindir)) {
$plugindir .= "/";

Expand All @@ -79,21 +92,16 @@ final public function get_includelists(string $plugindir) : array {
"Please, replace them with \$includelistfolders and " .
"\$includelistfiles in {$plugindir}tests/coverage.php\n";

foreach ($this->whitelistfolders as $folder) {
$coverages[] = html_writer::tag('directory', "{$plugindir}{$folder}", ['suffix' => '.php']);
}

foreach ($this->whitelistfiles as $file) {
$coverages[] = html_writer::tag('file', "{$plugindir}{$file}");
}
$includelistfolders = array_merge($includelistfolders, $this->whitelistfolders);
$includelistfiles = array_merge($includelistfiles, $this->whitelistfiles);
}
}

foreach ($this->includelistfolders as $folder) {
foreach ($includelistfolders as $folder) {
$coverages[] = html_writer::tag('directory', "{$plugindir}{$folder}", ['suffix' => '.php']);
}

foreach ($this->includelistfiles as $file) {
foreach ($includelistfiles as $file) {
$coverages[] = html_writer::tag('file', "{$plugindir}{$file}");
}

Expand Down
4 changes: 2 additions & 2 deletions lib/phpunit/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ protected static function get_coverage_config(array $includelists, array $exclud
* @param string $fulldir The directory to find the coverage info file in.
* @return phpunit_coverage_info
*/
protected static function get_coverage_info(string $fulldir): ?phpunit_coverage_info {
protected static function get_coverage_info(string $fulldir): phpunit_coverage_info {
$coverageconfig = "{$fulldir}/tests/coverage.php";
if (file_exists($coverageconfig)) {
$coverageinfo = require($coverageconfig);
Expand All @@ -984,7 +984,7 @@ protected static function get_coverage_info(string $fulldir): ?phpunit_coverage_
return $coverageinfo;
}

return null;
return new phpunit_coverage_info();;
}

/**
Expand Down
50 changes: 0 additions & 50 deletions lib/table/tests/coverage.php

This file was deleted.

Loading

0 comments on commit 3a70983

Please sign in to comment.