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