Merge "Remove some meaningless $this->equalTo() from tests"
This commit is contained in:
commit
29604272e8
8 changed files with 76 additions and 105 deletions
|
|
@ -514,14 +514,14 @@ class RevisionTest extends MediaWikiIntegrationTestCase {
|
|||
$db->expects( $this->once() )
|
||||
->method( 'selectRow' )
|
||||
->with(
|
||||
$this->equalTo( [
|
||||
[
|
||||
'revision', 'page', 'user',
|
||||
'temp_rev_comment' => 'revision_comment_temp', 'comment_rev_comment' => 'comment',
|
||||
'temp_rev_user' => 'revision_actor_temp', 'actor_rev_user' => 'actor',
|
||||
] ),
|
||||
],
|
||||
// We don't really care about the fields are they come from the selectField methods
|
||||
$this->isType( 'array' ),
|
||||
$this->equalTo( $conditions ),
|
||||
$conditions,
|
||||
// Method name
|
||||
$this->stringContains( 'fetchRevisionRowFromConds' ),
|
||||
// We don't really care about the options here
|
||||
|
|
|
|||
|
|
@ -211,8 +211,8 @@ class DefaultPreferencesFactoryTest extends \MediaWikiIntegrationTestCase {
|
|||
$userMock->expects( $this->exactly( 2 ) )
|
||||
->method( 'setOption' )
|
||||
->withConsecutive(
|
||||
[ $this->equalTo( 'test' ), $this->equalTo( $newOptions[ 'test' ] ) ],
|
||||
[ $this->equalTo( 'option' ), $this->equalTo( $newOptions[ 'option' ] ) ]
|
||||
[ 'test', $newOptions[ 'test' ] ],
|
||||
[ 'option', $newOptions[ 'option' ] ]
|
||||
);
|
||||
|
||||
$form->method( 'getModifiedUser' )
|
||||
|
|
|
|||
|
|
@ -68,9 +68,9 @@ class CentralIdLookupTest extends MediaWikiIntegrationTestCase {
|
|||
$mock = $this->getMockForAbstractClass( CentralIdLookup::class );
|
||||
$mock->expects( $this->once() )->method( 'lookupCentralIds' )
|
||||
->with(
|
||||
$this->equalTo( [ 15 => null ] ),
|
||||
$this->equalTo( CentralIdLookup::AUDIENCE_RAW ),
|
||||
$this->equalTo( CentralIdLookup::READ_LATEST )
|
||||
[ 15 => null ],
|
||||
CentralIdLookup::AUDIENCE_RAW,
|
||||
CentralIdLookup::READ_LATEST
|
||||
)
|
||||
->will( $this->returnValue( [ 15 => 'FooBar' ] ) );
|
||||
|
||||
|
|
@ -91,9 +91,9 @@ class CentralIdLookupTest extends MediaWikiIntegrationTestCase {
|
|||
->will( $this->returnValue( true ) );
|
||||
$mock->expects( $this->once() )->method( 'lookupCentralIds' )
|
||||
->with(
|
||||
$this->equalTo( [ 42 => null ] ),
|
||||
$this->equalTo( CentralIdLookup::AUDIENCE_RAW ),
|
||||
$this->equalTo( CentralIdLookup::READ_LATEST )
|
||||
[ 42 => null ],
|
||||
CentralIdLookup::AUDIENCE_RAW,
|
||||
CentralIdLookup::READ_LATEST
|
||||
)
|
||||
->will( $this->returnValue( [ 42 => $name ] ) );
|
||||
|
||||
|
|
@ -112,9 +112,9 @@ class CentralIdLookupTest extends MediaWikiIntegrationTestCase {
|
|||
->will( $this->returnValue( false ) );
|
||||
$mock->expects( $this->once() )->method( 'lookupCentralIds' )
|
||||
->with(
|
||||
$this->equalTo( [ 42 => null ] ),
|
||||
$this->equalTo( CentralIdLookup::AUDIENCE_RAW ),
|
||||
$this->equalTo( CentralIdLookup::READ_LATEST )
|
||||
[ 42 => null ],
|
||||
CentralIdLookup::AUDIENCE_RAW,
|
||||
CentralIdLookup::READ_LATEST
|
||||
)
|
||||
->will( $this->returnValue( [ 42 => $name ] ) );
|
||||
$this->assertNull(
|
||||
|
|
@ -136,9 +136,9 @@ class CentralIdLookupTest extends MediaWikiIntegrationTestCase {
|
|||
$mock = $this->getMockForAbstractClass( CentralIdLookup::class );
|
||||
$mock->expects( $this->once() )->method( 'lookupUserNames' )
|
||||
->with(
|
||||
$this->equalTo( [ 'FooBar' => 0 ] ),
|
||||
$this->equalTo( CentralIdLookup::AUDIENCE_RAW ),
|
||||
$this->equalTo( CentralIdLookup::READ_LATEST )
|
||||
[ 'FooBar' => 0 ],
|
||||
CentralIdLookup::AUDIENCE_RAW,
|
||||
CentralIdLookup::READ_LATEST
|
||||
)
|
||||
->will( $this->returnValue( [ 'FooBar' => 23 ] ) );
|
||||
|
||||
|
|
@ -154,9 +154,9 @@ class CentralIdLookupTest extends MediaWikiIntegrationTestCase {
|
|||
->will( $this->returnValue( true ) );
|
||||
$mock->expects( $this->once() )->method( 'lookupUserNames' )
|
||||
->with(
|
||||
$this->equalTo( [ 'FooBar' => 0 ] ),
|
||||
$this->equalTo( CentralIdLookup::AUDIENCE_RAW ),
|
||||
$this->equalTo( CentralIdLookup::READ_LATEST )
|
||||
[ 'FooBar' => 0 ],
|
||||
CentralIdLookup::AUDIENCE_RAW,
|
||||
CentralIdLookup::READ_LATEST
|
||||
)
|
||||
->will( $this->returnValue( [ 'FooBar' => 23 ] ) );
|
||||
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ class RevisionListTest extends MediaWikiIntegrationTestCase {
|
|||
$db->expects( $this->once() )
|
||||
->method( 'select' )
|
||||
->with(
|
||||
$this->equalTo( $revQuery['tables'] ),
|
||||
$this->equalTo( $revQuery['fields'] ),
|
||||
$this->equalTo( $conds ),
|
||||
$this->equalTo( 'RevisionList::doQuery' ),
|
||||
$this->equalTo( [ 'ORDER BY' => 'rev_id DESC' ] ),
|
||||
$this->equalTo( $revQuery['joins'] )
|
||||
$revQuery['tables'],
|
||||
$revQuery['fields'],
|
||||
$conds,
|
||||
'RevisionList::doQuery',
|
||||
[ 'ORDER BY' => 'rev_id DESC' ],
|
||||
$revQuery['joins']
|
||||
)
|
||||
->willReturn(
|
||||
new FakeResultWrapper( [] )
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class EditFilterMergedContentHookConstraintTest extends MediaWikiUnitTestCase {
|
|||
$hookContainer->expects( $this->once() )
|
||||
->method( 'run' )
|
||||
->with(
|
||||
$this->equalTo( 'EditFilterMergedContent' ),
|
||||
'EditFilterMergedContent',
|
||||
$this->anything() // Not worrying about the hook call here
|
||||
)
|
||||
->willReturn( $hookResult );
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ class UserBlockConstraintTest extends MediaWikiUnitTestCase {
|
|||
$permissionManager->expects( $this->once() )
|
||||
->method( 'isBlockedFrom' )
|
||||
->with(
|
||||
$this->equalTo( $user ),
|
||||
$this->equalTo( $title )
|
||||
$user,
|
||||
$title
|
||||
)
|
||||
->willReturn( false );
|
||||
|
||||
|
|
@ -55,8 +55,8 @@ class UserBlockConstraintTest extends MediaWikiUnitTestCase {
|
|||
$permissionManager->expects( $this->once() )
|
||||
->method( 'isBlockedFrom' )
|
||||
->with(
|
||||
$this->equalTo( $user ),
|
||||
$this->equalTo( $title )
|
||||
$user,
|
||||
$title
|
||||
)
|
||||
->willReturn( true );
|
||||
|
||||
|
|
|
|||
|
|
@ -41,18 +41,9 @@ class UserRateLimitConstraintTest extends MediaWikiUnitTestCase {
|
|||
$user->expects( $this->exactly( 3 ) )
|
||||
->method( 'pingLimiter' )
|
||||
->withConsecutive(
|
||||
[
|
||||
$this->equalTo( 'edit' ),
|
||||
$this->equalTo( 1 ),
|
||||
],
|
||||
[
|
||||
$this->equalTo( 'linkpurge' ),
|
||||
$this->equalTo( 0 ),
|
||||
],
|
||||
[
|
||||
$this->equalTo( 'editcontentmodel' ),
|
||||
$this->equalTo( 1 )
|
||||
]
|
||||
[ 'edit', 1 ],
|
||||
[ 'linkpurge', 0 ],
|
||||
[ 'editcontentmodel', 1 ]
|
||||
)
|
||||
->will(
|
||||
$this->onConsecutiveCalls(
|
||||
|
|
@ -81,18 +72,9 @@ class UserRateLimitConstraintTest extends MediaWikiUnitTestCase {
|
|||
$user->expects( $this->exactly( 3 ) )
|
||||
->method( 'pingLimiter' )
|
||||
->withConsecutive(
|
||||
[
|
||||
$this->equalTo( 'edit' ),
|
||||
$this->equalTo( 1 ),
|
||||
],
|
||||
[
|
||||
$this->equalTo( 'linkpurge' ),
|
||||
$this->equalTo( 0 ),
|
||||
],
|
||||
[
|
||||
$this->equalTo( 'editcontentmodel' ),
|
||||
$this->equalTo( 1 )
|
||||
]
|
||||
[ 'edit', 1 ],
|
||||
[ 'linkpurge', 0 ],
|
||||
[ 'editcontentmodel', 1 ]
|
||||
)
|
||||
->will(
|
||||
$this->onConsecutiveCalls(
|
||||
|
|
|
|||
|
|
@ -37,10 +37,10 @@ class UserEditTrackerTest extends MediaWikiUnitTestCase {
|
|||
$database->expects( $this->once() )
|
||||
->method( 'selectField' )
|
||||
->with(
|
||||
$this->equalTo( 'user' ),
|
||||
$this->equalTo( 'user_editcount' ),
|
||||
$this->equalTo( [ 'user_id' => $userId ] ),
|
||||
$this->equalTo( $methodName )
|
||||
'user',
|
||||
'user_editcount',
|
||||
[ 'user_id' => $userId ],
|
||||
$methodName
|
||||
)
|
||||
->willReturn( $editCount );
|
||||
$loadBalancer = $this->createMock( LoadBalancer::class );
|
||||
|
|
@ -99,10 +99,10 @@ class UserEditTrackerTest extends MediaWikiUnitTestCase {
|
|||
$database1->expects( $this->once() )
|
||||
->method( 'selectField' )
|
||||
->with(
|
||||
$this->equalTo( 'user' ),
|
||||
$this->equalTo( 'user_editcount' ),
|
||||
$this->equalTo( [ 'user_id' => $userId ] ),
|
||||
$this->equalTo( $methodName1 )
|
||||
'user',
|
||||
'user_editcount',
|
||||
[ 'user_id' => $userId ],
|
||||
$methodName1
|
||||
)
|
||||
->willReturn( null );
|
||||
|
||||
|
|
@ -110,17 +110,12 @@ class UserEditTrackerTest extends MediaWikiUnitTestCase {
|
|||
$database2->expects( $this->once() )
|
||||
->method( 'selectField' )
|
||||
->with(
|
||||
$this->equalTo( [
|
||||
'revision',
|
||||
'temp_rev_user' => 'revision_actor_temp'
|
||||
] ),
|
||||
$this->equalTo( 'COUNT(*)' ),
|
||||
$this->equalTo( [ [ 'temp_rev_actor.revactor_actor' => $actorId ] ] ),
|
||||
$this->equalTo( $methodName2 ),
|
||||
$this->equalTo( [] ),
|
||||
$this->equalTo( [ 'temp_rev_actor' =>
|
||||
[ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ]
|
||||
] )
|
||||
[ 'revision', 'temp_rev_user' => 'revision_actor_temp' ],
|
||||
'COUNT(*)',
|
||||
[ [ 'temp_rev_actor.revactor_actor' => $actorId ] ],
|
||||
$methodName2,
|
||||
[],
|
||||
[ 'temp_rev_actor' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ] ]
|
||||
)
|
||||
->willReturn( $editCount );
|
||||
|
||||
|
|
@ -141,9 +136,9 @@ class UserEditTrackerTest extends MediaWikiUnitTestCase {
|
|||
$actorMigration->expects( $this->once() )
|
||||
->method( 'getWhere' )
|
||||
->with(
|
||||
$this->equalTo( $database2 ),
|
||||
$this->equalTo( 'rev_user' ),
|
||||
$this->equalTo( $user )
|
||||
$database2,
|
||||
'rev_user',
|
||||
$user
|
||||
)
|
||||
->willReturn( [
|
||||
'tables' => [ 'temp_rev_user' => 'revision_actor_temp' ],
|
||||
|
|
@ -185,32 +180,26 @@ class UserEditTrackerTest extends MediaWikiUnitTestCase {
|
|||
$database1->expects( $this->once() )
|
||||
->method( 'selectField' )
|
||||
->with(
|
||||
$this->equalTo( [
|
||||
'revision',
|
||||
'temp_rev_user' => 'revision_actor_temp'
|
||||
] ),
|
||||
$this->equalTo( 'COUNT(*)' ),
|
||||
$this->equalTo( [ [ 'temp_rev_actor.revactor_actor' => $actorId ] ] ),
|
||||
$this->equalTo( $methodName ),
|
||||
$this->equalTo( [] ),
|
||||
$this->equalTo( [ 'temp_rev_actor' =>
|
||||
[ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ]
|
||||
] )
|
||||
[ 'revision', 'temp_rev_user' => 'revision_actor_temp' ],
|
||||
'COUNT(*)',
|
||||
[ [ 'temp_rev_actor.revactor_actor' => $actorId ] ],
|
||||
$methodName,
|
||||
[],
|
||||
[ 'temp_rev_actor' => [ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ] ]
|
||||
)
|
||||
->willReturn( $editCount );
|
||||
|
||||
$loadBalancer = $this->createMock( LoadBalancer::class );
|
||||
$loadBalancer->expects( $this->any() )
|
||||
->method( 'getConnectionRef' )
|
||||
$loadBalancer->method( 'getConnectionRef' )
|
||||
->with( DB_REPLICA )
|
||||
->willReturn( $database1 );
|
||||
$actorMigration = $this->createMock( ActorMigration::class );
|
||||
$actorMigration->expects( $this->once() )
|
||||
->method( 'getWhere' )
|
||||
->with(
|
||||
$this->equalTo( $database1 ),
|
||||
$this->equalTo( 'rev_user' ),
|
||||
$this->equalTo( $user )
|
||||
$database1,
|
||||
'rev_user',
|
||||
$user
|
||||
)
|
||||
->willReturn( [
|
||||
'tables' => [ 'temp_rev_user' => 'revision_actor_temp' ],
|
||||
|
|
@ -257,19 +246,19 @@ class UserEditTrackerTest extends MediaWikiUnitTestCase {
|
|||
$database->expects( $this->once() )
|
||||
->method( 'selectField' )
|
||||
->with(
|
||||
$this->equalTo( [
|
||||
[
|
||||
'revision',
|
||||
'temp_rev_user' => 'revision_actor_temp'
|
||||
] ),
|
||||
$this->equalTo( 'revactor_timestamp' ),
|
||||
$this->equalTo( [ [ 'temp_rev_actor.revactor_actor' => $actorId ] ] ),
|
||||
$this->equalTo( $methodName ),
|
||||
$this->equalTo( [
|
||||
],
|
||||
'revactor_timestamp',
|
||||
[ [ 'temp_rev_actor.revactor_actor' => $actorId ] ],
|
||||
$methodName,
|
||||
[
|
||||
'ORDER BY' => 'revactor_timestamp ' . $expectedSort
|
||||
] ),
|
||||
$this->equalTo( [ 'temp_rev_actor' =>
|
||||
],
|
||||
[ 'temp_rev_actor' =>
|
||||
[ 'JOIN', 'temp_rev_user.revactor_rev = rev_id' ]
|
||||
] )
|
||||
]
|
||||
)
|
||||
->willReturn( $dbTime );
|
||||
$loadBalancer = $this->createMock( LoadBalancer::class );
|
||||
|
|
@ -282,9 +271,9 @@ class UserEditTrackerTest extends MediaWikiUnitTestCase {
|
|||
$actorMigration->expects( $this->once() )
|
||||
->method( 'getWhere' )
|
||||
->with(
|
||||
$this->equalTo( $database ),
|
||||
$this->equalTo( 'rev_user' ),
|
||||
$this->equalTo( $user )
|
||||
$database,
|
||||
'rev_user',
|
||||
$user
|
||||
)
|
||||
->willReturn( [
|
||||
'tables' => [ 'temp_rev_user' => 'revision_actor_temp' ],
|
||||
|
|
|
|||
Loading…
Reference in a new issue