jenkins-bot has submitted this change and it was merged.

Change subject: Add sanity check test for LinksUpdateHookHandler::getMetadata
......................................................................


Add sanity check test for LinksUpdateHookHandler::getMetadata

Change-Id: I840902c8397c8442def8239504ce1cfa8eafbb8e
---
M tests/phpunit/LinksUpdateHookHandlerTest.php
1 file changed, 39 insertions(+), 0 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  Thiemo Mättig (WMDE): Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/tests/phpunit/LinksUpdateHookHandlerTest.php 
b/tests/phpunit/LinksUpdateHookHandlerTest.php
index 40bda08..e25e8bd 100644
--- a/tests/phpunit/LinksUpdateHookHandlerTest.php
+++ b/tests/phpunit/LinksUpdateHookHandlerTest.php
@@ -6,6 +6,7 @@
 use PageImages;
 use ParserOutput;
 use PHPUnit_Framework_TestCase;
+use RepoGroup;
 
 /**
  * @covers PageImages\Hooks\LinksUpdateHookHandler
@@ -16,6 +17,12 @@
  * @author Thiemo Mättig
  */
 class LinksUpdateHookHandlerTest extends PHPUnit_Framework_TestCase {
+
+       public function tearDown() {
+               // remove mock added in testGetMetadata()
+               RepoGroup::destroySingleton();
+               parent::tearDown();
+       }
 
        public function testOnLinksUpdate() {
                $parserOutput = new ParserOutput();
@@ -35,4 +42,36 @@
                $this->assertSame( 'A.jpg', 
$linksUpdate->mProperties[PageImages::PROP_NAME] );
        }
 
+       public function testGetMetadata() {
+               $file = $this->getMockBuilder( 'File' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               // ugly hack to avoid all the unmockable crap in FormatMetadata
+               $file->expects( $this->any() )
+                       ->method( 'isDeleted' )
+                       ->will( $this->returnValue( true ) );
+
+               $mockRepoGroup = $this->getMockBuilder( 'RepoGroup' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $mockRepoGroup->expects( $this->any() )
+                       ->method( 'findFile' )
+                       ->will( $this->returnValue( $file ) );
+               RepoGroup::setSingleton( $mockRepoGroup );
+
+               $parserOutput = new ParserOutput();
+               $parserOutput->setExtensionData( 'pageImages', array(
+                       array( 'filename' => 'A.jpg', 'fullwidth' => 100, 
'fullheight' => 50 ),
+               ) );
+
+               $linksUpdate = $this->getMockBuilder( 'LinksUpdate' )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $linksUpdate->expects( $this->any() )
+                       ->method( 'getParserOutput' )
+                       ->will( $this->returnValue( $parserOutput ) );
+
+               LinksUpdateHookHandler::onLinksUpdate( $linksUpdate );
+               $this->assertTrue( true, 'no errors in getMetadata' );
+       }
 }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I840902c8397c8442def8239504ce1cfa8eafbb8e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/PageImages
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Gergő Tisza <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to