MediaWikiUnitTestCase: Use DIRECTORY_SEPARATOR instead of `/`
authorRazeSoldier <razesoldier@outlook.com>
Wed, 17 Jul 2019 17:52:18 +0000 (01:52 +0800)
committerJforrester <jforrester@wikimedia.org>
Fri, 19 Jul 2019 19:45:30 +0000 (19:45 +0000)
`strpos( $reflection->getFilename(), '/unit/' )` will always
return FALSE under Windows

Change-Id: Ib13d32858e238b9a18094f829939f6bba08366ab

tests/phpunit/MediaWikiUnitTestCase.php

index 43a333c..5f7746b 100644 (file)
@@ -36,7 +36,8 @@ abstract class MediaWikiUnitTestCase extends TestCase {
        protected function setUp() {
                parent::setUp();
                $reflection = new ReflectionClass( $this );
        protected function setUp() {
                parent::setUp();
                $reflection = new ReflectionClass( $this );
-               if ( strpos( $reflection->getFilename(), '/unit/' ) === false ) {
+               $dirSeparator = DIRECTORY_SEPARATOR;
+               if ( strpos( $reflection->getFilename(), "${dirSeparator}unit${dirSeparator}" ) === false ) {
                        $this->fail( 'This unit test needs to be in "tests/phpunit/unit" !' );
                }
                $this->unitGlobals = $GLOBALS;
                        $this->fail( 'This unit test needs to be in "tests/phpunit/unit" !' );
                }
                $this->unitGlobals = $GLOBALS;