Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * Coverage information for PHPUnit. 19 * 20 * @package core 21 * @category phpunit 22 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 class phpunit_coverage_info { 26 27 /** @var array The list of folders relative to the plugin root to include in coverage generation. */ 28 protected $includelistfolders = []; 29 30 /** @var array The list of files relative to the plugin root to include in coverage generation. */ 31 protected $includelistfiles = []; 32 33 /** @var array The list of folders relative to the plugin root to exclude from coverage generation. */ 34 protected $excludelistfolders = []; 35 36 /** @var array The list of files relative to the plugin root to exclude from coverage generation. */ 37 protected $excludelistfiles = []; 38 39 /** 40 * Get the formatted XML list of files and folders to include. 41 * 42 * @param string $plugindir The root of the plugin, relative to the dataroot. 43 * @return array 44 */ 45 final public function get_includelists(string $plugindir) : array { 46 $coverages = []; 47 48 $includelistfolders = array_merge([ 49 'classes', 50 'tests/generator', 51 ], $this->includelistfolders);; 52 53 $includelistfiles = array_merge([ 54 'externallib.php', 55 'lib.php', 56 'locallib.php', 57 'renderer.php', 58 'rsslib.php', 59 ], $this->includelistfiles); 60 61 if (!empty($plugindir)) { 62 $plugindir .= "/"; 63 } 64 65 foreach (array_unique($includelistfolders) as $folder) { 66 $coverages[] = html_writer::tag('directory', "{$plugindir}{$folder}", ['suffix' => '.php']); 67 } 68 69 foreach (array_unique($includelistfiles) as $file) { 70 $coverages[] = html_writer::tag('file', "{$plugindir}{$file}"); 71 } 72 73 return $coverages; 74 } 75 76 /** 77 * Get the formatted XML list of files and folders to exclude. 78 * 79 * @param string $plugindir The root of the plugin, relative to the dataroot. 80 * @return array 81 */ 82 final public function get_excludelists(string $plugindir) : array { 83 $coverages = []; 84 85 if (!empty($plugindir)) { 86 $plugindir .= "/"; 87 } 88 89 foreach ($this->excludelistfolders as $folder) { 90 $coverages[] = html_writer::tag('directory', "{$plugindir}{$folder}", ['suffix' => '.php']); 91 } 92 93 foreach ($this->excludelistfiles as $file) { 94 $coverages[] = html_writer::tag('file', "{$plugindir}{$file}"); 95 } 96 97 return $coverages; 98 } 99 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body