From: Lucas Werkmeister Date: Mon, 20 May 2019 15:09:37 +0000 (+0200) Subject: Normalize dir path in AutoLoaderStructureTest X-Git-Tag: 1.34.0-rc.0~1454^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=2744dbd9b7bc186639e3be2b0a32399adbd30fb9;p=lhc%2Fweb%2Fwiklou.git Normalize dir path in AutoLoaderStructureTest The file paths we inspect are always normalized (File_Iterator_Facade applies realpath()), but the directory we compare against may not be, depending on how wfLoadExtension() was called. Normalize the directory before we remove the directory prefix from each file, so that we don’t end up stripping away the wrong parts of the path. Change-Id: Ib272fb892c18d989f8d439ed50c6a5a8fd542cc9 --- diff --git a/tests/phpunit/structure/AutoLoaderStructureTest.php b/tests/phpunit/structure/AutoLoaderStructureTest.php index 2ae6a78b74..4e1b00abba 100644 --- a/tests/phpunit/structure/AutoLoaderStructureTest.php +++ b/tests/phpunit/structure/AutoLoaderStructureTest.php @@ -49,7 +49,9 @@ class AutoLoaderStructureTest extends MediaWikiTestCase { // Check that the expected class name (based on the filename) is the // same as the one we found. // Strip directory prefix from front of filename, and .php extension - $abbrFileName = substr( substr( $file, strlen( $dir ) ), 0, -4 ); + $dirNameLength = strlen( realpath( $dir ) ) + 1; // +1 for the trailing slash + $fileBaseName = substr( $file, $dirNameLength ); + $abbrFileName = substr( $fileBaseName, 0, -4 ); $expectedClassName = $prefix . str_replace( '/', '\\', $abbrFileName ); $this->assertSame(