Fix file name and class case.
[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 */
12 public function testUnitTestFileNamesEndWithTest() {
13 $rootPath = escapeshellarg( __DIR__ );
14 $testClassRegex = implode( '|', array(
15 'ApiFormatTestBase',
16 'ApiTestCase',
17 'MediaWikiLangTestCase',
18 'MediaWikiTestCase',
19 'PHPUnit_Framework_TestCase',
20 ) );
21 $testClassRegex = "^class .* extends ($testClassRegex)";
22 $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" .
23 " | xargs grep -El '$testClassRegex|function suite\('";
24
25 $results = null;
26 $exitCode = null;
27 exec($finder, $results, $exitCode);
28
29 $this->assertEquals(
30 0,
31 $exitCode,
32 'Verify find/grep command succeeds.'
33 );
34
35 $results = array_filter(
36 $results,
37 array( $this, 'filterSuites' )
38 );
39
40 $this->assertEquals(
41 array(),
42 $results,
43 'Unit test file names must end with Test.'
44 );
45 }
46
47 /**
48 * Filter to remove testUnitTestFileNamesEndWithTest false positives.
49 */
50 public function filterSuites( $filename ) {
51 return strpos( $filename, __DIR__ . '/suites/' ) !== 0;
52 }
53 }