diff options
author | Timo Tijhof <krinklemail@gmail.com> | 2019-06-12 15:05:09 +0100 |
---|---|---|
committer | Timo Tijhof <krinklemail@gmail.com> | 2019-06-12 15:11:18 +0100 |
commit | d9a5806940194bd600aebe8156e0124bf12aee74 (patch) | |
tree | 0a37e7b5475c51df58d9b0b6ad5628b7838c08b2 /tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php | |
parent | 284367013f6ae00be28a4a35e5980ffc3134cc5e (diff) | |
download | mediawikicore-d9a5806940194bd600aebe8156e0124bf12aee74.tar.gz mediawikicore-d9a5806940194bd600aebe8156e0124bf12aee74.zip |
resourceloader: Convert test for FileModule versionHash to data provider
In prep for the next commit.
Change-Id: If08c3d8b769b6ec03faf8ff24f216ce9f670f6ac
Diffstat (limited to 'tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php')
-rw-r--r-- | tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php index fbef12ea3632..2aa0d27f9992 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderFileModuleTest.php @@ -347,7 +347,6 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { $module = new ResourceLoaderFileTestModule( [ 'localBasePath' => $basePath, 'styles' => [ 'styles.less' ], - ], [ 'lessVars' => [ 'foo' => '2px', 'Foo' => '#eeeeee' ] ] ); $module->setName( 'test.less' ); @@ -355,27 +354,48 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { $this->assertStringEqualsFile( $basePath . '/styles.css', $styles['all'] ); } + public function provideGetVersionHash() { + $a = []; + $b = [ + 'lessVars' => [ 'key' => 'value' ], + ]; + yield 'with and without Less variables' => [ $a, $b, false ]; + + $a = [ + 'lessVars' => [ 'key' => 'value1' ], + ]; + $b = [ + 'lessVars' => [ 'key' => 'value2' ], + ]; + yield 'different Less variables' => [ $a, $b, false ]; + + $x = [ + 'lessVars' => [ 'key' => 'value' ], + ]; + yield 'identical Less variables' => [ $x, $x, true ]; + } + /** + * @dataProvider provideGetVersionHash * @covers ResourceLoaderFileModule::getDefinitionSummary * @covers ResourceLoaderFileModule::getFileHashes */ - public function testGetVersionHash() { + public function testGetVersionHash( $a, $b, $isEqual ) { $context = $this->getResourceLoaderContext(); - // Less variables - $module = new ResourceLoaderFileTestModule(); - $version = $module->getVersionHash( $context ); - $module = new ResourceLoaderFileTestModule( [], [ - 'lessVars' => [ 'key' => 'value' ], - ] ); - $this->assertNotEquals( - $version, - $module->getVersionHash( $context ), - 'Using less variables is significant' + $moduleA = new ResourceLoaderFileTestModule( $a ); + $versionA = $moduleA->getVersionHash( $context ); + $moduleB = new ResourceLoaderFileTestModule( $b ); + $versionB = $moduleB->getVersionHash( $context ); + + $this->assertSame( + $isEqual, + ( $versionA === $versionB ), + 'Whether versions hashes are equal' ); } - public function providerGetScriptPackageFiles() { + public function provideGetScriptPackageFiles() { $basePath = __DIR__ . '/../../data/resourceloader'; $base = [ 'localBasePath' => $basePath ]; $commentScript = file_get_contents( "$basePath/script-comment.js" ); @@ -559,7 +579,7 @@ class ResourceLoaderFileModuleTest extends ResourceLoaderTestCase { } /** - * @dataProvider providerGetScriptPackageFiles + * @dataProvider provideGetScriptPackageFiles * @covers ResourceLoaderFileModule::getScript * @covers ResourceLoaderFileModule::getPackageFiles * @covers ResourceLoaderFileModule::expandPackageFiles |