Improve return types in class MagicWordArray
[lhc/web/wiklou.git] / tests / phpunit / includes / Revision / NoContentModelRevisionStoreDbTest.php
1 <?php
2 namespace MediaWiki\Tests\Revision;
3
4 use Revision;
5
6 /**
7 * Tests RevisionStore against the pre-MCR, pre-ContentHandler DB schema.
8 *
9 * @covers \MediaWiki\Revision\RevisionStore
10 *
11 * @group RevisionStore
12 * @group Storage
13 * @group Database
14 * @group medium
15 */
16 class NoContentModelRevisionStoreDbTest extends RevisionStoreDbTestBase {
17
18 use PreMcrSchemaOverride;
19
20 protected function getContentHandlerUseDB() {
21 return false;
22 }
23
24 protected function revisionToRow( Revision $rev, $options = [ 'page', 'user', 'comment' ] ) {
25 $row = parent::revisionToRow( $rev, $options );
26
27 $row->rev_text_id = (string)$rev->getTextId();
28
29 return $row;
30 }
31
32 public function provideGetArchiveQueryInfo() {
33 yield [
34 [
35 'tables' => [ 'archive' ],
36 'fields' => array_merge(
37 $this->getDefaultArchiveFields(),
38 [
39 'ar_comment_text' => 'ar_comment',
40 'ar_comment_data' => 'NULL',
41 'ar_comment_cid' => 'NULL',
42 'ar_user_text' => 'ar_user_text',
43 'ar_user' => 'ar_user',
44 'ar_actor' => 'NULL',
45 ]
46 ),
47 'joins' => [],
48 ]
49 ];
50 }
51
52 public function provideGetQueryInfo() {
53 yield [
54 [],
55 [
56 'tables' => [ 'revision' ],
57 'fields' => array_merge(
58 $this->getDefaultQueryFields(),
59 $this->getCommentQueryFields(),
60 $this->getActorQueryFields()
61 ),
62 'joins' => [],
63 ]
64 ];
65 yield [
66 [ 'page' ],
67 [
68 'tables' => [ 'revision', 'page' ],
69 'fields' => array_merge(
70 $this->getDefaultQueryFields(),
71 $this->getCommentQueryFields(),
72 $this->getActorQueryFields(),
73 [
74 'page_namespace',
75 'page_title',
76 'page_id',
77 'page_latest',
78 'page_is_redirect',
79 'page_len',
80 ]
81 ),
82 'joins' => [
83 'page' => [ 'JOIN', [ 'page_id = rev_page' ] ],
84 ],
85 ]
86 ];
87 yield [
88 [ 'user' ],
89 [
90 'tables' => [ 'revision', 'user' ],
91 'fields' => array_merge(
92 $this->getDefaultQueryFields(),
93 $this->getCommentQueryFields(),
94 $this->getActorQueryFields(),
95 [
96 'user_name',
97 ]
98 ),
99 'joins' => [
100 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
101 ],
102 ]
103 ];
104 yield [
105 [ 'text' ],
106 [
107 'tables' => [ 'revision', 'text' ],
108 'fields' => array_merge(
109 $this->getDefaultQueryFields(),
110 $this->getCommentQueryFields(),
111 $this->getActorQueryFields(),
112 [
113 'old_text',
114 'old_flags',
115 ]
116 ),
117 'joins' => [
118 'text' => [ 'JOIN', [ 'rev_text_id=old_id' ] ],
119 ],
120 ]
121 ];
122 }
123
124 public function provideGetSlotsQueryInfo() {
125 $db = wfGetDB( DB_REPLICA );
126
127 yield [
128 [],
129 [
130 'tables' => [
131 'slots' => 'revision',
132 ],
133 'fields' => array_merge(
134 [
135 'slot_revision_id' => 'slots.rev_id',
136 'slot_content_id' => 'NULL',
137 'slot_origin' => 'slots.rev_id',
138 'role_name' => $db->addQuotes( SlotRecord::MAIN ),
139 ]
140 ),
141 'joins' => [],
142 ]
143 ];
144 yield [
145 [ 'content' ],
146 [
147 'tables' => [
148 'slots' => 'revision',
149 ],
150 'fields' => array_merge(
151 [
152 'slot_revision_id' => 'slots.rev_id',
153 'slot_content_id' => 'NULL',
154 'slot_origin' => 'slots.rev_id',
155 'role_name' => $db->addQuotes( SlotRecord::MAIN ),
156 'content_size' => 'slots.rev_len',
157 'content_sha1' => 'slots.rev_sha1',
158 'content_address' =>
159 $db->buildConcat( [ $db->addQuotes( 'tt:' ), 'slots.rev_text_id' ] ),
160 'model_name' => 'NULL',
161 ]
162 ),
163 'joins' => [],
164 ]
165 ];
166 }
167
168 public function provideNewMutableRevisionFromArray() {
169 foreach ( parent::provideNewMutableRevisionFromArray() as $case ) {
170 yield $case;
171 }
172
173 yield 'Basic array, with page & id' => [
174 [
175 'id' => 2,
176 'page' => 1,
177 'text_id' => 2,
178 'timestamp' => '20171017114835',
179 'user_text' => '111.0.1.2',
180 'user' => 0,
181 'minor_edit' => false,
182 'deleted' => 0,
183 'len' => 46,
184 'parent_id' => 1,
185 'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
186 'comment' => 'Goat Comment!',
187 ]
188 ];
189 }
190
191 }