diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2012-05-03 13:01:35 +0200 |
commit | d9022f63880ce039446fba8364f68e656b7bf4cb (patch) | |
tree | 16b40fbf17bf7c9ee6f4ead25b16dd192378050a /tests/phpunit/StructureTest.php | |
parent | 27cf83d177256813e2e802241085fce5dd0f3fb9 (diff) |
Update to MediaWiki 1.19.0
Diffstat (limited to 'tests/phpunit/StructureTest.php')
-rw-r--r-- | tests/phpunit/StructureTest.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/phpunit/StructureTest.php b/tests/phpunit/StructureTest.php new file mode 100644 index 00000000..f967c18d --- /dev/null +++ b/tests/phpunit/StructureTest.php @@ -0,0 +1,56 @@ +<?php +/** + * The tests here verify the structure of the code. This is for outright bugs, + * not just style issues. + */ + +class StructureTest extends MediaWikiTestCase { + /** + * Verify all files that appear to be tests have file names ending in + * Test. If the file names do not end in Test, they will not be run. + */ + public function testUnitTestFileNamesEndWithTest() { + if ( wfIsWindows() ) { + $this->markTestSkipped( 'This test does not work on Windows' ); + } + $rootPath = escapeshellarg( __DIR__ ); + $testClassRegex = implode( '|', array( + 'ApiFormatTestBase', + 'ApiTestCase', + 'MediaWikiLangTestCase', + 'MediaWikiTestCase', + 'PHPUnit_Framework_TestCase', + ) ); + $testClassRegex = "^class .* extends ($testClassRegex)"; + $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" . + " | xargs grep -El '$testClassRegex|function suite\('"; + + $results = null; + $exitCode = null; + exec($finder, $results, $exitCode); + + $this->assertEquals( + 0, + $exitCode, + 'Verify find/grep command succeeds.' + ); + + $results = array_filter( + $results, + array( $this, 'filterSuites' ) + ); + + $this->assertEquals( + array(), + $results, + 'Unit test file names must end with Test.' + ); + } + + /** + * Filter to remove testUnitTestFileNamesEndWithTest false positives. + */ + public function filterSuites( $filename ) { + return strpos( $filename, __DIR__ . '/suites/' ) !== 0; + } +} |