2021-01-22 04:06:07 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Tests\Unit\Revision;
|
|
|
|
|
|
|
|
|
|
use CommentStoreComment;
|
2021-02-02 02:11:49 +00:00
|
|
|
use DummyContentForTesting;
|
2021-01-22 04:06:07 +00:00
|
|
|
use MediaWiki\Page\PageIdentityValue;
|
|
|
|
|
use MediaWiki\Revision\RevisionArchiveRecord;
|
2021-01-25 14:22:41 +00:00
|
|
|
use MediaWiki\Revision\RevisionRecord;
|
2021-01-22 04:06:07 +00:00
|
|
|
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 = [] ) {
|
2021-01-25 14:22:41 +00:00
|
|
|
$wikiId = $rowOverrides['wikiId'] ?? RevisionRecord::LOCAL;
|
|
|
|
|
|
|
|
|
|
$title = new PageIdentityValue( 17, NS_MAIN, 'Dummy', $wikiId );
|
2021-01-22 04:06:07 +00:00
|
|
|
|
2021-02-15 18:58:09 +00:00
|
|
|
$user = new UserIdentityValue( 11, 'Tester' );
|
2021-01-22 04:06:07 +00:00
|
|
|
$comment = CommentStoreComment::newUnsavedComment( 'Hello World' );
|
|
|
|
|
|
2021-02-02 02:11:49 +00:00
|
|
|
$main = SlotRecord::newUnsaved( SlotRecord::MAIN, new DummyContentForTesting( 'Lorem Ipsum' ) );
|
|
|
|
|
$aux = SlotRecord::newUnsaved( 'aux', new DummyContentForTesting( 'Frumious Bandersnatch' ) );
|
2021-01-22 04:06:07 +00:00
|
|
|
$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 ) {
|
2021-01-25 14:22:41 +00:00
|
|
|
if ( $field === 'rev_id' ) {
|
|
|
|
|
$field = 'ar_rev_id';
|
|
|
|
|
} else {
|
|
|
|
|
$field = preg_replace( '/^rev_/', 'ar_', $field );
|
|
|
|
|
}
|
2021-01-22 04:06:07 +00:00
|
|
|
$row[$field] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-25 14:22:41 +00:00
|
|
|
return new RevisionArchiveRecord( $title, $user, $comment, (object)$row, $slots, $wikiId );
|
2021-01-22 04:06:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers \MediaWiki\Revision\RevisionRecord::isCurrent
|
|
|
|
|
*/
|
|
|
|
|
public function testIsCurrent() {
|
|
|
|
|
$rev = $this->newRevision();
|
|
|
|
|
$this->assertFalse( $rev->isCurrent(),
|
|
|
|
|
RevisionArchiveRecord::class . ' cannot be stored current revision' );
|
|
|
|
|
}
|
|
|
|
|
}
|