Merge "registration: Expose config array to ExtensionRegistry"
[lhc/web/wiklou.git] / tests / phpunit / includes / page / PageArchivePreMcrTest.php
1 <?php
2 use MediaWiki\MediaWikiServices;
3 use MediaWiki\Storage\SqlBlobStore;
4 use MediaWiki\Tests\Storage\PreMcrSchemaOverride;
5
6 /**
7 * Test class for page archiving, using the pre-MCR schema.
8 *
9 * @group ContentHandler
10 * @group Database
11 * ^--- important, causes temporary tables to be used instead of the real database
12 *
13 * @group medium
14 * ^--- important, causes tests not to fail with timeout
15 */
16 class PageArchivePreMcrTest extends PageArchiveTestBase {
17
18 use PreMcrSchemaOverride;
19
20 /**
21 * @covers PageArchive::getTextFromRow
22 */
23 public function testGetTextFromRow() {
24 $this->hideDeprecated( PageArchive::class . '::getTextFromRow' );
25
26 /** @var SqlBlobStore $blobStore */
27 $blobStore = MediaWikiServices::getInstance()->getBlobStore();
28
29 $textId = $blobStore->getTextIdFromAddress(
30 $this->firstRev->getSlot( 'main' )->getAddress()
31 );
32
33 $row = (object)[ 'ar_text_id' => $textId ];
34 $text = $this->archivedPage->getTextFromRow( $row );
35 $this->assertSame( 'testing', $text );
36 }
37
38 protected function getExpectedArchiveRows() {
39 /** @var SqlBlobStore $blobStore */
40 $blobStore = MediaWikiServices::getInstance()->getBlobStore();
41
42 return [
43 [
44 'ar_minor_edit' => '0',
45 'ar_user' => '0',
46 'ar_user_text' => $this->ipEditor,
47 'ar_actor' => null,
48 'ar_len' => '11',
49 'ar_deleted' => '0',
50 'ar_rev_id' => strval( $this->ipRev->getId() ),
51 'ar_timestamp' => $this->db->timestamp( $this->ipRev->getTimestamp() ),
52 'ar_sha1' => '0qdrpxl537ivfnx4gcpnzz0285yxryy',
53 'ar_page_id' => strval( $this->ipRev->getPageId() ),
54 'ar_comment_text' => 'just a test',
55 'ar_comment_data' => null,
56 'ar_comment_cid' => null,
57 'ar_content_format' => null,
58 'ar_content_model' => null,
59 'ts_tags' => null,
60 'ar_id' => '2',
61 'ar_namespace' => '0',
62 'ar_title' => 'PageArchiveTest_thePage',
63 'ar_text_id' => (string)$blobStore->getTextIdFromAddress(
64 $this->ipRev->getSlot( 'main' )->getAddress()
65 ),
66 'ar_parent_id' => strval( $this->ipRev->getParentId() ),
67 ],
68 [
69 'ar_minor_edit' => '0',
70 'ar_user' => (string)$this->getTestUser()->getUser()->getId(),
71 'ar_user_text' => $this->getTestUser()->getUser()->getName(),
72 'ar_actor' => null,
73 'ar_len' => '7',
74 'ar_deleted' => '0',
75 'ar_rev_id' => strval( $this->firstRev->getId() ),
76 'ar_timestamp' => $this->db->timestamp( $this->firstRev->getTimestamp() ),
77 'ar_sha1' => 'pr0s8e18148pxhgjfa0gjrvpy8fiyxc',
78 'ar_page_id' => strval( $this->firstRev->getPageId() ),
79 'ar_comment_text' => 'testing',
80 'ar_comment_data' => null,
81 'ar_comment_cid' => null,
82 'ar_content_format' => null,
83 'ar_content_model' => null,
84 'ts_tags' => null,
85 'ar_id' => '1',
86 'ar_namespace' => '0',
87 'ar_title' => 'PageArchiveTest_thePage',
88 'ar_text_id' => (string)$blobStore->getTextIdFromAddress(
89 $this->firstRev->getSlot( 'main' )->getAddress()
90 ),
91 'ar_parent_id' => '0',
92 ],
93 ];
94 }
95
96 }