* @group Database
*/
class MovePageTest extends MediaWikiTestCase {
- /**
- * @param string $class
- * @return object A mock that throws on any method call
- */
- private function getNoOpMock( $class ) {
- $mock = $this->createMock( $class );
- $mock->expects( $this->never() )->method( $this->anythingBut( '__destruct' ) );
- return $mock;
- }
-
/**
* The only files that exist are 'File:Existent.jpg', 'File:Existent2.jpg', and
* 'File:Existent-file-no-page.jpg'. Calling unexpected methods causes a test failure.
private function newMovePage( $old, $new, array $params = [] ) : MovePage {
$mockLB = $this->createMock( LoadBalancer::class );
$mockLB->method( 'getConnection' )
- ->willReturn( $params['db'] ?? $this->getNoOpMock( IDatabase::class ) );
+ ->willReturn( $params['db'] ?? $this->createNoOpMock( IDatabase::class ) );
$mockLB->expects( $this->never() )
->method( $this->anythingBut( 'getConnection', '__destruct' ) );
),
$mockLB,
$params['nsInfo'] ?? $mockNsInfo,
- $params['wiStore'] ?? $this->getNoOpMock( WatchedItemStore::class ),
- $params['permMgr'] ?? $this->getNoOpMock( PermissionManager::class ),
+ $params['wiStore'] ?? $this->createNoOpMock( WatchedItemStore::class ),
+ $params['permMgr'] ?? $this->createNoOpMock( PermissionManager::class ),
$params['repoGroup'] ?? $this->getMockRepoGroup()
);
}
new WatchedItem( $user, $targets[0], '20151212010101' ),
new WatchedItem( $user, $targets[1], null ),
];
- $mockDb = $this->getMockDb();
- $mockDb->expects( $this->never() )->method( $this->anything() );
+ $mockDb = $this->createNoOpMock( IDatabase::class );
$mockCache = $this->getMockCache();
$mockCache->expects( $this->at( 1 ) )
}
public function testGetNotificationTimestampsBatch_anonymousUser() {
+ if ( defined( 'HHVM_VERSION' ) ) {
+ $this->markTestSkipped( 'HHVM Reflection buggy' );
+ }
+
$targets = [
new TitleValue( 0, 'SomeDbKey' ),
new TitleValue( 1, 'AnotherDbKey' ),
];
- $mockDb = $this->getMockDb();
- $mockDb->expects( $this->never() )->method( $this->anything() );
+ $mockDb = $this->createNoOpMock( IDatabase::class );
- $mockCache = $this->getMockCache();
- $mockCache->expects( $this->never() )->method( $this->anything() );
+ $mockCache = $this->createNoOpMock( HashBagOStuff::class );
$store = $this->newWatchedItemStore( [ 'db' => $mockDb, 'cache' => $mockCache ] );
$mockQueueGroup = $this->getMockJobQueueGroup();
- $mockRevisionRecord = $this->createMock( RevisionRecord::class );
- $mockRevisionRecord->expects( $this->never() )->method( $this->anything() );
+ $mockRevisionRecord = $this->createNoOpMock( RevisionRecord::class );
$mockRevisionLookup = $this->getMockRevisionLookup( [
'getTimestampFromId' => function () {
$oldid = 22;
$title = new TitleValue( 0, 'SomeDbKey' );
- $mockRevision = $this->createMock( RevisionRecord::class );
- $mockRevision->expects( $this->never() )->method( $this->anything() );
-
- $mockNextRevision = $this->createMock( RevisionRecord::class );
- $mockNextRevision->expects( $this->never() )->method( $this->anything() );
+ $mockRevision = $this->createNoOpMock( RevisionRecord::class );
+ $mockNextRevision = $this->createNoOpMock( RevisionRecord::class );
$mockDb = $this->getMockDb();
$mockDb->expects( $this->once() )
$mockQueueGroup = $this->getMockJobQueueGroup();
- $mockRevision = $this->createMock( RevisionRecord::class );
- $mockRevision->expects( $this->never() )->method( $this->anything() );
-
- $mockNextRevision = $this->createMock( RevisionRecord::class );
- $mockNextRevision->expects( $this->never() )->method( $this->anything() );
+ $mockRevision = $this->createNoOpMock( RevisionRecord::class );
+ $mockNextRevision = $this->createNoOpMock( RevisionRecord::class );
$mockRevisionLookup = $this->getMockRevisionLookup(
[
$mockQueueGroup = $this->getMockJobQueueGroup();
- $mockRevision = $this->createMock( RevisionRecord::class );
- $mockRevision->expects( $this->never() )->method( $this->anything() );
-
- $mockNextRevision = $this->createMock( RevisionRecord::class );
- $mockNextRevision->expects( $this->never() )->method( $this->anything() );
+ $mockRevision = $this->createNoOpMock( RevisionRecord::class );
+ $mockNextRevision = $this->createNoOpMock( RevisionRecord::class );
$mockRevisionLookup = $this->getMockRevisionLookup(
[
$mockQueueGroup = $this->getMockJobQueueGroup();
- $mockRevision = $this->createMock( RevisionRecord::class );
- $mockRevision->expects( $this->never() )->method( $this->anything() );
-
- $mockNextRevision = $this->createMock( RevisionRecord::class );
- $mockNextRevision->expects( $this->never() )->method( $this->anything() );
+ $mockRevision = $this->createNoOpMock( RevisionRecord::class );
+ $mockNextRevision = $this->createNoOpMock( RevisionRecord::class );
$mockRevisionLookup = $this->getMockRevisionLookup(
[