MediaWiki  1.33.0
PageArchivePreMcrTest.php
Go to the documentation of this file.
1 <?php
6 
18 
20 
24  public function testGetTextFromRow() {
25  $this->hideDeprecated( PageArchive::class . '::getTextFromRow' );
26 
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() {
41  $blobStore = MediaWikiServices::getInstance()->getBlobStore();
42 
43  return [
44  [
45  'ar_minor_edit' => '0',
46  'ar_user' => null,
47  'ar_user_text' => $this->ipEditor,
48  'ar_actor' => (string)User::newFromName( $this->ipEditor, false )->getActorId( $this->db ),
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' => (string)$this->getTestUser()->getUser()->getActorId(),
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 }
PageArchivePreMcrTest
Test class for page archiving, using the pre-MCR schema.
Definition: PageArchivePreMcrTest.php:17
MediaWikiTestCase\getTestUser
static getTestUser( $groups=[])
Convenience method for getting an immutable test user.
Definition: MediaWikiTestCase.php:180
MediaWiki\Storage\SqlBlobStore
Service for storing and loading Content objects.
Definition: SqlBlobStore.php:49
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:585
PageArchiveTestBase
Base class for tests of PageArchive against different database schemas.
Definition: PageArchiveTestBase.php:8
MediaWiki\Tests\Revision\PreMcrSchemaOverride
trait PreMcrSchemaOverride
Trait providing schema overrides that allow tests to run against the pre-MCR database schema.
Definition: PreMcrSchemaOverride.php:10
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
MediaWikiTestCase\hideDeprecated
hideDeprecated( $function)
Don't throw a warning if $function is deprecated and called later.
Definition: MediaWikiTestCase.php:1974
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
string
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
Definition: hooks.txt:175
PageArchivePreMcrTest\getExpectedArchiveRows
getExpectedArchiveRows()
Definition: PageArchivePreMcrTest.php:39
PageArchivePreMcrTest\testGetTextFromRow
testGetTextFromRow()
PageArchive::getTextFromRow.
Definition: PageArchivePreMcrTest.php:24
class
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
Definition: maintenance.txt:52
object
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
Definition: globals.txt:25
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
PageArchiveTestBase\$ipEditor
$ipEditor
A logged out user who edited the page before it was archived.
Definition: PageArchiveTestBase.php:24
Revision\SlotRecord
Value object representing a content slot associated with a page revision.
Definition: SlotRecord.php:39