r102720 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102719‎ | r102720 | r102721 >
Date:23:52, 10 November 2011
Author:gicode
Status:ok
Tags:
Comment:
Fix file name and class case.

Follow-up r102719
Modified paths:
  • /trunk/phase3/tests/phpunit/StructureTest.php (added) (history)
  • /trunk/phase3/tests/phpunit/structureTest.php (deleted) (history)
  • /trunk/phase3/tests/phpunit/suite.xml (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/structureTest.php
@@ -1,53 +0,0 @@
2 -<?php
3 -/**
4 - * The tests here verify the structure of the code. This is for outright bugs,
5 - * not just style issues.
6 - */
7 -
8 -class structureTest extends MediaWikiTestCase {
9 - /**
10 - * Verify all files that appear to be tests have file names ending in
11 - * Test. If the file names do not end in Test, they will not be run.
12 - */
13 - public function testUnitTestFileNamesEndWithTest() {
14 - $rootPath = escapeshellarg( __DIR__ );
15 - $testClassRegex = implode( '|', array(
16 - 'ApiFormatTestBase',
17 - 'ApiTestCase',
18 - 'MediaWikiLangTestCase',
19 - 'MediaWikiTestCase',
20 - 'PHPUnit_Framework_TestCase',
21 - ) );
22 - $testClassRegex = "^class .* extends ($testClassRegex)";
23 - $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" .
24 - " | xargs grep -El '$testClassRegex|function suite\('";
25 -
26 - $results = null;
27 - $exitCode = null;
28 - exec($finder, $results, $exitCode);
29 -
30 - $this->assertEquals(
31 - 0,
32 - $exitCode,
33 - 'Verify find/grep command succeeds.'
34 - );
35 -
36 - $results = array_filter(
37 - $results,
38 - array( $this, 'filterSuites' )
39 - );
40 -
41 - $this->assertEquals(
42 - array(),
43 - $results,
44 - 'Unit test file names must end with Test.'
45 - );
46 - }
47 -
48 - /**
49 - * Filter to remove testUnitTestFileNamesEndWithTest false positives.
50 - */
51 - public function filterSuites( $filename ) {
52 - return strpos( $filename, __DIR__ . '/suites/' ) !== 0;
53 - }
54 -}
Index: trunk/phase3/tests/phpunit/StructureTest.php
@@ -0,0 +1,53 @@
 2+<?php
 3+/**
 4+ * The tests here verify the structure of the code. This is for outright bugs,
 5+ * not just style issues.
 6+ */
 7+
 8+class StructureTest extends MediaWikiTestCase {
 9+ /**
 10+ * Verify all files that appear to be tests have file names ending in
 11+ * Test. If the file names do not end in Test, they will not be run.
 12+ */
 13+ public function testUnitTestFileNamesEndWithTest() {
 14+ $rootPath = escapeshellarg( __DIR__ );
 15+ $testClassRegex = implode( '|', array(
 16+ 'ApiFormatTestBase',
 17+ 'ApiTestCase',
 18+ 'MediaWikiLangTestCase',
 19+ 'MediaWikiTestCase',
 20+ 'PHPUnit_Framework_TestCase',
 21+ ) );
 22+ $testClassRegex = "^class .* extends ($testClassRegex)";
 23+ $finder = "find $rootPath -name '*.php' '!' -name '*Test.php'" .
 24+ " | xargs grep -El '$testClassRegex|function suite\('";
 25+
 26+ $results = null;
 27+ $exitCode = null;
 28+ exec($finder, $results, $exitCode);
 29+
 30+ $this->assertEquals(
 31+ 0,
 32+ $exitCode,
 33+ 'Verify find/grep command succeeds.'
 34+ );
 35+
 36+ $results = array_filter(
 37+ $results,
 38+ array( $this, 'filterSuites' )
 39+ );
 40+
 41+ $this->assertEquals(
 42+ array(),
 43+ $results,
 44+ 'Unit test file names must end with Test.'
 45+ );
 46+ }
 47+
 48+ /**
 49+ * Filter to remove testUnitTestFileNamesEndWithTest false positives.
 50+ */
 51+ public function filterSuites( $filename ) {
 52+ return strpos( $filename, __DIR__ . '/suites/' ) !== 0;
 53+ }
 54+}
Index: trunk/phase3/tests/phpunit/suite.xml
@@ -21,7 +21,7 @@
2222 <directory>skins</directory>
2323 </testsuite>
2424 <testsuite name="structure">
25 - <file>structureTest.php</file>
 25+ <file>StructureTest.php</file>
2626 </testsuite>
2727 <testsuite name="uploadfromurl">
2828 <file>suites/UploadFromUrlTestSuite.php</file>

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102719Add test to catch the problem fixed in r102595....gicode23:45, 10 November 2011

Status & tagging log