MediaWiki
REL1_22
|
00001 <?php 00007 class StructureTest extends MediaWikiTestCase { 00013 public function testUnitTestFileNamesEndWithTest() { 00014 if ( wfIsWindows() ) { 00015 $this->markTestSkipped( 'This test does not work on Windows' ); 00016 } 00017 $rootPath = escapeshellarg( __DIR__ . '/..' ); 00018 $testClassRegex = implode( '|', array( 00019 'ApiFormatTestBase', 00020 'ApiTestCase', 00021 'ApiQueryTestBase', 00022 'ApiQueryContinueTestBase', 00023 'MediaWikiLangTestCase', 00024 'MediaWikiTestCase', 00025 'PHPUnit_Framework_TestCase', 00026 'DumpTestCase', 00027 ) ); 00028 $testClassRegex = "^class .* extends ($testClassRegex)"; 00029 $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" . 00030 " | xargs grep -El '$testClassRegex|function suite\('"; 00031 00032 $results = null; 00033 $exitCode = null; 00034 exec( $finder, $results, $exitCode ); 00035 00036 $this->assertEquals( 00037 0, 00038 $exitCode, 00039 'Verify find/grep command succeeds.' 00040 ); 00041 00042 $results = array_filter( 00043 $results, 00044 array( $this, 'filterSuites' ) 00045 ); 00046 $strip = strlen( $rootPath ) - 1; 00047 foreach ( $results as $k => $v ) { 00048 $results[$k] = substr( $v, $strip ); 00049 } 00050 $this->assertEquals( 00051 array(), 00052 $results, 00053 "Unit test file in $rootPath must end with Test." 00054 ); 00055 } 00056 00060 public function filterSuites( $filename ) { 00061 return strpos( $filename, __DIR__ . '/../suites/' ) !== 0; 00062 } 00063 }