aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/unit/includes/api
diff options
context:
space:
mode:
authorThiemo Kreuz <thiemo.kreuz@wikimedia.de>2021-04-22 09:56:11 +0200
committerThiemo Kreuz <thiemo.kreuz@wikimedia.de>2021-04-23 12:02:42 +0200
commitc1ee8250e9bc9c9c3161ca0ded3946fd2af1da7d (patch)
treeed0c960ea070ecc91b10bf708b70977f84080420 /tests/phpunit/unit/includes/api
parent74653506a88de1bdadbc927b201f9ac6967fab5f (diff)
downloadmediawikicore-c1ee8250e9bc9c9c3161ca0ded3946fd2af1da7d.tar.gz
mediawikicore-c1ee8250e9bc9c9c3161ca0ded3946fd2af1da7d.zip
Remove unnecessary ->equalTo() from tests
This is the default anyway when using ->with(). The test code becomes so much more readable without this, I would like to argue. Let it just say "with these values". Because of the way I split my changes into multiple patches there are a few other changes in this patch I could not split, e.g. removing unnecessary ->any(). This is the default anyway and doesn't make the test more specific. Change-Id: I34990799fa9258ba8dc64c7e78ec43f7903b7681
Diffstat (limited to 'tests/phpunit/unit/includes/api')
-rw-r--r--tests/phpunit/unit/includes/api/ApiUnblockTest.php53
1 files changed, 13 insertions, 40 deletions
diff --git a/tests/phpunit/unit/includes/api/ApiUnblockTest.php b/tests/phpunit/unit/includes/api/ApiUnblockTest.php
index e78240f08763..6e1cf58270a2 100644
--- a/tests/phpunit/unit/includes/api/ApiUnblockTest.php
+++ b/tests/phpunit/unit/includes/api/ApiUnblockTest.php
@@ -86,10 +86,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$blockPermissionCheckerFactory = $this->createMock( BlockPermissionCheckerFactory::class );
$blockPermissionCheckerFactory->expects( $this->once() )
->method( 'newBlockPermissionChecker' )
- ->with(
- $this->equalTo( $target ),
- $this->equalTo( $performer )
- )
+ ->with( $target, $performer )
->willReturn( $blockPermissionChecker );
return $blockPermissionCheckerFactory;
@@ -105,12 +102,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$unblockUserFactory = $this->createMock( UnblockUserFactory::class );
$unblockUserFactory->expects( $this->once() )
->method( 'newUnblockUser' )
- ->with(
- $this->equalTo( $target ),
- $this->equalTo( $performer ),
- $this->equalTo( $reason ),
- $this->equalTo( $tags )
- )
+ ->with( $target, $performer, $reason, $tags )
->willReturn( $unblockUser );
return $unblockUserFactory;
@@ -148,12 +140,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$testException = new Exception( 'Error should be thrown in requireOnlyOneParameter' );
$apiUnblock->method( 'requireOnlyOneParameter' )
- ->with(
- $this->equalTo( $requestParams ),
- $this->equalTo( 'id' ),
- $this->equalTo( 'user' ),
- $this->equalTo( 'userid' )
- )
+ ->with( $requestParams, 'id', 'user', 'userid' )
->will( $this->throwException( $testException ) );
$this->expectException( Exception::class );
@@ -168,9 +155,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$args['performer']->expects( $this->once() )
->method( 'isAllowed' )
- ->with(
- $this->equalTo( 'block' )
- )
+ ->with( 'block' )
->willReturn( false );
$requestParams = [ 'actual contents are not used in this test' ];
@@ -184,10 +169,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$testException = new Exception( 'Error should be thrown in dieWithError' );
$apiUnblock->method( 'dieWithError' )
- ->with(
- $this->equalTo( 'apierror-permissiondenied-unblock' ),
- $this->equalTo( 'permissiondenied' )
- )
+ ->with( 'apierror-permissiondenied-unblock', 'permissiondenied' )
->will( $this->throwException( $testException ) );
$this->expectException( Exception::class );
@@ -203,10 +185,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$args['userCache']->expects( $this->once() )
->method( 'getProp' )
- ->with(
- $this->equalTo( 'userIdGoesHere' ),
- $this->equalTo( 'name' )
- )
+ ->with( 'userIdGoesHere', 'name' )
->willReturn( false );
$requestParams = [ 'userid' => 'userIdGoesHere' ];
@@ -220,10 +199,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$testException = new Exception( 'Error should be thrown in dieWithError' );
$apiUnblock->method( 'dieWithError' )
- ->with(
- $this->equalTo( [ 'apierror-nosuchuserid', 'userIdGoesHere' ] ),
- $this->equalTo( 'nosuchuserid' )
- )
+ ->with( [ 'apierror-nosuchuserid', 'userIdGoesHere' ], 'nosuchuserid' )
->will( $this->throwException( $testException ) );
$this->expectException( Exception::class );
@@ -252,10 +228,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
// Also includes the test of the codepath where UserCache is used and works
$args['userCache']->expects( $this->once() )
->method( 'getProp' )
- ->with(
- $this->equalTo( 'userIdGoesHere' ),
- $this->equalTo( 'name' )
- )
+ ->with( 'userIdGoesHere', 'name' )
->willReturn( 'userNameOfTargetFromCache' );
$badStatus = Status::newFatal( 'bad status' );
@@ -283,7 +256,7 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$testException = new Exception( 'Error should be thrown in dieStatus' );
$apiUnblock->method( 'dieStatus' )
- ->with( $this->equalTo( $badStatus ) )
+ ->with( $badStatus )
->will( $this->throwException( $testException ) );
$this->expectException( Exception::class );
@@ -300,14 +273,14 @@ class ApiUnblockTest extends MediaWikiUnitTestCase {
$apiResult->expects( $this->once() )
->method( 'addValue' )
->with(
- $this->equalTo( null ),
- $this->equalTo( $args['action'] ),
- $this->equalTo( [
+ null,
+ $args['action'],
+ [
'id' => 678, // block id
'user' => 'targetNameGoesHere', // target name
'userid' => 123, // target user id
'reason' => 'reasonGoesHere', // reason in $requestParams
- ] )
+ ]
)
->willReturn( true );
$args['apiMain']->method( 'getResult' )->willReturn( $apiResult );