MediaWiki  REL1_24
StructureTest.php
Go to the documentation of this file.
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             'MediaWikiMediaTestCase',
00025             'MediaWikiTestCase',
00026             'ResourceLoaderTestCase',
00027             'PHPUnit_Framework_TestCase',
00028             'DumpTestCase',
00029         ) );
00030         $testClassRegex = "^class .* extends ($testClassRegex)";
00031         $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" .
00032             " | xargs grep -El '$testClassRegex|function suite\('";
00033 
00034         $results = null;
00035         $exitCode = null;
00036         exec( $finder, $results, $exitCode );
00037 
00038         $this->assertEquals(
00039             0,
00040             $exitCode,
00041             'Verify find/grep command succeeds.'
00042         );
00043 
00044         $results = array_filter(
00045             $results,
00046             array( $this, 'filterSuites' )
00047         );
00048         $strip = strlen( $rootPath ) - 1;
00049         foreach ( $results as $k => $v ) {
00050             $results[$k] = substr( $v, $strip );
00051         }
00052         $this->assertEquals(
00053             array(),
00054             $results,
00055             "Unit test file in $rootPath must end with Test."
00056         );
00057     }
00058 
00064     public function filterSuites( $filename ) {
00065         return strpos( $filename, __DIR__ . '/../suites/' ) !== 0;
00066     }
00067 }