6 use InvalidArgumentException;
32 $title->resetArticleID( 17 );
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 );
60 $title->resetArticleID( 17 );
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';
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' => [
167 $this->assertSame(
$title, $rec->getPageAsLinkTarget(),
'getPageAsLinkTarget' );
169 $this->assertSame( $comment, $rec->getComment(),
'getComment' );
171 $this->assertSame( $slots, $rec->
getSlots(),
'getSlots' );
172 $this->assertSame( $slots->
getSlotRoles(), $rec->getSlotRoles(),
'getSlotRoles' );
173 $this->assertSame( $slots->
getSlots(), $rec->getSlots()->getSlots(),
'getSlots' );
174 $this->assertSame( $wikiId, $rec->getWikiId(),
'getWikiId' );
176 $this->assertSame( (
int)$row->rev_id, $rec->getId(),
'getId' );
177 $this->assertSame( (
int)$row->rev_page, $rec->getPageId(),
'getId' );
178 $this->assertSame( $row->rev_timestamp, $rec->getTimestamp(),
'getTimestamp' );
179 $this->assertSame( (
int)$row->rev_deleted, $rec->getVisibility(),
'getVisibility' );
180 $this->assertSame( (
bool)$row->rev_minor_edit, $rec->isMinor(),
'getIsMinor' );
182 if ( isset( $row->rev_parent_id ) ) {
183 $this->assertSame( (
int)$row->rev_parent_id, $rec->getParentId(),
'getParentId' );
185 $this->assertSame( 0, $rec->getParentId(),
'getParentId' );
188 if ( isset( $row->rev_len ) ) {
189 $this->assertSame( (
int)$row->rev_len, $rec->getSize(),
'getSize' );
191 $this->assertSame( $slots->
computeSize(), $rec->getSize(),
'getSize' );
194 if ( !empty( $row->rev_sha1 ) ) {
195 $this->assertSame( $row->rev_sha1, $rec->getSha1(),
'getSha1' );
197 $this->assertSame( $slots->
computeSha1(), $rec->getSha1(),
'getSha1' );
200 if ( isset( $row->page_latest ) ) {
202 (
int)$row->rev_id === (
int)$row->page_latest,
217 $title->resetArticleID( 17 );
229 'rev_page' => strval(
$title->getArticleID() ),
230 'rev_timestamp' =>
'20200101000000',
232 'rev_minor_edit' => 0,
233 'rev_parent_id' =>
'5',
234 'rev_len' => $slots->computeSize(),
235 'rev_sha1' => $slots->computeSha1(),
236 'page_latest' =>
'18',
239 yield
'not a row' => [
249 $row[
'rev_timestamp'] =
'kittens';
251 yield
'bad timestamp' => [
260 $row[
'rev_page'] = 99;
262 yield
'page ID mismatch' => [
272 yield
'bad wiki' => [
327 $this->assertSame( $current,
$rev->isCurrent(),
'isCurrent()' );
343 'rev_deleted' => $visibility,
354 $this->assertNotNull(