Krinkle has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/364002 )
Change subject: resourceloader: Add unit tests for ResourceLoaderSkinModule
......................................................................
resourceloader: Add unit tests for ResourceLoaderSkinModule
Change-Id: I299eff8f5172e047c0d54d9c824b17529dd6d190
---
A tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
1 file changed, 67 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/02/364002/1
diff --git
a/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
b/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
new file mode 100644
index 0000000..c567698
--- /dev/null
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * @group Database
+ * @group ResourceLoader
+ */
+class ResourceLoaderSkinModuleTest extends PHPUnit_Framework_TestCase {
+
+ public static function provideGetStyles() {
+ return [
+ [
+ 'parent' => [],
+ 'expected' => [
+ 'all' => [ '.mw-wiki-logo {
background-image: url(/logo.png); }' ],
+ ],
+ ],
+ [
+ 'parent' => [
+ 'screen' => '.example {}',
+ ],
+ 'expected' => [
+ 'screen' => [ '.example {}' ],
+ 'all' => [ '.mw-wiki-logo {
background-image: url(/logo.png); }' ],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider provideGetStyles
+ * @covers ResourceLoaderSkinModule::normalizeStyles
+ * @covers ResourceLoaderSkinModule::getStyles
+ */
+ public function testGetStyles( $parent, $expected ) {
+ $module = $this->getMockBuilder(
ResourceLoaderSkinModule::class )
+ ->disableOriginalConstructor()
+ ->setMethods( [ 'readStyleFiles' ] )
+ ->getMock();
+ $module->expects( $this->once() )->method( 'readStyleFiles' )
+ ->willReturn( $parent );
+ $module->setConfig( new HashConfig( [
+ 'ResourceBasePath' => '/w',
+ 'Logo' => '/logo.png',
+ 'LogoHD' => false,
+ ] ) );
+
+ $ctx = $this->getMockBuilder( ResourceLoaderContext::class )
+ ->disableOriginalConstructor()->getMock();
+
+ $this->assertEquals(
+ $module->getStyles( $ctx ),
+ $expected
+ );
+ }
+
+ /**
+ * @covers ResourceLoaderSkinModule::isKnownEmpty
+ */
+ public function testIsKnownEmpty() {
+ $module = $this->getMockBuilder(
ResourceLoaderSkinModule::class )
+ ->disableOriginalConstructor()->setMethods( null
)->getMock();
+ $ctx = $this->getMockBuilder( ResourceLoaderContext::class )
+ ->disableOriginalConstructor()->getMock();
+
+ $this->assertFalse( $module->isKnownEmpty( $ctx ) );
+ }
+}
--
To view, visit https://gerrit.wikimedia.org/r/364002
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I299eff8f5172e047c0d54d9c824b17529dd6d190
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits