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

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(-)

Approvals:
  Aude: Looks good to me, approved
  jenkins-bot: Verified



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: merged
Gerrit-Change-Id: I6cc3f8672af7f1eea29789100ff17c7a2193880e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Hoo man <[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