*/
public function insertComment( $rc ) {
if ( $this->isDeleted( $rc, RevisionRecord::DELETED_COMMENT ) ) {
- return ' <span class="history-deleted">' .
+ return ' <span class="history-deleted comment">' .
$this->msg( 'rev-deleted-comment' )->escaped() . '</span>';
} else {
return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle(),
'headers' => array_merge(
$mutableHeaders,
[
- 'content-length' => strlen( $params['content'] ),
'etag' => md5( $params['content'] ),
+ 'content-length' => strlen( $params['content'] ),
'x-object-meta-sha1base36' =>
Wikimedia\base_convert( sha1( $params['content'] ), 16, 36, 31 )
]
return $status;
}
+ // Open a handle to the source file so that it can be streamed. The size and hash
+ // will be computed using the handle. In the off chance that the source file changes
+ // during this operation, the PUT will fail due to an ETag mismatch and be aborted.
AtEase::suppressWarnings();
- $sha1Base16 = sha1_file( $params['src'] );
+ $srcHandle = fopen( $params['src'], 'rb' );
AtEase::restoreWarnings();
- if ( $sha1Base16 === false ) { // source doesn't exist?
- $status->fatal( 'backend-fail-store', $params['src'], $params['dst'] );
+ if ( $srcHandle === false ) { // source doesn't exist?
+ $status->fatal( 'backend-fail-notexists', $params['src'] );
return $status;
}
- $handle = fopen( $params['src'], 'rb' );
- if ( $handle === false ) { // source doesn't exist?
- $status->fatal( 'backend-fail-store', $params['src'], $params['dst'] );
+ // Compute the MD5 and SHA-1 hashes in one pass
+ $srcSize = fstat( $srcHandle )['size'];
+ $md5Context = hash_init( 'md5' );
+ $sha1Context = hash_init( 'sha1' );
+ $hashDigestSize = 0;
+ while ( !feof( $srcHandle ) ) {
+ $buffer = (string)fread( $srcHandle, 131072 ); // 128 KiB
+ hash_update( $md5Context, $buffer );
+ hash_update( $sha1Context, $buffer );
+ $hashDigestSize += strlen( $buffer );
+ }
+ // Reset the handle back to the beginning so that it can be streamed
+ rewind( $srcHandle );
+
+ if ( $hashDigestSize !== $srcSize ) {
+ $status->fatal( 'backend-fail-hash', $params['src'] );
return $status;
}
'headers' => array_merge(
$mutableHeaders,
[
- 'content-length' => fstat( $handle )['size'],
- 'etag' => md5_file( $params['src'] ),
- 'x-object-meta-sha1base36' => Wikimedia\base_convert( $sha1Base16, 16, 36, 31 )
+ 'content-length' => $srcSize,
+ 'etag' => hash_final( $md5Context ),
+ 'x-object-meta-sha1base36' =>
+ Wikimedia\base_convert( hash_final( $sha1Context ), 16, 36, 31 )
]
),
- 'body' => $handle // resource
+ 'body' => $srcHandle // resource
] ];
$method = __METHOD__;
};
$opHandle = new SwiftFileOpHandle( $this, $handler, $reqs );
- $opHandle->resourcesToClose[] = $handle;
+ $opHandle->resourcesToClose[] = $srcHandle;
if ( !empty( $params['async'] ) ) { // deferred
$status->value = $opHandle;
}
}
- $this->assertEquals( '', $bad );
+ $this->assertSame( '', $bad );
}
}
wfGetDB( DB_MASTER )->commit( __METHOD__ );
- $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount(), 'No deferred updates' );
+ $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No deferred updates' );
if ( $expectedCode != EditPage::AS_BLANK_ARTICLE ) {
$latest = $page->getLatest();
public function testGetText() {
$req = new FauxRequest( [ 'x' => 'Value' ] );
$this->assertEquals( 'Value', $req->getText( 'x' ) );
- $this->assertEquals( '', $req->getText( 'z' ) );
+ $this->assertSame( '', $req->getText( 'z' ) );
}
/**
*/
public function testDummies() {
$req = new FauxRequest();
- $this->assertEquals( '', $req->getRawQueryString() );
- $this->assertEquals( '', $req->getRawPostString() );
- $this->assertEquals( '', $req->getRawInput() );
+ $this->assertSame( '', $req->getRawQueryString() );
+ $this->assertSame( '', $req->getRawPostString() );
+ $this->assertSame( '', $req->getRawInput() );
}
}
* @covers Html::expandAttributes
*/
public function testExpandAttributesForBooleans() {
- $this->assertEquals(
+ $this->assertSame(
'',
Html::expandAttributes( [ 'selected' => false ] ),
'Boolean attributes do not generates output when value is false'
);
- $this->assertEquals(
+ $this->assertSame(
'',
Html::expandAttributes( [ 'selected' => null ] ),
'Boolean attributes do not generates output when value is null'
$user = $context->getUser();
$user->setOption( 'showrollbackconfirmation', $rollbackEnabled );
- $this->assertEquals( 0, Title::newFromText( $title )->getArticleID() );
+ $this->assertSame( 0, Title::newFromText( $title )->getArticleID() );
$pageData = $this->insertPage( $title );
$page = WikiPage::factory( $pageData['title'] );
// This should do nothing. In particular, it should not create a service instance.
$services->resetServiceForTesting( 'Test' );
- $this->assertEquals( 0, $serviceCounter, 'No service instance should be created yet.' );
+ $this->assertSame( 0, $serviceCounter, 'No service instance should be created yet.' );
$oldInstance = $services->getService( 'Test' );
$this->assertEquals( 1, $serviceCounter, 'A service instance should exit now.' );
'Some syndication links should be there' );
} else {
$this->assertFalse( $outputPage->isSyndicated(), 'No syndication should be offered' );
- $this->assertEquals( 0, count( $outputPage->getSyndicationLinks() ),
+ $this->assertSame( 0, count( $outputPage->getSyndicationLinks() ),
'No syndication links should be there' );
}
}
);
$jobq->get( 'null' )->delete(); // clear jobqueue
- $this->assertEquals( 0, $jobq->get( 'null' )->getSize(),
+ $this->assertSame( 0, $jobq->get( 'null' )->getSize(),
'Job queue for NullJob has been cleaned' );
$cache->delete( $cache->makeKey( 'SiteStats', 'jobscount' ) );
'jobs count is kept in process cache' );
$cache->clearProcessCache();
- $this->assertEquals( 0, SiteStats::jobs() );
+ $this->assertSame( 0, SiteStats::jobs() );
}
}
$this->db->endAtomic( __METHOD__ ); // run deferred updates
- $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' );
+ $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' );
}
/**
$this->db->endAtomic( __METHOD__ ); // run deferred updates
- $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' );
+ $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount(), 'No pending updates' );
$this->assertNotFalse( $pcache->get( $page, $updater->getCanonicalParserOptions() ) );
}
$title2 = Title::newFromText( 'Foo' );
$this->assertNotSame( $title1, $title2, 'title cache should be empty' );
- $this->assertEquals( 0, $linkCache->getGoodLinkID( 'Foo' ), 'link cache should be empty' );
+ $this->assertSame( 0, $linkCache->getGoodLinkID( 'Foo' ), 'link cache should be empty' );
}
public function provideGetLinkURL() {
$this->assertNull( Xml::expandAttributes( null ),
'Converting a null list of attributes'
);
- $this->assertEquals( '', Xml::expandAttributes( [] ),
+ $this->assertSame( '', Xml::expandAttributes( [] ),
'Converting an empty list of attributes'
);
}
'titles' => 'User:' . implode( '|User:', $userNames ),
] );
- $this->assertEquals( 0, $genderCache->misses,
+ $this->assertSame( 0, $genderCache->misses,
'ApiPageSet does not prefill the gender cache correctly' );
$this->assertEquals( $userNames, array_keys( $genderCache->cache ),
'ApiPageSet does not prefill all users into the gender cache' );
$pages = array_values( $result[0]['query']['pages'] );
$this->assertCount( 1, $pages );
- $this->assertEquals( 0, $pages[0]['ns'] );
+ $this->assertSame( 0, $pages[0]['ns'] );
$this->assertEquals( $this->getPrefixedText( $target ), $pages[0]['title'] );
$this->assertArraySubsetsEqual(
$pages[0]['revisions'],
// $result[0]['query']['pages'] uses page ids as keys
$item = array_values( $result[0]['query']['pages'] )[0];
- $this->assertEquals( 0, $item['ns'] );
+ $this->assertSame( 0, $item['ns'] );
$this->assertEquals( 'ApiQueryWatchlistRawIntegrationTestPage', $item['title'] );
}
unset( $data[0]['query']['watchlist'][$index] );
}
}
- $this->assertEquals( 0, count( $data[0]['query']['watchlist'] ) );
+ $this->assertSame( 0, count( $data[0]['query']['watchlist'] ) );
return $data;
}
}
if ( $created ) {
- $this->assertNotEquals( 0, \User::idFromName( $username ) );
+ $this->assertNotNull( \User::idFromName( $username ) );
} else {
- $this->assertEquals( 0, \User::idFromName( $username ) );
+ $this->assertNull( \User::idFromName( $username ) );
}
$first = false;
$this->assertEquals( $expect, $ret );
$this->assertNotEquals( 0, $user->getId() );
$this->assertSame( 'UTSysop', $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, '{username} already exists locally' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( wfMessage( 'readonlytext', 'Because' ) ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'denied by wfReadOnly(): {reason}' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'test' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'blacklisted in session {sessionid}' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'test2' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'blacklisted in session {sessionid}' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'noname' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username . '@', $user->getId() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'name "{username}" is not creatable' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'authmanager-autocreate-noperm' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'IP lacks the ability to create or autocreate accounts' ],
], $logger->getBuffer() );
unset( $lock );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'usernameinprogress' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'Could not acquire account creation lock' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'fail-in-pre' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'Provider denied creation of {username}: {reason}' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'fail-in-primary' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'Provider denied creation of {username}: {reason}' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'fail-in-secondary' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, 'Provider denied creation of {username}: {reason}' ],
], $logger->getBuffer() );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->unhook( 'LocalUserCreated' );
$this->assertEquals( \Status::newFatal( 'authmanager-autocreate-exception' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::DEBUG, '{username} denied by prior creation attempt failures' ],
], $logger->getBuffer() );
$user->setName( $username );
$ret = $this->manager->autoCreateUser( $user, AuthManager::AUTOCREATE_SOURCE_SESSION, true );
$this->assertEquals( \Status::newFatal( 'because' ), $ret );
- $this->assertEquals( 0, $user->getId() );
+ $this->assertSame( 0, $user->getId() );
$this->assertNotEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::INFO, 'creating new user ({username}) - from: {from}' ],
[ LogLevel::ERROR, '{username} failed with message {msg}' ],
} catch ( \Exception $ex ) {
$this->assertSame( 'Excepted', $ex->getMessage() );
}
- $this->assertEquals( 0, $user->getId() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $user->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::INFO, 'creating new user ({username}) - from: {from}' ],
[ LogLevel::ERROR, '{username} failed with exception {exception}' ],
$this->assertEquals( \Status::newGood(), $ret );
$this->assertNotEquals( 0, $user->getId() );
$this->assertEquals( $username, $user->getName() );
- $this->assertEquals( 0, $session->getUser()->getId() );
+ $this->assertSame( 0, $session->getUser()->getId() );
$this->assertSame( [
[ LogLevel::INFO, 'creating new user ({username}) - from: {from}' ],
], $logger->getBuffer() );
[ 'ir_ipb_id' => $block->getId() ]
);
- $this->assertEquals( 0, $result->numRows() );
+ $this->assertSame( 0, $result->numRows() );
}
/**
$this->assertEquals( 'Meta>MetaWikiUser', $block->getBlocker()->getName(),
'Correct blocker name' );
$this->assertEquals( 'Meta>MetaWikiUser', $block->getByName(), 'Correct blocker name' );
- $this->assertEquals( 0, $block->getBy(), 'Correct blocker id' );
+ $this->assertSame( 0, $block->getBy(), 'Correct blocker id' );
}
protected function addXffBlocks() {
$this->makePage( 'Go', 'de', 'Race!' );
$dbw->endAtomic( __METHOD__ );
- $this->assertEquals( 0,
+ $this->assertSame( 0,
DeferredUpdates::pendingUpdatesCount(),
'Post-commit deferred update triggers a run of all updates' );
// Populate one key
$this->makePage( 'Key1', 'de', 'Value1' );
- $this->assertEquals( 0,
+ $this->assertSame( 0,
DeferredUpdates::pendingUpdatesCount(),
'Post-commit deferred update triggers a run of all updates' );
$this->assertEquals( 'Value1', $messageCache->get( 'Key1' ), 'Key1 was successfully edited' );
// Populate the second key
$this->makePage( 'Key2', 'de', 'Value2' );
- $this->assertEquals( 0,
+ $this->assertSame( 0,
DeferredUpdates::pendingUpdatesCount(),
'Post-commit deferred update triggers a run of all updates' );
$this->assertEquals( 'Value2', $messageCache->get( 'Key2' ), 'Key2 was successfully edited' );
MessageCache::singleton()->getMsgFromNamespace( 'allpages', $wgContLanguageCode );
- $this->assertEquals( 0, $dbr->trxLevel() );
+ $this->assertSame( 0, $dbr->trxLevel() );
$dbr->setFlag( DBO_TRX, $dbr::REMEMBER_PRIOR ); // make queries trigger TRX
MessageCache::singleton()->getMsgFromNamespace( 'go', $wgContLanguageCode );
$dbr->restoreFlags();
- $this->assertEquals( 0, $dbr->trxLevel(), "No DB read queries (content language)" );
+ $this->assertSame( 0, $dbr->trxLevel(), "No DB read queries (content language)" );
}
public function testNoDBAccessNonContentLanguage() {
MessageCache::singleton()->getMsgFromNamespace( 'allpages/nl', 'nl' );
- $this->assertEquals( 0, $dbr->trxLevel() );
+ $this->assertSame( 0, $dbr->trxLevel() );
$dbr->setFlag( DBO_TRX, $dbr::REMEMBER_PRIOR ); // make queries trigger TRX
MessageCache::singleton()->getMsgFromNamespace( 'go/nl', 'nl' );
$dbr->restoreFlags();
- $this->assertEquals( 0, $dbr->trxLevel(), "No DB read queries (non-content language)" );
+ $this->assertSame( 0, $dbr->trxLevel(), "No DB read queries (non-content language)" );
}
/**
$this->assertEquals( '(recentchanges-page-added-to-category: ' . self::$pageName . ')',
self::$lastNotifyArgs[3] );
$this->assertEquals( self::$pageName, self::$lastNotifyArgs[4]->getPrefixedText() );
- $this->assertEquals( 0, self::$lastNotifyArgs[5] );
- $this->assertEquals( 0, self::$lastNotifyArgs[6] );
+ $this->assertSame( 0, self::$lastNotifyArgs[5] );
+ $this->assertSame( 0, self::$lastNotifyArgs[6] );
$this->assertEquals( null, self::$lastNotifyArgs[7] );
$this->assertEquals( 1, self::$lastNotifyArgs[8] );
$this->assertEquals( null, self::$lastNotifyArgs[9] );
- $this->assertEquals( 0, self::$lastNotifyArgs[10] );
+ $this->assertSame( 0, self::$lastNotifyArgs[10] );
}
public function testChangeRemovedNoRev() {
$this->assertEquals( '(recentchanges-page-removed-from-category: ' . self::$pageName . ')',
self::$lastNotifyArgs[3] );
$this->assertEquals( self::$pageName, self::$lastNotifyArgs[4]->getPrefixedText() );
- $this->assertEquals( 0, self::$lastNotifyArgs[5] );
- $this->assertEquals( 0, self::$lastNotifyArgs[6] );
+ $this->assertSame( 0, self::$lastNotifyArgs[5] );
+ $this->assertSame( 0, self::$lastNotifyArgs[6] );
$this->assertEquals( null, self::$lastNotifyArgs[7] );
$this->assertEquals( 1, self::$lastNotifyArgs[8] );
$this->assertEquals( null, self::$lastNotifyArgs[9] );
- $this->assertEquals( 0, self::$lastNotifyArgs[10] );
+ $this->assertSame( 0, self::$lastNotifyArgs[10] );
}
public function testChangeAddedWithRev() {
$this->assertEquals( self::$pageRev->getParentId(), self::$lastNotifyArgs[5] );
$this->assertEquals( $revision->getId(), self::$lastNotifyArgs[6] );
$this->assertEquals( null, self::$lastNotifyArgs[7] );
- $this->assertEquals( 0, self::$lastNotifyArgs[8] );
+ $this->assertSame( 0, self::$lastNotifyArgs[8] );
$this->assertEquals( '127.0.0.1', self::$lastNotifyArgs[9] );
- $this->assertEquals( 0, self::$lastNotifyArgs[10] );
+ $this->assertSame( 0, self::$lastNotifyArgs[10] );
}
public function testChangeRemovedWithRev() {
$this->assertEquals( self::$pageRev->getParentId(), self::$lastNotifyArgs[5] );
$this->assertEquals( $revision->getId(), self::$lastNotifyArgs[6] );
$this->assertEquals( null, self::$lastNotifyArgs[7] );
- $this->assertEquals( 0, self::$lastNotifyArgs[8] );
+ $this->assertSame( 0, self::$lastNotifyArgs[8] );
$this->assertEquals( '127.0.0.1', self::$lastNotifyArgs[9] );
- $this->assertEquals( 0, self::$lastNotifyArgs[10] );
+ $this->assertSame( 0, self::$lastNotifyArgs[10] );
}
}
$recentChange2 = $this->getEditChange( '20131103092253' );
$html = $enhancedChangesList->recentChangesLine( $recentChange2, false );
- $this->assertEquals( '', $html );
+ $this->assertSame( '', $html );
}
public function testRecentChangesPrefix() {
$this->assertEquals( false, $cacheEntry->watched, 'watched' );
$this->assertEquals( '21:21', $cacheEntry->timestamp, 'timestamp' );
- $this->assertEquals( 0, $cacheEntry->numberofWatchingusers, 'watching users' );
+ $this->assertSame( 0, $cacheEntry->numberofWatchingusers, 'watching users' );
$this->assertEquals( false, $cacheEntry->unpatrolled, 'unpatrolled' );
$this->assertUserLinks( $user->getName(), $cacheEntry );
$this->assertEquals( false, $cacheEntry->watched, 'watched' );
$this->assertEquals( '21:21', $cacheEntry->timestamp, 'timestamp' );
- $this->assertEquals( 0, $cacheEntry->numberofWatchingusers, 'watching users' );
+ $this->assertSame( 0, $cacheEntry->numberofWatchingusers, 'watching users' );
$this->assertEquals( false, $cacheEntry->unpatrolled, 'unpatrolled' );
$this->assertDeleteLogLink( $cacheEntry );
$this->assertEquals( false, $cacheEntry->watched, 'watched' );
$this->assertEquals( '21:21', $cacheEntry->timestamp, 'timestamp' );
- $this->assertEquals( 0, $cacheEntry->numberofWatchingusers, 'watching users' );
+ $this->assertSame( 0, $cacheEntry->numberofWatchingusers, 'watching users' );
$this->assertEquals( false, $cacheEntry->unpatrolled, 'unpatrolled' );
$this->assertRevDel( $cacheEntry );
$content = null;
$text = ContentHandler::getContentText( $content );
- $this->assertEquals( '', $text );
+ $this->assertSame( '', $text );
}
public static function dataGetContentText_TextContent() {
$content = $handler->makeEmptyContent();
$this->assertTrue( $content->isEmpty() );
- $this->assertEquals( '', $content->getData() );
+ $this->assertSame( '', $content->getData() );
}
public static function dataIsSupportedFormat() {
public function testGetWikitextForTransclusion() {
$content = $this->newContent( 'hello world.' );
- $this->assertEquals( '', $content->getWikitextForTransclusion() );
+ $this->assertFalse( $content->getWikitextForTransclusion() );
}
/**
$content = $this->handler->makeEmptyContent();
$this->assertTrue( $content->isEmpty() );
- $this->assertEquals( '', $content->getText() );
+ $this->assertSame( '', $content->getText() );
}
public static function dataIsSupportedFormat() {
$oInfo = $context->exportSession();
$this->assertEquals( '127.0.0.1', $oInfo['ip'], "Correct initial IP address." );
- $this->assertEquals( 0, $oInfo['userId'], "Correct initial user ID." );
+ $this->assertSame( 0, $oInfo['userId'], "Correct initial user ID." );
$this->assertFalse( MediaWiki\Session\SessionManager::getGlobalSession()->isPersistent(),
'Global session isn\'t persistent to start' );
};
$factory = $this->newLBFactoryMultiLBs();
- $this->assertEquals( 0, $countLBsFunc( $factory ) );
+ $this->assertSame( 0, $countLBsFunc( $factory ) );
$dbw = $factory->getMainLB()->getConnection( DB_MASTER );
$this->assertEquals( 1, $countLBsFunc( $factory ) );
// Test that LoadBalancer instances made during pre-commit callbacks in do not
$called = 0;
$factory = $this->newLBFactoryMultiLBs();
- $this->assertEquals( 0, $countLBsFunc( $factory ) );
+ $this->assertSame( 0, $countLBsFunc( $factory ) );
$dbw = $factory->getMainLB()->getConnection( DB_MASTER );
$this->assertEquals( 1, $countLBsFunc( $factory ) );
// Test that LoadBalancer instances made during pre-commit callbacks in do not
/** @var IMaintainableDatabase $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
- $this->assertEquals(
+ $this->assertSame(
'',
$db->getDomainId(),
'Null domain ID handle used'
);
- $this->assertEquals(
- '',
+ $this->assertNull(
$db->getDBname(),
'Null domain ID handle used'
);
- $this->assertEquals(
+ $this->assertSame(
'',
$db->tablePrefix(),
'Main domain ID handle used; prefix is empty though'
/** @var IMaintainableDatabase $db */
$db = $lb->getConnection( DB_MASTER, [], '' );
- $this->assertEquals( '', $db->getDomainID(), "Null domain used" );
+ $this->assertSame( '', $db->getDomainID(), "Null domain used" );
$this->assertEquals(
$this->quoteTable( $db, 'page' ),
$lb->forEachOpenConnection( function () use ( &$n ) {
++$n;
} );
- $this->assertEquals( 0, $n, "Connections closed" );
+ $this->assertSame( 0, $n, "Connections closed" );
$conn2 = $lb->getConnectionRef( DB_MASTER );
$this->assertEquals(
$this->assertEquals( 1, $wrapped->pages );
$this->assertEquals( 3, $wrapped->users );
$this->assertEquals( 1, $wrapped->images );
- $this->assertEquals( 0, $wrapped->edits );
- $this->assertEquals( 0, $wrapped->articles );
+ $this->assertSame( 0, $wrapped->edits );
+ $this->assertSame( 0, $wrapped->articles );
}
/**
$fi = SiteStats::images();
$ai = SiteStats::articles();
- $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount() );
+ $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount() );
$dbw->begin( __METHOD__ ); // block opportunistic updates
$this->assertEquals( 1, DeferredUpdates::pendingUpdatesCount() );
DeferredUpdates::doUpdates();
- $this->assertEquals( 0, DeferredUpdates::pendingUpdatesCount() );
+ $this->assertSame( 0, DeferredUpdates::pendingUpdatesCount() );
SiteStats::unload();
$this->assertEquals( $pi + 2, SiteStats::pages(), 'page count' );
$be->getReadIndexFromParams( [ 'latest' => 1 ] ),
'Reads with "latest" flag use backend 1'
);
- $this->assertEquals(
+ $this->assertSame(
0,
$be->getReadIndexFromParams( [ 'latest' => 0 ] ),
'Reads without "latest" flag use backend 0'
* @covers File::getHashPath
*/
public function testGetHashPath() {
- $this->assertEquals( '', $this->file_hl0->getHashPath() );
+ $this->assertSame( '', $this->file_hl0->getHashPath() );
$this->assertEquals( 'a/a2/', $this->file_hl2->getHashPath() );
$this->assertEquals( 'c/c4/', $this->file_lc->getHashPath() );
}
$s = $r->execute();
$errorMsg = $s->getErrorsByType( 'error' )[0]['message'];
- $this->assertEquals( 0, $r->getStatus() );
+ $this->assertSame( 0, $r->getStatus() );
$this->assertEquals( 'http-invalid-url', $errorMsg );
}
$s = $r->execute();
$errorMsg = $s->getErrorsByType( 'error' )[0]['message'];
- $this->assertEquals( 0, $r->getStatus() );
+ $this->assertSame( 0, $r->getStatus() );
$this->assertEquals( 'http-request-error', $errorMsg );
}
$s = $r->execute();
$errorMsg = $s->getErrorsByType( 'error' )[0]['message'];
- $this->assertEquals( 0, $r->getStatus() );
+ $this->assertSame( 0, $r->getStatus() );
$this->assertEquals( 'http-timed-out', $errorMsg );
}
$this->hideDeprecated( 'Http::getProxy' );
$this->setMwGlobals( 'wgHTTPProxy', false );
- $this->assertEquals(
+ $this->assertSame(
'',
Http::getProxy(),
'default setting'
$this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" );
$queue->flushCaches();
- $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
$this->assertNull( $queue->push( $this->newJob() ), "Push worked ($desc)" );
$this->assertNull( $queue->batchPush( [ $this->newJob() ] ), "Push worked ($desc)" );
$queue->flushCaches();
$this->assertEquals( 2, $queue->getSize(), "Queue size is correct ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
$jobs = iterator_to_array( $queue->getAllQueuedJobs() );
$this->assertEquals( 2, count( $jobs ), "Queue iterator size is correct ($desc)" );
$job2 = $queue->pop();
$this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" );
- $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" );
$queue->flushCaches();
if ( $recycles ) {
$queue->ack( $job2 );
$queue->flushCaches();
- $this->assertEquals( 0, $queue->getAcquiredCount(), "Active job count ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "Active job count ($desc)" );
$this->assertNull( $queue->batchPush( [ $this->newJob(), $this->newJob() ] ),
"Push worked ($desc)" );
$queue->delete();
$queue->flushCaches();
$this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" );
- $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" );
}
/**
$this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" );
$queue->flushCaches();
- $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
$this->assertNull(
$queue->batchPush(
$queue->flushCaches();
$this->assertEquals( 1, $queue->getSize(), "Queue size is correct ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
$this->assertNull(
$queue->batchPush(
$queue->flushCaches();
$this->assertEquals( 1, $queue->getSize(), "Queue size is correct ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
$job1 = $queue->pop();
$this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" );
$queue->flushCaches();
- $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" );
if ( $recycles ) {
$this->assertEquals( 1, $queue->getAcquiredCount(), "Active job count ($desc)" );
}
$queue->ack( $job1 );
$queue->flushCaches();
- $this->assertEquals( 0, $queue->getAcquiredCount(), "Active job count ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "Active job count ($desc)" );
}
/**
$this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" );
$queue->flushCaches();
- $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
$root1 = Job::newRootJobParams( "nulljobspam:testId" ); // task ID/timestamp
for ( $i = 0; $i < 5; ++$i ) {
$queue->flushCaches();
$this->assertEquals( 10, $queue->getSize(), "Queue size is correct ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
$dupcount = 0;
$jobs = [];
$this->assertTrue( $queue->isEmpty(), "Queue is empty ($desc)" );
$queue->flushCaches();
- $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "Queue is empty ($desc)" );
for ( $i = 0; $i < 10; ++$i ) {
$this->assertNull( $queue->push( $this->newJob( $i ) ), "Push worked ($desc)" );
$this->assertFalse( $queue->pop(), "Queue is not empty ($desc)" );
$queue->flushCaches();
- $this->assertEquals( 0, $queue->getSize(), "Queue is empty ($desc)" );
- $this->assertEquals( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
+ $this->assertSame( 0, $queue->getSize(), "Queue is empty ($desc)" );
+ $this->assertSame( 0, $queue->getAcquiredCount(), "No jobs active ($desc)" );
}
/**
$this->assertEquals( 1, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] );
$this->assertEquals( 2, $watchedItemStore->countWatchedItems( $user ) );
$this->runJobs( 1 );
- $this->assertEquals( 0, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] );
+ $this->assertSame( 0, JobQueueGroup::singleton()->getQueueSizes()['clearUserWatchlist'] );
$this->assertEquals( 2, $watchedItemStore->countWatchedItems( $user ) );
$this->assertTrue( $watchedItemStore->isWatched( $user, new TitleValue( 0, 'C' ) ) );
* Compare against an array so we get the cache content difference.
*/
protected function assertCacheEmpty( $cache, $msg = 'Cache should be empty' ) {
- $this->assertEquals( 0, $cache->getEntriesCount(), $msg );
+ $this->assertSame( 0, $cache->getEntriesCount(), $msg );
}
/**
$this->assertEquals( 'a', $entry['name'] );
$this->assertEquals( 'mark', $entry['entryType'] );
$this->assertArrayHasKey( 'startTime', $entry );
- $this->assertEquals( 0, $entry['duration'] );
+ $this->assertSame( 0, $entry['duration'] );
usleep( 100 );
$timing->mark( 'a' );
$cache->set( 'bar', 1, 10 );
$cache->set( 'baz', 1, -10 );
- $this->assertEquals( 0, $cacheInternal->bag['foo'][$cache::KEY_EXP], 'Indefinite' );
+ $this->assertSame( 0, $cacheInternal->bag['foo'][$cache::KEY_EXP], 'Indefinite' );
// 2 seconds tolerance
$this->assertEquals( time() + 10, $cacheInternal->bag['bar'][$cache::KEY_EXP], 'Future', 2 );
$this->assertEquals( time() - 10, $cacheInternal->bag['baz'][$cache::KEY_EXP], 'Past', 2 );
$v = $cache->getWithSetCallback(
$key, 30, $func, [ 'lowTTL' => 0, 'lockTSE' => 5 ] + $extOpts );
$this->assertEquals( $value, $v, "Value returned" );
- $this->assertEquals( 0, $wasSet, "Value not regenerated" );
+ $this->assertSame( 0, $wasSet, "Value not regenerated" );
$mockWallClock += 1;
$asycList[0](); // run the refresh callback
$asycList = [];
$this->assertEquals( 2, $wasSet, "Value calculated at later time" );
- $this->assertEquals( 0, count( $asycList ), "No deferred refreshes added." );
+ $this->assertSame( 0, count( $asycList ), "No deferred refreshes added." );
$v = $cache->getWithSetCallback( $key, 300, $func, $opts );
$this->assertEquals( $value, $v, "New value stored" );
$keyedIds, 30, $genFunc, [ 'lowTTL' => 0, 'lockTSE' => 5 ] + $extOpts );
$this->assertEquals( $value, $v[$keyB], "Value returned" );
$this->assertEquals( 1, $wasSet, "Value regenerated" );
- $this->assertEquals( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" );
+ $this->assertSame( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" );
$v = $cache->getMultiWithSetCallback(
$keyedIds, 30, $genFunc, [ 'lowTTL' => 0, 'lockTSE' => 5 ] + $extOpts );
$this->assertEquals( $value, $v[$keyB], "Value returned" );
$this->assertEquals( 1, $wasSet, "Value not regenerated" );
- $this->assertEquals( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" );
+ $this->assertSame( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" );
$mockWallClock += 1;
$keyedIds, 30, $genFunc, [ 'lowTTL' => 0 ] + $extOpts );
$this->assertEquals( $value, $v[$keyB], "Value returned" );
$this->assertEquals( 1, $wasSet, "Value regenerated" );
- $this->assertEquals( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" );
+ $this->assertSame( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" );
$v = $cache->getMultiWithUnionSetCallback(
$keyedIds, 30, $genFunc, [ 'lowTTL' => 0 ] + $extOpts );
$this->assertEquals( $value, $v[$keyB], "Value returned" );
$this->assertEquals( 1, $wasSet, "Value not regenerated" );
- $this->assertEquals( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" );
+ $this->assertSame( 0, $cache->getWarmupKeyMisses(), "Keys warmed in warmup cache" );
$mockWallClock += 1;
$wasSet = 0;
$v = $cache->getWithSetCallback( $key, 30, $funcV2, $verOpts + $extOpts );
$this->assertEquals( $valueV2, $v, "Value not regenerated (secondary key)" );
- $this->assertEquals( 0, $wasSet, "Value not regenerated (secondary key)" );
+ $this->assertSame( 0, $wasSet, "Value not regenerated (secondary key)" );
// Clear out the older or unversioned key
$cache->delete( $key, 0 );
$this->database->startAtomic( __METHOD__ );
$wrapper->trxStatus = Database::STATUS_TRX_ERROR;
$this->database->rollback( __METHOD__ );
- $this->assertEquals( 0, $this->database->trxLevel() );
+ $this->assertSame( 0, $this->database->trxLevel() );
$this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() );
$this->assertLastSql( 'BEGIN; ROLLBACK' );
$this->database->endAtomic( __METHOD__ );
$this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() );
$this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'1\'; COMMIT' );
- $this->assertEquals( 0, $this->database->trxLevel(), 'Use after rollback()' );
+ $this->assertSame( 0, $this->database->trxLevel(), 'Use after rollback()' );
$this->database->begin( __METHOD__ );
$this->database->startAtomic( __METHOD__, Database::ATOMIC_CANCELABLE );
$this->database->commit( __METHOD__ );
// phpcs:ignore Generic.Files.LineLength
$this->assertLastSql( 'BEGIN; SAVEPOINT wikimedia_rdbms_atomic1; UPDATE y SET a = \'1\' WHERE field = \'1\'; ROLLBACK TO SAVEPOINT wikimedia_rdbms_atomic1; DELETE FROM y WHERE field = \'1\'; COMMIT' );
- $this->assertEquals( 0, $this->database->trxLevel(), 'Use after rollback()' );
+ $this->assertSame( 0, $this->database->trxLevel(), 'Use after rollback()' );
// Next transaction
$this->database->startAtomic( __METHOD__ );
$this->database->endAtomic( __METHOD__ );
$this->assertEquals( Database::STATUS_TRX_NONE, $wrapper->trxStatus() );
$this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'3\'; COMMIT' );
- $this->assertEquals( 0, $this->database->trxLevel() );
+ $this->assertSame( 0, $this->database->trxLevel() );
}
/**
$this->assertFalse( $this->database->isOpen() );
$this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'3\'; ROLLBACK; SELECT 2' );
- $this->assertEquals( 0, $this->database->trxLevel() );
+ $this->assertSame( 0, $this->database->trxLevel() );
}
/**
$this->assertFalse( $this->database->isOpen() );
$this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'3\'; ROLLBACK; SELECT 2' );
- $this->assertEquals( 0, $this->database->trxLevel() );
+ $this->assertSame( 0, $this->database->trxLevel() );
}
/**
$this->assertFalse( $this->database->isOpen() );
$this->assertLastSql( 'BEGIN; DELETE FROM x WHERE field = \'3\'; ROLLBACK' );
- $this->assertEquals( 0, $this->database->trxLevel() );
+ $this->assertSame( 0, $this->database->trxLevel() );
}
/**
$this->assertFalse( $this->database->isOpen() );
$this->assertLastSql( 'BEGIN; SELECT 1; ROLLBACK' );
- $this->assertEquals( 0, $this->database->trxLevel() );
+ $this->assertSame( 0, $this->database->trxLevel() );
}
/**
$db->method( 'isOpen' )->willReturn( true );
$db->method( 'getDBname' )->willReturn( 'unittest' );
- $this->assertEquals( 0, $db->trxLevel() );
+ $this->assertSame( 0, $db->trxLevel() );
$this->assertEquals( true, $db->lockIsFree( 'x', __METHOD__ ) );
$this->assertEquals( true, $db->lock( 'x', __METHOD__ ) );
$this->assertEquals( false, $db->lockIsFree( 'x', __METHOD__ ) );
$this->assertEquals( true, $db->unlock( 'x', __METHOD__ ) );
$this->assertEquals( true, $db->lockIsFree( 'x', __METHOD__ ) );
- $this->assertEquals( 0, $db->trxLevel() );
+ $this->assertSame( 0, $db->trxLevel() );
$db->setFlag( DBO_TRX );
$this->assertEquals( true, $db->lockIsFree( 'x', __METHOD__ ) );
$db->clearFlag( DBO_TRX );
// Pending writes with DBO_TRX
- $this->assertEquals( 0, $db->trxLevel() );
+ $this->assertSame( 0, $db->trxLevel() );
$this->assertTrue( $db->lockIsFree( 'meow', __METHOD__ ) );
$db->setFlag( DBO_TRX );
$db->query( "DELETE FROM test WHERE t = 1" ); // trigger DBO_TRX transaction before lock
$db->rollback( __METHOD__, IDatabase::FLUSHING_ALL_PEERS );
// Pending writes without DBO_TRX
$db->clearFlag( DBO_TRX );
- $this->assertEquals( 0, $db->trxLevel() );
+ $this->assertSame( 0, $db->trxLevel() );
$this->assertTrue( $db->lockIsFree( 'meow2', __METHOD__ ) );
$db->begin( __METHOD__ );
$db->query( "DELETE FROM test WHERE t = 1" ); // trigger DBO_TRX transaction before lock
$db->rollback( __METHOD__ );
// No pending writes, with DBO_TRX
$db->setFlag( DBO_TRX );
- $this->assertEquals( 0, $db->trxLevel() );
+ $this->assertSame( 0, $db->trxLevel() );
$this->assertTrue( $db->lockIsFree( 'wuff', __METHOD__ ) );
$db->query( "SELECT 1", __METHOD__ );
$this->assertEquals( 1, $db->trxLevel() );
$lock = $db->getScopedLockAndFlush( 'wuff', __METHOD__, 1 );
- $this->assertEquals( 0, $db->trxLevel() );
+ $this->assertSame( 0, $db->trxLevel() );
$this->assertFalse( $db->lockIsFree( 'wuff', __METHOD__ ), 'Lock already acquired' );
$db->rollback( __METHOD__, IDatabase::FLUSHING_ALL_PEERS );
// No pending writes, without DBO_TRX
$db->clearFlag( DBO_TRX );
- $this->assertEquals( 0, $db->trxLevel() );
+ $this->assertSame( 0, $db->trxLevel() );
$this->assertTrue( $db->lockIsFree( 'wuff2', __METHOD__ ) );
$db->begin( __METHOD__ );
try {
$linkRenderer = new LinkRenderer( $titleFormatter, $linkCache, $nsInfo );
$linkRenderer->setStubThreshold( 0 );
- $this->assertEquals(
+ $this->assertSame(
'',
$linkRenderer->getLinkClasses( $foobarTitle )
);
);
$linkRenderer->setStubThreshold( 20 );
- $this->assertEquals(
+ $this->assertSame(
'',
$linkRenderer->getLinkClasses( $userTitle )
);
'%[jpeg:sampling-factor]',
$path
)->execute();
- $this->assertEquals( 0,
+ $this->assertSame( 0,
$result->getExitCode(),
"ImageMagick's identify command should return success"
);
$meta = PNGMetadataExtractor::getMetadata( $this->filePath .
'Png-native-test.png' );
- $this->assertEquals( 0, $meta['frameCount'] );
+ $this->assertSame( 0, $meta['frameCount'] );
$this->assertEquals( 1, $meta['loopCount'] );
- $this->assertEquals( 0, $meta['duration'] );
+ $this->assertSame( 0.0, $meta['duration'] );
}
/**
$this->assertEquals( 20, $meta['frameCount'] );
// Note loop count of 0 = infinity
- $this->assertEquals( 0, $meta['loopCount'] );
+ $this->assertSame( 0, $meta['loopCount'] );
$this->assertEquals( 1.5, $meta['duration'], '', 0.00001 );
}
$n = $res->numRows();
$res->free();
- $this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' );
+ $this->assertSame( 0, $n, 'pagelinks should contain no more links from the page' );
}
/**
$n = $res->numRows();
$res->free();
- $this->assertEquals( 0, $n, 'pagelinks should contain no more links from the page' );
+ $this->assertSame( 0, $n, 'pagelinks should contain no more links from the page' );
}
/**
$page->updateCategoryCounts( [ 'A' ], [], 0 );
$this->assertEquals( 1, Category::newFromName( 'A' )->getPageCount() );
- $this->assertEquals( 0, Category::newFromName( 'B' )->getPageCount() );
- $this->assertEquals( 0, Category::newFromName( 'C' )->getPageCount() );
+ $this->assertSame( 0, Category::newFromName( 'B' )->getPageCount() );
+ $this->assertSame( 0, Category::newFromName( 'C' )->getPageCount() );
// Add a new category
$page->updateCategoryCounts( [ 'B' ], [], 0 );
$this->assertEquals( 1, Category::newFromName( 'A' )->getPageCount() );
$this->assertEquals( 1, Category::newFromName( 'B' )->getPageCount() );
- $this->assertEquals( 0, Category::newFromName( 'C' )->getPageCount() );
+ $this->assertSame( 0, Category::newFromName( 'C' )->getPageCount() );
// Add and remove a category
$page->updateCategoryCounts( [ 'C' ], [ 'A' ], 0 );
- $this->assertEquals( 0, Category::newFromName( 'A' )->getPageCount() );
+ $this->assertSame( 0, Category::newFromName( 'A' )->getPageCount() );
$this->assertEquals( 1, Category::newFromName( 'B' )->getPageCount() );
$this->assertEquals( 1, Category::newFromName( 'C' )->getPageCount() );
}
] );
$context = $this->getResourceLoaderContext( [], $rl );
- $this->assertEquals(
+ $this->assertSame(
'',
$rl->getCombinedVersion( $context, [] ),
'empty list'
*/
public function testNumRows() {
$resultSet = new SearchNearMatchResultSet( null );
- $this->assertEquals( 0, $resultSet->numRows() );
+ $this->assertSame( 0, $resultSet->numRows() );
$resultSet = new SearchNearMatchResultSet( Title::newMainPage() );
$this->assertEquals( 1, $resultSet->numRows() );
$wrapper = TestingAccessWrapper::newFromObject( $command );
$this->assertEquals( $expected, $wrapper->command );
- $this->assertEquals( 0, $wrapper->restrictions & Shell::NO_LOCALSETTINGS );
+ $this->assertSame( 0, $wrapper->restrictions & Shell::NO_LOCALSETTINGS );
}
public function provideMakeScriptCommand() {
$this->assertNull( $site );
$sites = $store->getSites();
- $this->assertEquals( 0, $sites->count() );
+ $this->assertSame( 0, $sites->count() );
}
/**
$this->assertNull( $site );
$sites = $store->getSites();
- $this->assertEquals( 0, $sites->count() );
+ $this->assertSame( 0, $sites->count() );
}
/**
$path = '//acme.com/'; // protocol-relative URL
$site->setPath( $type, $path );
- $this->assertEquals( '', $site->getProtocol() );
+ $this->assertSame( '', $site->getProtocol() );
}
public static function provideGetPageUrl() {
$this->markTestSkippedIfDbType( 'postgres' );
$users = User::findUsersByGroup( [] );
- $this->assertEquals( 0, iterator_count( $users ) );
+ $this->assertSame( 0, iterator_count( $users ) );
$users = User::findUsersByGroup( 'foo' );
- $this->assertEquals( 0, iterator_count( $users ) );
+ $this->assertSame( 0, iterator_count( $users ) );
$user = $this->getMutableTestUser( [ 'foo' ] )->getUser();
$users = User::findUsersByGroup( 'foo' );
$this->assertInstanceOf( WatchedItem::class, $watchedItem );
$this->assertEquals( 1, $watchedItem->getUser()->getId() );
$this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() );
- $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() );
+ $this->assertSame( 0, $watchedItem->getLinkTarget()->getNamespace() );
}
public function testLoadWatchedItem_noItem() {
$this->assertInstanceOf( WatchedItem::class, $watchedItem );
$this->assertEquals( 1, $watchedItem->getUser()->getId() );
$this->assertEquals( 'SomeDbKey', $watchedItem->getLinkTarget()->getDBkey() );
- $this->assertEquals( 0, $watchedItem->getLinkTarget()->getNamespace() );
+ $this->assertSame( 0, $watchedItem->getLinkTarget()->getNamespace() );
}
public function testGetWatchedItem_cachedItem() {
$index = $indexList->next();
$this->assertEquals( 'baz_index2', $index->name );
$this->assertEquals( '1', $index->unique );
- $this->assertEquals( 0,
+ $this->assertSame( 0,
$db->selectField( 'sqlite_master', 'COUNT(*)', [ 'name' => 'baz' ] ),
'Create a temporary duplicate only'
);
$databaseCreation = $db->query( 'CREATE TABLE a ( a_1 )', __METHOD__ );
$this->assertInstanceOf( ResultWrapper::class, $databaseCreation, "Failed to create table a" );
$res = $db->select( 'a', '*' );
- $this->assertEquals( 0, $db->numFields( $res ), "expects to get 0 fields for an empty table" );
+ $this->assertSame( 0, $db->numFields( $res ), "expects to get 0 fields for an empty table" );
$insertion = $db->insert( 'a', [ 'a_1' => 10 ], __METHOD__ );
$this->assertTrue( $insertion, "Insertion failed" );
$res = $db->select( 'a', '*' );
$s = $lang->getMessageFromDB( 'word-separator' );
$c = $lang->getMessageFromDB( 'comma-separator' );
- $this->assertEquals( '', $lang->listToText( [] ) );
+ $this->assertSame( '', $lang->listToText( [] ) );
$this->assertEquals( 'a', $lang->listToText( [ 'a' ] ) );
$this->assertEquals( "a{$and}{$s}b", $lang->listToText( [ 'a', 'b' ] ) );
$this->assertEquals( "a{$c}b{$and}{$s}c", $lang->listToText( [ 'a', 'b', 'c' ] ) );
// 2. Do the real output checking on our own.
$lines = explode( "\n", $this->getActualOutput() );
$this->assertGreaterThan( 1, count( $lines ), "Minimal lines of produced output" );
- $this->assertEquals( '', array_pop( $lines ), "Output ends in LF" );
+ $this->assertSame( '', array_pop( $lines ), "Output ends in LF" );
$timestamp_re = "[0-9]{4}-[01][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-6][0-9]";
foreach ( $lines as $line ) {
$this->assertRegExp(
*/
public function testNorig() {
$obj = new FakeDiffOp();
- $this->assertEquals( 0, $obj->norig() );
+ $this->assertSame( 0, $obj->norig() );
$obj->orig = [ 'foo' ];
$this->assertEquals( 1, $obj->norig() );
}
*/
public function testNclosing() {
$obj = new FakeDiffOp();
- $this->assertEquals( 0, $obj->nclosing() );
+ $this->assertSame( 0, $obj->nclosing() );
$obj->closing = [ 'foo' ];
$this->assertEquals( 1, $obj->nclosing() );
}
public function testConstruct() {
$pf = new PasswordFactory();
$this->assertEquals( [ '' ], array_keys( $pf->getTypes() ) );
- $this->assertEquals( '', $pf->getDefaultType() );
+ $this->assertSame( '', $pf->getDefaultType() );
$pf = new PasswordFactory( [
'foo' => [ 'class' => 'FooPassword' ],
*/
public function testAppend() {
$set = SearchSuggestionSet::emptySuggestionSet();
- $this->assertEquals( 0, $set->getSize() );
+ $this->assertSame( 0, $set->getSize() );
$set->append( new SearchSuggestion( 3 ) );
$this->assertEquals( 3, $set->getWorstScore() );
$this->assertEquals( 3, $set->getBestScore() );
*/
public function testInsertBest() {
$set = SearchSuggestionSet::emptySuggestionSet();
- $this->assertEquals( 0, $set->getSize() );
+ $this->assertSame( 0, $set->getSize() );
$set->prepend( new SearchSuggestion( 3 ) );
$this->assertEquals( 3, $set->getWorstScore() );
$this->assertEquals( 3, $set->getBestScore() );
$this->assertEquals( 10, $set->getSize() );
$set->shrink( 0 );
- $this->assertEquals( 0, $set->getSize() );
+ $this->assertSame( 0, $set->getSize() );
}
// TODO: test for fromTitles
// Sauce Labs
// ======
// See http://webdriver.io/guide/services/sauce.html
- // and https://docs.saucelabs.com/reference/platforms-configurator
- services: [ 'sauce' ],
- user: process.env.SAUCE_USERNAME,
- key: process.env.SAUCE_ACCESS_KEY,
-
- // Default timeout in milliseconds for Selenium Grid requests
- connectionRetryTimeout: 90 * 1000,
-
- // Default request retries count
- connectionRetryCount: 3,
+ // and https://github.com/bermi/sauce-connect-launcher#advanced-usage
+ services: process.env.SAUCE_ACCESS_KEY ? [ 'sauce' ] : [],
// ==================
// Test Files