3 * Copyright (C) 2017 Kunal Mehta <legoktm@member.fsf.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 * Trait that checks that covers tags are valid, since PHPUnit
23 * won't do it unless you run it with coverage, which is super
28 trait MediaWikiCoversValidator
{
31 * Test that all methods in this class that begin
32 * with "test" have valid covers tags.
34 public function testValidCovers() {
35 $methods = get_class_methods( $this );
36 $class = static::class;
38 foreach ( $methods as $method ) {
39 if ( strpos( $method, 'test' ) === 0 ) {
41 PHPUnit_Util_Test
::getLinesToBeCovered( $class, $method );
42 } catch ( PHPUnit_Framework_CodeCoverageException
$e ) {
43 $bad .= "$class::$method: {$e->getMessage()}\n";
48 $this->assertEquals( '', $bad );