better structure filename error output
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 24 Feb 2012 16:54:48 +0000 (16:54 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 24 Feb 2012 16:54:48 +0000 (16:54 +0000)
When dumping an array, PHPUnit limit the number of characters shown. That would
just hide the relevant part of the path:

1) StructureTest::testUnitTestFileNamesEndWithTest
[...]
 Array (
+    0 => '/some/path/tests/phpunit/incl...ge.php'
+    1 => '/some/path/tests/phpunit/incl...ki.php'
 )

By stripping the common path ( /some/path/tests/phpunit ), we end up with a
more useful output:

 Array (
+    0 => 'includes/RecentChange.php'
+    1 => 'includes/Wiki.php'
 )

tests/phpunit/StructureTest.php

index f967c18..6953ab6 100644 (file)
@@ -39,11 +39,14 @@ class StructureTest extends MediaWikiTestCase {
                        $results,
                        array( $this, 'filterSuites' )
                );
-
+               $strip = strlen( $rootPath ) - 1;
+               foreach( $results as $k => $v) {
+                       $results[$k] = substr( $v, $strip );
+               }
                $this->assertEquals(
                        array(),
                        $results,
-                       'Unit test file names must end with Test.'
+                       "Unit test file in $rootPath must end with Test."
                );
        }