From a0339862ac8f69c9967a4b6208bfa4111231ea0e Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Tue, 26 Jun 2018 02:52:40 +0100 Subject: [PATCH] resourceloader: Add @covers for FileModuleTest Add @covers for various helper methods used by public methods, where the helper methods actually contain most of the logic being tested in FileModuleTest. I've changed these methods from protected to private (confirmed no usage) to further pin down that their contract doesn't matter beyond making the public methods work. Change-Id: I2aef0d322b38bc3595e7d2c2339112b16fc66b8d --- .../ResourceLoaderFileModule.php | 32 +++++++++---------- .../ResourceLoaderImageModule.php | 2 +- .../ResourceLoaderFileModuleTest.php | 5 +++ 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/includes/resourceloader/ResourceLoaderFileModule.php b/includes/resourceloader/ResourceLoaderFileModule.php index e572aa4169..68ea0c07ab 100644 --- a/includes/resourceloader/ResourceLoaderFileModule.php +++ b/includes/resourceloader/ResourceLoaderFileModule.php @@ -486,16 +486,13 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { } /** - * Helper method to gather file hashes for getDefinitionSummary. - * - * This function is context-sensitive, only computing hashes of files relevant to the - * given language, skin, etc. + * Helper method for getDefinitionSummary. * * @see ResourceLoaderModule::getFileDependencies * @param ResourceLoaderContext $context * @return array */ - protected function getFileHashes( ResourceLoaderContext $context ) { + private function getFileHashes( ResourceLoaderContext $context ) { $files = []; // Flatten style files into $files @@ -673,12 +670,12 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { } /** - * Get a list of file paths for all scripts in this module, in order of proper execution. + * Get a list of script file paths for this module, in order of proper execution. * * @param ResourceLoaderContext $context * @return array List of file paths */ - protected function getScriptFiles( ResourceLoaderContext $context ) { + private function getScriptFiles( ResourceLoaderContext $context ) { $files = array_merge( $this->scripts, $this->getLanguageScripts( $context->getLanguage() ), @@ -717,6 +714,9 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { /** * Get a list of file paths for all styles in this module, in order of proper inclusion. * + * This is considered a private method. Exposed for internal use by WebInstallerOutput. + * + * @private * @param ResourceLoaderContext $context * @return array List of file paths */ @@ -790,13 +790,13 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { } /** - * Gets the contents of a list of JavaScript files. + * Get the contents of a list of JavaScript files. Helper for getScript(). * * @param array $scripts List of file paths to scripts to read, remap and concetenate - * @throws MWException * @return string Concatenated and remapped JavaScript data from $scripts + * @throws MWException */ - protected function readScriptFiles( array $scripts ) { + private function readScriptFiles( array $scripts ) { if ( empty( $scripts ) ) { return ''; } @@ -819,17 +819,17 @@ class ResourceLoaderFileModule extends ResourceLoaderModule { } /** - * Gets the contents of a list of CSS files. + * Get the contents of a list of CSS files. + * + * This is considered a private method. Exposed for internal use by WebInstallerOutput. * - * @param array $styles List of media type/list of file paths pairs, to read, remap and - * concetenate + * @private + * @param array $styles Map of media type to file paths to read, remap, and concatenate * @param bool $flip * @param ResourceLoaderContext $context - * - * @throws MWException * @return array List of concatenated and remapped CSS data from $styles, * keyed by media type - * + * @throws MWException * @since 1.27 Calling this method without a ResourceLoaderContext instance * is deprecated. */ diff --git a/includes/resourceloader/ResourceLoaderImageModule.php b/includes/resourceloader/ResourceLoaderImageModule.php index e1bddcc9b9..26d5e98212 100644 --- a/includes/resourceloader/ResourceLoaderImageModule.php +++ b/includes/resourceloader/ResourceLoaderImageModule.php @@ -426,7 +426,7 @@ class ResourceLoaderImageModule extends ResourceLoaderModule { * @param ResourceLoaderContext $context * @return array */ - protected function getFileHashes( ResourceLoaderContext $context ) { + private function getFileHashes( ResourceLoaderContext $context ) { $this->loadFromDefinition(); $files = []; foreach ( $this->getImages( $context ) as $name => $image ) { diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php index e82bab72df..71966b7570 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php @@ -140,6 +140,8 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { /** * @covers ResourceLoaderFileModule::getScript + * @covers ResourceLoaderFileModule::getScriptFiles + * @covers ResourceLoaderFileModule::readScriptFiles */ public function testGetScript() { $module = new ResourceLoaderFileModule( [ @@ -220,6 +222,8 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { * * @covers ResourceLoaderFileModule::getStyles * @covers ResourceLoaderFileModule::getStyleFiles + * @covers ResourceLoaderFileModule::readStyleFiles + * @covers ResourceLoaderFileModule::readStyleFile */ public function testMixedCssAnnotations() { $basePath = __DIR__ . '/../../data/css'; @@ -334,6 +338,7 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { /** * @covers ResourceLoaderFileModule::getDefinitionSummary + * @covers ResourceLoaderFileModule::getFileHashes */ public function testGetVersionHash() { $context = $this->getResourceLoaderContext(); -- 2.20.1