More complete, more straightforward JobQueueMemoryTest
[mediawiki.git] / tests / phpunit / structure / StructureTest.php
blob14461be691c6d3cd9a54fbc3f60a6f068a222b2c
1 <?php
2 /**
3 * The tests here verify the structure of the code. This is for outright bugs,
4 * not just style issues.
5 */
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
13 public function testUnitTestFileNamesEndWithTest() {
14 if ( wfIsWindows() ) {
15 $this->markTestSkipped( 'This test does not work on Windows' );
17 $rootPath = escapeshellarg( __DIR__ . '/..' );
18 $testClassRegex = implode( '|', array(
19 'ApiFormatTestBase',
20 'ApiTestCase',
21 'ApiQueryTestBase',
22 'ApiQueryContinueTestBase',
23 'MediaWikiLangTestCase',
24 'MediaWikiMediaTestCase',
25 'MediaWikiTestCase',
26 'ResourceLoaderTestCase',
27 'PHPUnit_Framework_TestCase',
28 'DumpTestCase',
29 ) );
30 $testClassRegex = "^class .* extends ($testClassRegex)";
31 $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" .
32 " | xargs grep -El '$testClassRegex|function suite\('";
34 $results = null;
35 $exitCode = null;
36 exec( $finder, $results, $exitCode );
38 $this->assertEquals(
40 $exitCode,
41 'Verify find/grep command succeeds.'
44 $results = array_filter(
45 $results,
46 array( $this, 'filterSuites' )
48 $strip = strlen( $rootPath ) - 1;
49 foreach ( $results as $k => $v ) {
50 $results[$k] = substr( $v, $strip );
52 $this->assertEquals(
53 array(),
54 $results,
55 "Unit test file in $rootPath must end with Test."
59 /**
60 * Filter to remove testUnitTestFileNamesEndWithTest false positives.
61 * @param string $filename
62 * @return bool
64 public function filterSuites( $filename ) {
65 return strpos( $filename, __DIR__ . '/../suites/' ) !== 0;