6 use InvalidArgumentException;
35 $title->resetArticleID( 17 );
42 if ( isset( $rowOverrides[
'rev_deleted'] ) ) {
43 $record->setVisibility( $rowOverrides[
'rev_deleted'] );
46 if ( isset( $rowOverrides[
'rev_id'] ) ) {
47 $record->setId( $rowOverrides[
'rev_id'] );
50 if ( isset( $rowOverrides[
'rev_page'] ) ) {
51 $record->setPageId( $rowOverrides[
'rev_page'] );
55 $record->setComment( $comment );
56 $record->setUser(
$user );
57 $record->setTimestamp(
'20101010000000' );
64 $title->resetArticleID( 17 );
84 $this->assertSame(
$title, $rec->getPageAsLinkTarget(),
'getPageAsLinkTarget' );
85 $this->assertSame( $wikiId, $rec->getWikiId(),
'getWikiId' );
90 $title->resetArticleID( 17 );
92 yield
'not a wiki id' => [
114 $this->assertNull( $record->getId() );
115 $record->setId( 888 );
116 $this->assertSame( 888, $record->getId() );
122 $this->assertNull( $record->getUser() );
123 $record->setUser(
$user );
124 $this->assertSame(
$user, $record->getUser() );
129 $this->assertSame( 0, $record->getPageId() );
130 $record->setPageId( 999 );
131 $this->assertSame( 999, $record->getPageId() );
136 $this->assertNull( $record->getParentId() );
137 $record->setParentId( 100 );
138 $this->assertSame( 100, $record->getParentId() );
168 $record->setSlot( $slot );
175 $this->assertFalse( $record->isMinor() );
176 $record->setMinorEdit(
true );
177 $this->assertSame(
true, $record->isMinor() );
182 $this->assertNull( $record->getTimestamp() );
183 $record->setTimestamp(
'20180101010101' );
184 $this->assertSame(
'20180101010101', $record->getTimestamp() );
189 $this->assertSame( 0, $record->getVisibility() );
196 $this->assertSame(
'phoiac9h4m842xq45sp7s6u21eteeq1', $record->getSha1() );
197 $record->setSha1(
'someHash' );
198 $this->assertSame(
'someHash', $record->getSha1() );
208 $this->assertSame( 0, $record->getSize() );
209 $record->setSize( 775 );
210 $this->assertSame( 775, $record->getSize() );
216 $this->assertNull( $record->getComment() );
217 $record->setComment( $comment );
218 $this->assertSame( $comment, $record->getComment() );
226 'slot_revision_id' =>
null,
227 'slot_content_id' => 1,
228 'content_address' =>
null,
230 'role_name' =>
'main',
231 'slot_origin' =>
null
238 'slot_revision_id' =>
null,
239 'slot_content_id' => 1,
240 'content_address' =>
'foo',
242 'role_name' =>
'aux',
248 $record->setSlot( $mainSlot );
249 $record->setSlot( $auxSlot );
251 $this->assertSame( [
'main' ], $record->getOriginalSlots()->getSlotRoles() );
252 $this->assertSame( $mainSlot, $record->getOriginalSlots()->getSlot(
SlotRecord::MAIN ) );
254 $this->assertSame( [
'aux' ], $record->getInheritedSlots()->getSlotRoles() );
255 $this->assertSame( $auxSlot, $record->getInheritedSlots()->getSlot(
'aux' ) );
267 $record->removeSlot(
'b' );
269 $this->assertTrue( $record->hasSlot(
'a' ) );
270 $this->assertFalse( $record->hasSlot(
'b' ) );
281 $update->modifyContent(
'b', $x );
282 $update->modifyContent(
'c', $x );
283 $update->removeSlot(
'c' );
284 $update->removeSlot(
'd' );
291 $record->applyUpdate( $update );
293 $this->assertEquals( [
'b' ], array_keys( $record->getOriginalSlots()->getSlots() ) );
294 $this->assertEquals( $a, $record->getSlot(
'a' )->getContent() );
295 $this->assertEquals( $x, $record->getSlot(
'b' )->getContent() );
296 $this->assertFalse( $record->hasSlot(
'c' ) );
308 ->disableOriginalConstructor()
314 yield
'empty' => [
$rev ];
319 $rev->setComment( $comment );
320 yield
'no timestamp' => [
$rev ];
324 $rev->setComment( $comment );
325 $rev->setTimestamp(
'20101010000000' );
326 yield
'no content' => [
$rev ];
330 $rev->setComment( $comment );
331 $rev->setTimestamp(
'20101010000000' );
332 yield
'no user' => [
$rev ];
337 $rev->setTimestamp(
'20101010000000' );
338 yield
'no comment' => [
$rev ];
345 $this->assertFalse(
$rev->isReadyForInsertion() );