31 $title = Title::newFromText(
'Dummy' );
32 $title->resetArticleID( 17 );
35 $comment = CommentStoreComment::newUnsavedComment(
'Hello World' );
37 $main = SlotRecord::newUnsaved(
'main',
new TextContent(
'Lorem Ipsum' ) );
38 $aux = SlotRecord::newUnsaved(
'aux',
new TextContent(
'Frumious Bandersnatch' ) );
43 'rev_page' => strval( $title->getArticleID() ),
44 'rev_timestamp' =>
'20200101000000',
46 'rev_minor_edit' => 0,
47 'rev_parent_id' =>
'5',
48 'rev_len' => $slots->computeSize(),
49 'rev_sha1' => $slots->computeSha1(),
50 'page_latest' =>
'18',
53 $row = array_merge( $row, $rowOverrides );
59 $title = Title::newFromText(
'Dummy' );
60 $title->resetArticleID( 17 );
63 $comment = CommentStoreComment::newUnsavedComment(
'Hello World' );
65 $main = SlotRecord::newUnsaved(
'main',
new TextContent(
'Lorem Ipsum' ) );
66 $aux = SlotRecord::newUnsaved(
'aux',
new TextContent(
'Frumious Bandersnatch' ) );
71 'rev_page' => strval( $title->getArticleID() ),
72 'rev_timestamp' =>
'20200101000000',
74 'rev_minor_edit' => 0,
75 'rev_parent_id' =>
'5',
76 'rev_len' => $slots->computeSize(),
77 'rev_sha1' => $slots->computeSha1(),
78 'page_latest' =>
'18',
92 $row[
'rev_minor_edit'] =
'1';
93 $row[
'rev_deleted'] = strval( RevisionRecord::DELETED_USER );
95 yield
'minor deleted' => [
104 $row[
'page_latest'] = $row[
'rev_id'];
115 unset( $row[
'rev_parent'] );
117 yield
'no parent' => [
126 $row[
'rev_len'] =
null;
127 $row[
'rev_sha1'] =
'';
129 yield
'rev_len is null, rev_sha1 is ""' => [
138 yield
'no length, no hash' => [
139 Title::newFromText(
'DummyDoesNotExist' ),
167 $this->assertSame( $title, $rec->getPageAsLinkTarget(),
'getPageAsLinkTarget' );
168 $this->assertSame( $user, $rec->getUser( RevisionRecord::RAW ),
'getUser' );
169 $this->assertSame( $comment, $rec->getComment(),
'getComment' );
171 $this->assertSame( $slots->
getSlotRoles(), $rec->getSlotRoles(),
'getSlotRoles' );
172 $this->assertSame( $wikiId, $rec->getWikiId(),
'getWikiId' );
174 $this->assertSame( (
int)$row->rev_id, $rec->getId(),
'getId' );
175 $this->assertSame( (
int)$row->rev_page, $rec->getPageId(),
'getId' );
176 $this->assertSame( $row->rev_timestamp, $rec->getTimestamp(),
'getTimestamp' );
177 $this->assertSame( (
int)$row->rev_deleted, $rec->getVisibility(),
'getVisibility' );
178 $this->assertSame( (
bool)$row->rev_minor_edit, $rec->isMinor(),
'getIsMinor' );
180 if ( isset( $row->rev_parent_id ) ) {
181 $this->assertSame( (
int)$row->rev_parent_id, $rec->getParentId(),
'getParentId' );
183 $this->assertSame( 0, $rec->getParentId(),
'getParentId' );
186 if ( isset( $row->rev_len ) ) {
187 $this->assertSame( (
int)$row->rev_len, $rec->getSize(),
'getSize' );
189 $this->assertSame( $slots->
computeSize(), $rec->getSize(),
'getSize' );
192 if ( !empty( $row->rev_sha1 ) ) {
193 $this->assertSame( $row->rev_sha1, $rec->getSha1(),
'getSha1' );
195 $this->assertSame( $slots->
computeSha1(), $rec->getSha1(),
'getSha1' );
198 if ( isset( $row->page_latest ) ) {
200 (
int)$row->rev_id === (
int)$row->page_latest,
214 $title = Title::newFromText(
'Dummy' );
215 $title->resetArticleID( 17 );
219 $comment = CommentStoreComment::newUnsavedComment(
'Hello World' );
221 $main = SlotRecord::newUnsaved(
'main',
new TextContent(
'Lorem Ipsum' ) );
222 $aux = SlotRecord::newUnsaved(
'aux',
new TextContent(
'Frumious Bandersnatch' ) );
227 'rev_page' => strval( $title->getArticleID() ),
228 'rev_timestamp' =>
'20200101000000',
230 'rev_minor_edit' => 0,
231 'rev_parent_id' =>
'5',
232 'rev_len' => $slots->computeSize(),
233 'rev_sha1' => $slots->computeSha1(),
234 'page_latest' =>
'18',
237 yield
'not a row' => [
247 $row[
'rev_timestamp'] =
'kittens';
249 yield
'bad timestamp' => [
258 $row[
'rev_page'] = 99;
260 yield
'page ID mismatch' => [
270 yield
'bad wiki' => [
341 'rev_deleted' => $visibility,
348 $this->assertNotNull(
$rev->getSlot(
'main', RevisionRecord::RAW ),
'raw can' );
349 $this->assertNotNull(
$rev->getSlot(
'main', RevisionRecord::FOR_PUBLIC ),
'public can' );
351 $this->assertNotNull(
352 $rev->getSlot(
'main', RevisionRecord::FOR_THIS_USER, $user ),
356 $rev->getSlot(
'main', RevisionRecord::RAW )->getContent();
359 $rev->getSlot(
'main', RevisionRecord::FOR_PUBLIC )->getContent();
360 $rev->getSlot(
'main', RevisionRecord::FOR_THIS_USER, $user )->getContent();