Code that needs to store an actor ID in the database to represent a UserIdentity, or needs to construct a UserIdentity based on an actor ID loaded from the database, should use the ActorNormalization service. Note: The getActorId() method is removed from the UserIdentity interface, but all concrete classes continue to support it for now. UsererIdentityValue::getActorId() is hard deprecated and should be removed in 1.37. It always returns 0. User::getActorId() is not deprecated at this point. Bug: T274179 Depends-On: Id2b3ddf6a2a7cdf90f8936a69148d2cce6fde237 Change-Id: I9925906d11e47efaec3c1f48d5cb3f9896a982c1
71 lines
2 KiB
PHP
71 lines
2 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Tests\Unit\Revision;
|
|
|
|
use CommentStoreComment;
|
|
use DummyContentForTesting;
|
|
use MediaWiki\Page\PageIdentityValue;
|
|
use MediaWiki\Revision\RevisionArchiveRecord;
|
|
use MediaWiki\Revision\RevisionRecord;
|
|
use MediaWiki\Revision\RevisionSlots;
|
|
use MediaWiki\Revision\SlotRecord;
|
|
use MediaWiki\User\UserIdentityValue;
|
|
use MediaWikiUnitTestCase;
|
|
|
|
/**
|
|
* @covers \MediaWiki\Revision\RevisionArchiveRecord
|
|
* @covers \MediaWiki\Revision\RevisionRecord
|
|
*/
|
|
class RevisionArchiveRecordTest extends MediaWikiUnitTestCase {
|
|
use RevisionRecordTests;
|
|
|
|
/**
|
|
* @param array $rowOverrides
|
|
*
|
|
* @return RevisionArchiveRecord
|
|
*/
|
|
protected function newRevision( array $rowOverrides = [] ) {
|
|
$wikiId = $rowOverrides['wikiId'] ?? RevisionRecord::LOCAL;
|
|
|
|
$title = new PageIdentityValue( 17, NS_MAIN, 'Dummy', $wikiId );
|
|
|
|
$user = new UserIdentityValue( 11, 'Tester' );
|
|
$comment = CommentStoreComment::newUnsavedComment( 'Hello World' );
|
|
|
|
$main = SlotRecord::newUnsaved( SlotRecord::MAIN, new DummyContentForTesting( 'Lorem Ipsum' ) );
|
|
$aux = SlotRecord::newUnsaved( 'aux', new DummyContentForTesting( 'Frumious Bandersnatch' ) );
|
|
$slots = new RevisionSlots( [ $main, $aux ] );
|
|
|
|
$row = [
|
|
'ar_id' => '5',
|
|
'ar_rev_id' => '7',
|
|
'ar_page_id' => '17',
|
|
'ar_timestamp' => '20200101000000',
|
|
'ar_deleted' => 0,
|
|
'ar_minor_edit' => 0,
|
|
'ar_parent_id' => '5',
|
|
'ar_len' => $slots->computeSize(),
|
|
'ar_sha1' => $slots->computeSha1(),
|
|
];
|
|
|
|
foreach ( $rowOverrides as $field => $value ) {
|
|
if ( $field === 'rev_id' ) {
|
|
$field = 'ar_rev_id';
|
|
} else {
|
|
$field = preg_replace( '/^rev_/', 'ar_', $field );
|
|
}
|
|
$row[$field] = $value;
|
|
}
|
|
|
|
return new RevisionArchiveRecord( $title, $user, $comment, (object)$row, $slots, $wikiId );
|
|
}
|
|
|
|
/**
|
|
* @covers \MediaWiki\Revision\RevisionRecord::isCurrent
|
|
*/
|
|
public function testIsCurrent() {
|
|
$rev = $this->newRevision();
|
|
$this->assertFalse( $rev->isCurrent(),
|
|
RevisionArchiveRecord::class . ' cannot be stored current revision' );
|
|
}
|
|
}
|