MediaWiki REL1_33
RevisionStoreCacheRecordTest.php
Go to the documentation of this file.
1<?php
3
4use Title;
13
20
27 protected function newRevision( array $rowOverrides = [], $callback = false ) {
28 $title = Title::newFromText( 'Dummy' );
29 $title->resetArticleID( 17 );
30
31 $user = new UserIdentityValue( 11, 'Tester', 0 );
32 $comment = CommentStoreComment::newUnsavedComment( 'Hello World' );
33
34 $main = SlotRecord::newUnsaved( SlotRecord::MAIN, new TextContent( 'Lorem Ipsum' ) );
35 $aux = SlotRecord::newUnsaved( 'aux', new TextContent( 'Frumious Bandersnatch' ) );
36 $slots = new RevisionSlots( [ $main, $aux ] );
37
38 $row = [
39 'rev_id' => '7',
40 'rev_page' => strval( $title->getArticleID() ),
41 'rev_timestamp' => '20200101000000',
42 'rev_deleted' => 0,
43 'rev_minor_edit' => 0,
44 'rev_parent_id' => '5',
45 'rev_len' => $slots->computeSize(),
46 'rev_sha1' => $slots->computeSha1(),
47 'rev_user' => '11',
48 'page_latest' => '18',
49 ];
50
51 $row = array_merge( $row, $rowOverrides );
52
53 if ( !$callback ) {
54 $callback = function ( $revId ) use ( $row ) {
55 return (object)$row;
56 };
57 }
58
59 return new RevisionStoreCacheRecord(
60 $callback,
61 $title,
62 $user,
63 $comment,
64 (object)$row,
65 $slots
66 );
67 }
68
69 public function testCallback() {
70 // Provide a callback that returns non-default values. Asserting the revision returns
71 // these values confirms callback execution and behavior. Also confirm the callback
72 // is only invoked once, even for multiple getter calls.
73 $rowOverrides = [
74 'rev_deleted' => RevisionRecord::DELETED_TEXT,
75 'rev_user' => 12,
76 ];
77 $callbackInvoked = 0;
78 $callback = function ( $revId ) use ( &$callbackInvoked, $rowOverrides ) {
79 $callbackInvoked++;
80 return (object)$rowOverrides;
81 };
82 $rev = $this->newRevision( [], $callback );
83
84 $this->assertSame( RevisionRecord::DELETED_TEXT, $rev->getVisibility() );
85 $this->assertSame( 12, $rev->getUser()->getId() );
86 $this->assertSame( 1, $callbackInvoked );
87 }
88
89}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
CommentStoreComment represents a comment stored by CommentStore.
Page revision base class.
Value object representing the set of slots belonging to a revision.
A RevisionRecord representing an existing revision persisted in the revision table.
Value object representing a content slot associated with a page revision.
\MediaWiki\Revision\RevisionStoreCacheRecord \MediaWiki\Revision\RevisionStoreRecord \MediaWiki\Revis...
\MediaWiki\Revision\RevisionStoreRecord \MediaWiki\Revision\RevisionRecord
Value object representing a user's identity.
Content object implementation for representing flat text.
Represents a title within MediaWiki.
Definition Title.php:40
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
Definition hooks.txt:1779
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))