From 1decdbce53686da6db12e367723997f5b8161ea6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Wed, 10 Feb 2016 19:37:07 +0100 Subject: [PATCH] CSSMin: Make isRemoteUrl and isLocalUrl really private, now that we can in PHP 5.5 Well, protected, because we want to have unit tests for them, apparently. Change-Id: I734b88599e5860aa59a07a89cc5389eb73b48813 --- includes/libs/CSSMin.php | 8 +++----- tests/phpunit/includes/libs/CSSMinTest.php | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/includes/libs/CSSMin.php b/includes/libs/CSSMin.php index 5f4dda9703..ece29e85cc 100644 --- a/includes/libs/CSSMin.php +++ b/includes/libs/CSSMin.php @@ -349,7 +349,7 @@ class CSSMin { $url = $match['file'] . $match['query']; $file = $local . $match['file']; if ( - !CSSMin::isRemoteUrl( $url ) && !CSSMin::isLocalUrl( $url ) + !self::isRemoteUrl( $url ) && !self::isLocalUrl( $url ) && file_exists( $file ) ) { $mimeTypes[ CSSMin::getMimeType( $file ) ] = true; @@ -391,11 +391,10 @@ class CSSMin { /** * Is this CSS rule referencing a remote URL? * - * @private Until we require PHP 5.5 and we can access self:: from closures. * @param string $maybeUrl * @return bool */ - public static function isRemoteUrl( $maybeUrl ) { + protected static function isRemoteUrl( $maybeUrl ) { if ( substr( $maybeUrl, 0, 2 ) === '//' || parse_url( $maybeUrl, PHP_URL_SCHEME ) ) { return true; } @@ -405,11 +404,10 @@ class CSSMin { /** * Is this CSS rule referencing a local URL? * - * @private Until we require PHP 5.5 and we can access self:: from closures. * @param string $maybeUrl * @return bool */ - public static function isLocalUrl( $maybeUrl ) { + protected static function isLocalUrl( $maybeUrl ) { if ( $maybeUrl !== '' && $maybeUrl[0] === '/' && !self::isRemoteUrl( $maybeUrl ) ) { return true; } diff --git a/tests/phpunit/includes/libs/CSSMinTest.php b/tests/phpunit/includes/libs/CSSMinTest.php index 6c0a923721..8902ecd4be 100644 --- a/tests/phpunit/includes/libs/CSSMinTest.php +++ b/tests/phpunit/includes/libs/CSSMinTest.php @@ -155,7 +155,7 @@ class CSSMinTest extends MediaWikiTestCase { * @cover CSSMin::isRemoteUrl */ public function testIsRemoteUrl( $expect, $url ) { - $this->assertEquals( CSSMin::isRemoteUrl( $url ), $expect ); + $this->assertEquals( CSSMinTestable::isRemoteUrl( $url ), $expect ); } public static function provideIsLocalUrls() { @@ -172,7 +172,7 @@ class CSSMinTest extends MediaWikiTestCase { * @cover CSSMin::isLocalUrl */ public function testIsLocalUrl( $expect, $url ) { - $this->assertEquals( CSSMin::isLocalUrl( $url ), $expect ); + $this->assertEquals( CSSMinTestable::isLocalUrl( $url ), $expect ); } public static function provideRemapRemappingCases() { @@ -443,3 +443,13 @@ class CSSMinTest extends MediaWikiTestCase { ]; } } + +class CSSMinTestable extends CSSMin { + // Make some protected methods public + public static function isRemoteUrl( $maybeUrl ) { + return parent::isRemoteUrl( $maybeUrl ); + } + public static function isLocalUrl( $maybeUrl ) { + return parent::isLocalUrl( $maybeUrl ); + } +} -- 2.20.1