Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/321863
Change subject: Fix test stubbing
......................................................................
Fix test stubbing
* Mock the class we're testing
* Only stub fetchFileMetadata method
* The stub's isImageFree method will now run the actual code within
the method called
* The method isImageFree is made public (note if you don't want to do
a bit more work is needed)
Change-Id: I8116103e850c7d10c1ccd29cc3561fce72006c7b
---
M includes/ApiQueryPageImages.php
M includes/LinksUpdateHookHandler.php
M tests/phpunit/LinksUpdateHookHandlerTest.php
3 files changed, 4 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageImages
refs/changes/63/321863/1
diff --git a/includes/ApiQueryPageImages.php b/includes/ApiQueryPageImages.php
index bd46cf2..9bcdbdd 100644
--- a/includes/ApiQueryPageImages.php
+++ b/includes/ApiQueryPageImages.php
@@ -143,7 +143,7 @@
/**
* Get property names used in page_props table
- *
+ *
* If the license is free, then only the free property name will be
returned,
* otherwise both free and non-free property names will be returned.
That's
* because we save the image name only once if it's free and the best
image.
diff --git a/includes/LinksUpdateHookHandler.php
b/includes/LinksUpdateHookHandler.php
index 6cb3971..58b3021 100644
--- a/includes/LinksUpdateHookHandler.php
+++ b/includes/LinksUpdateHookHandler.php
@@ -142,7 +142,7 @@
* @param string $fileName Name of the image file
* @return bool
*/
- protected function isImageFree( $fileName ) {
+ public function isImageFree( $fileName ) {
$file = wfFindFile( $fileName );
if ( $file ) {
// Process copyright metadata from CommonsMetadata, if
present.
@@ -154,7 +154,7 @@
/**
* Fetch file metadata
- *
+ *
* @param File $file
* @return array
*/
diff --git a/tests/phpunit/LinksUpdateHookHandlerTest.php
b/tests/phpunit/LinksUpdateHookHandlerTest.php
index 1b3ef72..6b1c4fd 100644
--- a/tests/phpunit/LinksUpdateHookHandlerTest.php
+++ b/tests/phpunit/LinksUpdateHookHandlerTest.php
@@ -9,12 +9,6 @@
use PHPUnit_Framework_TestCase;
use RepoGroup;
-class LinksUpdateHookHandlerProxy extends LinksUpdateHookHandler {
- /** inheritdoc */
- public function isImageFree( $fileName ) {
- return parent::isImageFree( $fileName );
- }
-}
/**
* @covers PageImages\Hooks\LinksUpdateHookHandler
*
@@ -98,7 +92,7 @@
*/
public function testIsFreeImage( $fileName, $metadata, $expected ) {
RepoGroup::setSingleton( $this->getRepoGroup() );
- $mock = $this->getMockBuilder( 'LinksUpdateHookHandlerProxy' )
+ $mock = $this->getMockBuilder(
'PageImages\Hooks\LinksUpdateHookHandler' )
->setMethods( ['fetchFileMetadata'] )
->getMock();
$mock->expects( $this->any() )
--
To view, visit https://gerrit.wikimedia.org/r/321863
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8116103e850c7d10c1ccd29cc3561fce72006c7b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageImages
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits