Merge "Selenium: replace UserLoginPage with BlankPage where possible"
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiCoversValidator.php
1 <?php
2 /**
3 * Copyright (C) 2017 Kunal Mehta <legoktm@member.fsf.org>
4 *
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.
9 *
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.
14 *
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.
18 *
19 */
20
21 /**
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
24 * slow.
25 *
26 * @since 1.31
27 */
28 trait MediaWikiCoversValidator {
29
30 /**
31 * Test that all methods in this class that begin
32 * with "test" have valid covers tags.
33 */
34 public function testValidCovers() {
35 $methods = get_class_methods( $this );
36 $class = get_class( $this );
37 $bad = '';
38 foreach ( $methods as $method ) {
39 if ( strpos( $method, 'test' ) === 0 ) {
40 try {
41 PHPUnit_Util_Test::getLinesToBeCovered( $class, $method );
42 } catch ( PHPUnit_Framework_CodeCoverageException $e ) {
43 $bad .= "$class::$method: {$e->getMessage()}\n";
44 }
45 }
46 }
47
48 $this->assertEquals( '', $bad );
49 }
50 }