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