MediaWiki REL1_33
RefreshLinksJobTest.php
Go to the documentation of this file.
1<?php
3
14
15 public function setUp() {
16 parent::setUp();
17
18 $this->tablesUsed[] = 'page';
19 $this->tablesUsed[] = 'revision';
20
21 $this->tablesUsed[] = 'pagelinks';
22 $this->tablesUsed[] = 'categorylinks';
23 }
24
31 private function createPage( $name, array $content ) {
32 $title = Title::makeTitle( $this->getDefaultWikitextNS(), $name );
33 $page = WikiPage::factory( $title );
34
35 $updater = $page->newPageUpdater( $this->getTestUser()->getUser() );
36
37 foreach ( $content as $slot => $cnt ) {
38 $updater->setContent( $slot, $cnt );
39 }
40
41 $updater->saveRevision( CommentStoreComment::newUnsavedComment( 'Test' ) );
42
43 return $page;
44 }
45
46 // TODO: test multi-page
47 // TODO: test recursive
48 // TODO: test partition
49
50 public function testRunForSinglePage() {
51 MediaWikiServices::getInstance()->getSlotRoleRegistry()->defineRoleWithModel(
52 'aux',
54 );
55
56 $mainContent = new WikitextContent( 'MAIN [[Kittens]]' );
57 $auxContent = new WikitextContent( 'AUX [[Category:Goats]]' );
58 $page = $this->createPage( __METHOD__, [ 'main' => $mainContent, 'aux' => $auxContent ] );
59
60 // clear state
61 $parserCache = MediaWikiServices::getInstance()->getParserCache();
62 $parserCache->deleteOptionsKey( $page );
63
64 $this->db->delete( 'pagelinks', '*', __METHOD__ );
65 $this->db->delete( 'categorylinks', '*', __METHOD__ );
66
67 // run job
68 $job = new RefreshLinksJob( $page->getTitle(), [ 'parseThreshold' => 0 ] );
69 $job->run();
70
71 // assert state
72 $options = ParserOptions::newCanonical( 'canonical' );
73 $out = $parserCache->get( $page, $options );
74 $this->assertNotFalse( $out, 'parser cache entry' );
75
76 $text = $out->getText();
77 $this->assertContains( 'MAIN', $text );
78 $this->assertContains( 'AUX', $text );
79
80 $this->assertSelect(
81 'pagelinks',
82 'pl_title',
83 [ 'pl_from' => $page->getId() ],
84 [ [ 'Kittens' ] ]
85 );
86 $this->assertSelect(
87 'categorylinks',
88 'cl_to',
89 [ 'cl_from' => $page->getId() ],
90 [ [ 'Goats' ] ]
91 );
92 }
93
94}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
getDefaultWikitextNS()
Returns the ID of a namespace that defaults to Wikitext.
static getTestUser( $groups=[])
Convenience method for getting an immutable test user.
assertSelect( $table, $fields, $condition, array $expectedRows, array $options=[], array $join_conds=[])
Asserts that the given database query yields the rows given by $expectedRows.
MediaWikiServices is the service locator for the application scope of MediaWiki.
createPage( $name, array $content)
Job to update link tables for pages.
Content object for wiki text pages.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition hooks.txt:855
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1999
const CONTENT_MODEL_WIKITEXT
Definition Defines.php:244
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$page->newPageUpdater($user) $updater
$content
if(count( $args)< 1) $job