Merge "Make LocalFile file locking calls use Status::wrap"
[lhc/web/wiklou.git] / tests / phpunit / includes / Storage / McrWriteBothRevisionStoreDbTest.php
1 <?php
2 namespace MediaWiki\Tests\Storage;
3
4 use MediaWiki\Storage\RevisionRecord;
5 use MediaWiki\Storage\SlotRecord;
6
7 /**
8 * Tests RevisionStore against the intermediate MCR DB schema for use during schema migration.
9 *
10 * @covers \MediaWiki\Storage\RevisionStore
11 *
12 * @group RevisionStore
13 * @group Storage
14 * @group Database
15 * @group medium
16 */
17 class McrWriteBothRevisionStoreDbTest extends RevisionStoreDbTestBase {
18
19 use McrWriteBothSchemaOverride;
20
21 protected function assertRevisionExistsInDatabase( RevisionRecord $rev ) {
22 parent::assertRevisionExistsInDatabase( $rev );
23
24 $this->assertSelect(
25 'slots', [ 'count(*)' ], [ 'slot_revision_id' => $rev->getId() ], [ [ '1' ] ]
26 );
27 $this->assertSelect(
28 'content',
29 [ 'count(*)' ],
30 [ 'content_address' => $rev->getSlot( 'main' )->getAddress() ],
31 [ [ '1' ] ]
32 );
33 }
34
35 /**
36 * @param SlotRecord $a
37 * @param SlotRecord $b
38 */
39 protected function assertSameSlotContent( SlotRecord $a, SlotRecord $b ) {
40 parent::assertSameSlotContent( $a, $b );
41
42 // Assert that the same content ID has been used
43 if ( $a->hasContentId() && $b->hasContentId() ) {
44 $this->assertSame( $a->getContentId(), $b->getContentId() );
45 }
46 }
47
48 public function provideGetArchiveQueryInfo() {
49 yield [
50 [
51 'tables' => [ 'archive' ],
52 'fields' => array_merge(
53 $this->getDefaultArchiveFields(),
54 [
55 'ar_comment_text' => 'ar_comment',
56 'ar_comment_data' => 'NULL',
57 'ar_comment_cid' => 'NULL',
58 'ar_user_text' => 'ar_user_text',
59 'ar_user' => 'ar_user',
60 'ar_actor' => 'NULL',
61 'ar_content_format',
62 'ar_content_model',
63 ]
64 ),
65 'joins' => [],
66 ]
67 ];
68 }
69
70 public function provideGetQueryInfo() {
71 yield [
72 [],
73 [
74 'tables' => [ 'revision' ],
75 'fields' => array_merge(
76 $this->getDefaultQueryFields(),
77 $this->getCommentQueryFields(),
78 $this->getActorQueryFields(),
79 $this->getContentHandlerQueryFields()
80 ),
81 'joins' => [],
82 ]
83 ];
84 yield [
85 [ 'page', 'user', 'text' ],
86 [
87 'tables' => [ 'revision', 'page', 'user', 'text' ],
88 'fields' => array_merge(
89 $this->getDefaultQueryFields(),
90 $this->getCommentQueryFields(),
91 $this->getActorQueryFields(),
92 $this->getContentHandlerQueryFields(),
93 [
94 'page_namespace',
95 'page_title',
96 'page_id',
97 'page_latest',
98 'page_is_redirect',
99 'page_len',
100 'user_name',
101 'old_text',
102 'old_flags',
103 ]
104 ),
105 'joins' => [
106 'page' => [ 'INNER JOIN', [ 'page_id = rev_page' ] ],
107 'user' => [ 'LEFT JOIN', [ 'rev_user != 0', 'user_id = rev_user' ] ],
108 'text' => [ 'INNER JOIN', [ 'rev_text_id=old_id' ] ],
109 ],
110 ]
111 ];
112 }
113
114 }