From 2744dbd9b7bc186639e3be2b0a32399adbd30fb9 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Mon, 20 May 2019 17:09:37 +0200 Subject: [PATCH] Normalize dir path in AutoLoaderStructureTest MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- tests/phpunit/structure/AutoLoaderStructureTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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( -- 2.20.1