Gergő Tisza has uploaded a new change for review.
https://gerrit.wikimedia.org/r/275699
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageImages
refs/changes/99/275699/1
diff --git a/tests/phpunit/LinksUpdateHookHandlerTest.php
b/tests/phpunit/LinksUpdateHookHandlerTest.php
index 40bda08..39c4633 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( false ) );
+
+ $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: newchange
Gerrit-Change-Id: I840902c8397c8442def8239504ce1cfa8eafbb8e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageImages
Gerrit-Branch: master
Gerrit-Owner: Gergő Tisza <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits