(Bug 44192) Do not attempt to send a real e-mail in ApiAccountCreationTest
[lhc/web/wiklou.git] / tests / phpunit / StructureTest.php
1 <?php
2 /**
3 * The tests here verify the structure of the code. This is for outright bugs,
4 * not just style issues.
5 */
6
7 class StructureTest extends MediaWikiTestCase {
8 /**
9 * Verify all files that appear to be tests have file names ending in
10 * Test. If the file names do not end in Test, they will not be run.
11 * @group medium
12 */
13 public function testUnitTestFileNamesEndWithTest() {
14 if ( wfIsWindows() ) {
15 $this->markTestSkipped( 'This test does not work on Windows' );
16 }
17 $rootPath = escapeshellarg( __DIR__ );
18 $testClassRegex = implode( '|', array(
19 'ApiFormatTestBase',
20 'ApiTestCase',
21 'MediaWikiLangTestCase',
22 'MediaWikiTestCase',
23 'PHPUnit_Framework_TestCase',
24 'DumpTestCase',
25 ) );
26 $testClassRegex = "^class .* extends ($testClassRegex)";
27 $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" .
28 " | xargs grep -El '$testClassRegex|function suite\('";
29
30 $results = null;
31 $exitCode = null;
32 exec($finder, $results, $exitCode);
33
34 $this->assertEquals(
35 0,
36 $exitCode,
37 'Verify find/grep command succeeds.'
38 );
39
40 $results = array_filter(
41 $results,
42 array( $this, 'filterSuites' )
43 );
44 $strip = strlen( $rootPath ) - 1;
45 foreach( $results as $k => $v) {
46 $results[$k] = substr( $v, $strip );
47 }
48 $this->assertEquals(
49 array(),
50 $results,
51 "Unit test file in $rootPath must end with Test."
52 );
53 }
54
55 /**
56 * Filter to remove testUnitTestFileNamesEndWithTest false positives.
57 */
58 public function filterSuites( $filename ) {
59 return strpos( $filename, __DIR__ . '/suites/' ) !== 0;
60 }
61 }