Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/260360
Change subject: Do not mock trivial RequestContext value object
......................................................................
Do not mock trivial RequestContext value object
This class does not even have a constructor. It's a super trivial
value object, isn't it?
Change-Id: I6cc3f8672af7f1eea29789100ff17c7a2193880e
---
M repo/tests/phpunit/includes/api/EntitySavingHelperTest.php
M repo/tests/phpunit/includes/api/MergeItemsTest.php
2 files changed, 10 insertions(+), 14 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/60/260360/1
diff --git a/repo/tests/phpunit/includes/api/EntitySavingHelperTest.php
b/repo/tests/phpunit/includes/api/EntitySavingHelperTest.php
index 373f3a5..91760a2 100644
--- a/repo/tests/phpunit/includes/api/EntitySavingHelperTest.php
+++ b/repo/tests/phpunit/includes/api/EntitySavingHelperTest.php
@@ -2,6 +2,7 @@
namespace Wikibase\Test\Repo\Api;
+use RequestContext;
use Status;
use Wikibase\DataModel\Entity\Item;
use Wikibase\DataModel\Entity\ItemId;
@@ -60,29 +61,24 @@
return $mock;
}
- private function getMockContext() {
- return $this->getMock( 'RequestContext' );
- }
-
- private function getMockUser() {
- return $this->getMockBuilder( 'User' )
+ private function newContext() {
+ $user = $this->getMockBuilder( 'User' )
->disableOriginalConstructor()
->getMock();
+
+ $context = new RequestContext();
+ $context->setUser( $user );
+ return $context;
}
public function testAttemptSave() {
- $mockContext = $this->getMockContext();
- $mockContext->expects( $this->once() )
- ->method( 'getUser' )
- ->will( $this->returnValue( $this->getMockUser() ) );
-
$mockApiBase = $this->getMockApiBase();
$mockApiBase->expects( $this->once() )
->method( 'isWriteMode' )
->will( $this->returnValue( true ) );
$mockApiBase->expects( $this->atLeastOnce() )
->method( 'getContext' )
- ->will( $this->returnValue( $mockContext ) );
+ ->will( $this->returnValue( $this->newContext() ) );
$mockApiBase->expects( $this->atLeastOnce() )
->method( 'extractRequestParams' )
->will( $this->returnValue( array() ) );
diff --git a/repo/tests/phpunit/includes/api/MergeItemsTest.php
b/repo/tests/phpunit/includes/api/MergeItemsTest.php
index 4940e3e..9f09848 100644
--- a/repo/tests/phpunit/includes/api/MergeItemsTest.php
+++ b/repo/tests/phpunit/includes/api/MergeItemsTest.php
@@ -3,6 +3,7 @@
namespace Wikibase\Test\Repo\Api;
use Language;
+use RequestContext;
use Status;
use TestSites;
use UsageException;
@@ -135,8 +136,7 @@
Language::factory( 'en' )
);
- $mockContext = $this->getMock( 'RequestContext' );
- $apiHelperFactory = $wikibaseRepo->getApiHelperFactory(
$mockContext );
+ $apiHelperFactory = $wikibaseRepo->getApiHelperFactory( new
RequestContext() );
$resultBuilder = $apiHelperFactory->getResultBuilder( $module );
--
To view, visit https://gerrit.wikimedia.org/r/260360
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6cc3f8672af7f1eea29789100ff17c7a2193880e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits