Aude has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/155535

Change subject: Use mock in SpecialPageCopyrightViewTest
......................................................................

Use mock in SpecialPageCopyrightViewTest

this fixes failure on travis, where the test
indirectly depended on content language setting.

We can use a mock and then not be concerned about
content language at all.

Change-Id: I60c0b201807b05d2b4e5847bfe4ccaed204cb86b
---
M repo/tests/phpunit/includes/specials/SpecialPageCopyrightViewTest.php
1 file changed, 23 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/35/155535/1

diff --git 
a/repo/tests/phpunit/includes/specials/SpecialPageCopyrightViewTest.php 
b/repo/tests/phpunit/includes/specials/SpecialPageCopyrightViewTest.php
index ed44e93..012fc15 100644
--- a/repo/tests/phpunit/includes/specials/SpecialPageCopyrightViewTest.php
+++ b/repo/tests/phpunit/includes/specials/SpecialPageCopyrightViewTest.php
@@ -3,6 +3,7 @@
 namespace Wikibase\Test;
 
 use Language;
+use Message;
 use Wikibase\CopyrightMessageBuilder;
 use Wikibase\Repo\Specials\SpecialPageCopyrightView;
 
@@ -19,36 +20,39 @@
        /**
         * @dataProvider getHtmlProvider
         */
-       public function testGetHtml( $regex, $matcher, $rightsUrl, $rightsText 
) {
-               $lang = Language::factory( 'qqx' );
+       public function testGetHtml( $expected, $message, $languageCode ) {
+               $lang = Language::factory( $languageCode );
 
                $specialPageCopyrightView = new SpecialPageCopyrightView(
-                       new CopyrightMessageBuilder(),
-                       $rightsUrl,
-                       $rightsText
+                       $this->getCopyrightMessageBuilder( $message ), 'x', 'y'
                );
 
                $html = $specialPageCopyrightView->getHtml( $lang );
+               $this->assertEquals( $expected, $html );
+       }
 
-               $this->assertRegExp( $regex, $html, 'message html includes 
wikibase-save and copyrightpage' );
-               $this->assertTag( $matcher, $html, 'message html includes 
license link and text' );
+       private function getCopyrightMessageBuilder( Message $message ) {
+               $copyrightMessageBuilder = $this->getMockBuilder( 
'Wikibase\CopyrightMessageBuilder' )
+                       ->getMock();
+
+               $copyrightMessageBuilder->expects( $this->any() )
+                       ->method( 'build' )
+                       ->will( $this->returnValue( $message ) );
+
+               return $copyrightMessageBuilder;
        }
 
        public function getHtmlProvider() {
+               $message = new Message(
+                       'wikibase-shortcopyrightwarning',
+                       array( 'wikibase-save', 'copyrightpage', 
'copyrightlink' )
+               );
+
                return array(
                        array(
-                               '/\(wikibase-shortcopyrightwarning: 
\(wikibase-save\), ' .
-                               preg_quote( wfMessage( 'copyrightpage' 
)->inContentLanguage()->text(), '/' ) .
-                               '/',
-                               array(
-                                       'tag' => 'a',
-                                       'attributes' => array(
-                                               'href' => 
'https://creativecommons.org'
-                                       ),
-                                       'content' => 'Creative Commons 
Attribution-Share Alike 3.0'
-                               ),
-                               'https://creativecommons.org',
-                               'Creative Commons Attribution-Share Alike 3.0'
+                               '<div>(wikibase-shortcopyrightwarning: 
wikibase-save, copyrightpage, copyrightlink)</div>',
+                               $message,
+                               'qqx'
                        )
                );
        }

-- 
To view, visit https://gerrit.wikimedia.org/r/155535
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I60c0b201807b05d2b4e5847bfe4ccaed204cb86b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>

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

Reply via email to