3 * The tests here verify the structure of the code. This is for outright bugs,
4 * not just style issues.
7 class StructureTest
extends MediaWikiTestCase
{
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.
12 public function testUnitTestFileNamesEndWithTest() {
13 if ( wfIsWindows() ) {
14 $this->markTestSkipped( 'This test does not work on Windows' );
16 $rootPath = escapeshellarg( __DIR__
);
17 $testClassRegex = implode( '|', array(
20 'MediaWikiLangTestCase',
22 'PHPUnit_Framework_TestCase',
25 $testClassRegex = "^class .* extends ($testClassRegex)";
26 $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" .
27 " | xargs grep -El '$testClassRegex|function suite\('";
31 exec($finder, $results, $exitCode);
36 'Verify find/grep command succeeds.'
39 $results = array_filter(
41 array( $this, 'filterSuites' )
43 $strip = strlen( $rootPath ) - 1;
44 foreach( $results as $k => $v) {
45 $results[$k] = substr( $v, $strip );
50 "Unit test file in $rootPath must end with Test."
55 * Filter to remove testUnitTestFileNamesEndWithTest false positives.
57 public function filterSuites( $filename ) {
58 return strpos( $filename, __DIR__
. '/suites/' ) !== 0;