6use InvalidArgumentException;
34 $title = Title::newFromText(
'Dummy' );
35 $title->resetArticleID( 17 );
38 $comment = CommentStoreComment::newUnsavedComment(
'Hello World' );
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'] );
54 $record->setContent( SlotRecord::MAIN,
new TextContent(
'Lorem Ipsum' ) );
55 $record->setComment( $comment );
56 $record->setUser( $user );
57 $record->setTimestamp(
'20101010000000' );
63 $title = Title::newFromText(
'Dummy' );
64 $title->resetArticleID( 17 );
84 $this->assertSame( $title, $rec->getPageAsLinkTarget(),
'getPageAsLinkTarget' );
85 $this->assertSame( $wikiId, $rec->getWikiId(),
'getWikiId' );
89 $title = Title::newFromText(
'Dummy' );
90 $title->resetArticleID( 17 );
92 yield
'not a wiki id' => [
108 $this->setExpectedException( InvalidArgumentException::class );
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() );
143 $this->setExpectedException( RevisionAccessException::class );
144 $this->assertNull( $record->getContent( SlotRecord::MAIN ) );
150 $record->setContent( SlotRecord::MAIN,
$content );
151 $this->assertSame(
$content, $record->getContent( SlotRecord::MAIN ) );
156 $this->assertFalse( $record->hasSlot( SlotRecord::MAIN ) );
158 $this->setExpectedException( RevisionAccessException::class );
159 $record->getSlot( SlotRecord::MAIN );
164 $slot = SlotRecord::newUnsaved(
168 $record->setSlot( $slot );
169 $this->assertTrue( $record->hasSlot( SlotRecord::MAIN ) );
170 $this->assertSame( $slot, $record->getSlot( SlotRecord::MAIN ) );
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() );
190 $record->setVisibility( RevisionRecord::DELETED_USER );
191 $this->assertSame( RevisionRecord::DELETED_USER, $record->getVisibility() );
196 $this->assertSame(
'phoiac9h4m842xq45sp7s6u21eteeq1', $record->getSha1() );
197 $record->setSha1(
'someHash' );
198 $this->assertSame(
'someHash', $record->getSha1() );
203 $this->assertInstanceOf( MutableRevisionSlots::class, $record->getSlots() );
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' ) );
264 $record->inheritSlot( SlotRecord::newSaved( 7, 3,
'a', SlotRecord::newUnsaved(
'a', $a ) ) );
265 $record->inheritSlot( SlotRecord::newSaved( 7, 4,
'b', SlotRecord::newUnsaved(
'b', $b ) ) );
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' );
287 $record->inheritSlot( SlotRecord::newSaved( 7, 3,
'a', SlotRecord::newUnsaved(
'a', $a ) ) );
288 $record->inheritSlot( SlotRecord::newSaved( 7, 4,
'b', SlotRecord::newUnsaved(
'b', $b ) ) );
289 $record->inheritSlot( SlotRecord::newSaved( 7, 5,
'c', SlotRecord::newUnsaved(
'c', $c ) ) );
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' ) );
301 $title = $this->getMock( Title::class );
304 $user = $this->getMock( User::class );
307 $comment = $this->getMockBuilder( CommentStoreComment::class )
308 ->disableOriginalConstructor()
314 yield
'empty' => [
$rev ];
318 $rev->setUser( $user );
319 $rev->setComment( $comment );
320 yield
'no timestamp' => [
$rev ];
323 $rev->setUser( $user );
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 ];
335 $rev->setUser( $user );
337 $rev->setTimestamp(
'20101010000000' );
338 yield
'no comment' => [
$rev ];
345 $this->assertFalse(
$rev->isReadyForInsertion() );
Content object implementation for representing flat text.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Content object for wiki text pages.
namespace and then decline to actually register it file or subcat img or subcat $title
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc $rev
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))