[MediaWiki-commits] [Gerrit] mediawiki/core[master]: resourceloader: Add unit tests for ResourceLoaderSkinModule

2017-07-10 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
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(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  jenkins-bot: Verified



diff --git 
a/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php 
b/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
new file mode 100644
index 000..c567698
--- /dev/null
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
@@ -0,0 +1,67 @@
+ [],
+   '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: merged
Gerrit-Change-Id: I299eff8f5172e047c0d54d9c824b17529dd6d190
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle 
Gerrit-Reviewer: Bartosz Dziewoński 
Gerrit-Reviewer: jenkins-bot <>

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] mediawiki/core[master]: resourceloader: Add unit tests for ResourceLoaderSkinModule

2017-07-07 Thread Krinkle (Code Review)
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 000..c567698
--- /dev/null
+++ b/tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
@@ -0,0 +1,67 @@
+ [],
+   '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 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits