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