2012-05-10 20:56:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2015-11-15 02:29:37 +00:00
|
|
|
* @group LinksUpdate
|
2012-05-10 20:56:34 +00:00
|
|
|
* @group Database
|
|
|
|
|
* ^--- make sure temporary tables are used.
|
|
|
|
|
*/
|
2015-12-07 16:26:16 +00:00
|
|
|
class LinksUpdateTest extends MediaWikiLangTestCase {
|
2016-03-07 17:26:25 +00:00
|
|
|
protected static $testingPageId;
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
function __construct( $name = null, array $data = [], $dataName = '' ) {
|
2012-05-10 20:56:34 +00:00
|
|
|
parent::__construct( $name, $data, $dataName );
|
|
|
|
|
|
2012-10-02 08:39:30 +00:00
|
|
|
$this->tablesUsed = array_merge( $this->tablesUsed,
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2012-10-02 08:39:30 +00:00
|
|
|
'interwiki',
|
|
|
|
|
'page_props',
|
|
|
|
|
'pagelinks',
|
|
|
|
|
'categorylinks',
|
|
|
|
|
'langlinks',
|
|
|
|
|
'externallinks',
|
|
|
|
|
'imagelinks',
|
|
|
|
|
'templatelinks',
|
2015-08-24 17:40:06 +00:00
|
|
|
'iwlinks',
|
|
|
|
|
'recentchanges',
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2012-10-02 08:39:30 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-08 10:56:20 +00:00
|
|
|
protected function setUp() {
|
2012-10-23 17:02:36 +00:00
|
|
|
parent::setUp();
|
2012-05-10 20:56:34 +00:00
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
2012-10-02 08:39:30 +00:00
|
|
|
$dbw->replace(
|
|
|
|
|
'interwiki',
|
2016-02-17 09:09:32 +00:00
|
|
|
[ 'iw_prefix' ],
|
|
|
|
|
[
|
2012-10-02 08:39:30 +00:00
|
|
|
'iw_prefix' => 'linksupdatetest',
|
|
|
|
|
'iw_url' => 'http://testing.com/wiki/$1',
|
|
|
|
|
'iw_api' => 'http://testing.com/w/api.php',
|
|
|
|
|
'iw_local' => 0,
|
|
|
|
|
'iw_trans' => 0,
|
|
|
|
|
'iw_wikiid' => 'linksupdatetest',
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2012-10-02 08:39:30 +00:00
|
|
|
);
|
2015-08-24 17:40:06 +00:00
|
|
|
$this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-07 17:26:25 +00:00
|
|
|
public function addDBDataOnce() {
|
2015-12-11 13:17:51 +00:00
|
|
|
$res = $this->insertPage( 'Testing' );
|
2016-03-07 17:26:25 +00:00
|
|
|
self::$testingPageId = $res['id'];
|
2015-08-24 17:40:06 +00:00
|
|
|
$this->insertPage( 'Some_other_page' );
|
|
|
|
|
$this->insertPage( 'Template:TestingTemplate' );
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function makeTitleAndParserOutput( $name, $id ) {
|
|
|
|
|
$t = Title::newFromText( $name );
|
|
|
|
|
$t->mArticleID = $id; # XXX: this is fugly
|
|
|
|
|
|
|
|
|
|
$po = new ParserOutput();
|
|
|
|
|
$po->setTitleText( $t->getPrefixedText() );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return [ $t, $po ];
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addLink
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_pagelinks() {
|
2015-12-11 13:17:51 +00:00
|
|
|
/** @var Title $t */
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2016-03-07 17:26:25 +00:00
|
|
|
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po->addLink( Title::newFromText( "Foo" ) );
|
|
|
|
|
$po->addLink( Title::newFromText( "Special:Foo" ) ); // special namespace should be ignored
|
|
|
|
|
$po->addLink( Title::newFromText( "linksupdatetest:Foo" ) ); // interwiki link should be ignored
|
|
|
|
|
$po->addLink( Title::newFromText( "#Foo" ) ); // hash link should be ignored
|
|
|
|
|
|
2014-04-24 10:05:52 +00:00
|
|
|
$update = $this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'pagelinks',
|
|
|
|
|
'pl_namespace,
|
|
|
|
|
pl_title',
|
2016-03-07 17:26:25 +00:00
|
|
|
'pl_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ NS_MAIN, 'Foo' ] ]
|
2014-04-24 10:05:52 +00:00
|
|
|
);
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertArrayEquals( [
|
2013-10-09 18:48:37 +00:00
|
|
|
Title::makeTitle( NS_MAIN, 'Foo' ), // newFromText doesn't yield the same internal state....
|
2016-02-17 09:09:32 +00:00
|
|
|
], $update->getAddedLinks() );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po = new ParserOutput();
|
|
|
|
|
$po->setTitleText( $t->getPrefixedText() );
|
|
|
|
|
|
|
|
|
|
$po->addLink( Title::newFromText( "Bar" ) );
|
2013-10-09 18:48:37 +00:00
|
|
|
$po->addLink( Title::newFromText( "Talk:Bar" ) );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2014-04-24 10:05:52 +00:00
|
|
|
$update = $this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'pagelinks',
|
|
|
|
|
'pl_namespace,
|
|
|
|
|
pl_title',
|
2016-03-07 17:26:25 +00:00
|
|
|
'pl_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[ NS_MAIN, 'Bar' ],
|
|
|
|
|
[ NS_TALK, 'Bar' ],
|
|
|
|
|
]
|
2014-04-24 10:05:52 +00:00
|
|
|
);
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->assertArrayEquals( [
|
2013-10-09 18:48:37 +00:00
|
|
|
Title::makeTitle( NS_MAIN, 'Bar' ),
|
|
|
|
|
Title::makeTitle( NS_TALK, 'Bar' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
], $update->getAddedLinks() );
|
|
|
|
|
$this->assertArrayEquals( [
|
2013-10-09 18:48:37 +00:00
|
|
|
Title::makeTitle( NS_MAIN, 'Foo' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
], $update->getRemovedLinks() );
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addExternalLink
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_externallinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2016-03-07 17:26:25 +00:00
|
|
|
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po->addExternalLink( "http://testing.com/wiki/Foo" );
|
|
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'externallinks',
|
|
|
|
|
'el_to, el_index',
|
2016-03-07 17:26:25 +00:00
|
|
|
'el_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[ 'http://testing.com/wiki/Foo', 'http://com.testing./wiki/Foo' ],
|
|
|
|
|
]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addCategory
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_categorylinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2013-03-01 20:02:42 +00:00
|
|
|
$this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
|
|
|
|
|
|
2016-03-07 17:26:25 +00:00
|
|
|
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po->addCategory( "Foo", "FOO" );
|
|
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'categorylinks',
|
|
|
|
|
'cl_to, cl_sortkey',
|
2016-03-07 17:26:25 +00:00
|
|
|
'cl_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'Foo', "FOO\nTESTING" ] ]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2015-08-24 17:40:06 +00:00
|
|
|
public function testOnAddingAndRemovingCategory_recentChangesRowIsAdded() {
|
|
|
|
|
$this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
|
|
|
|
|
|
|
|
|
|
$title = Title::newFromText( 'Testing' );
|
|
|
|
|
$wikiPage = new WikiPage( $title );
|
|
|
|
|
$wikiPage->doEditContent( new WikitextContent( '[[Category:Foo]]' ), 'added category' );
|
2015-11-15 02:29:37 +00:00
|
|
|
$this->runAllRelatedJobs();
|
2015-08-24 17:40:06 +00:00
|
|
|
|
|
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$title,
|
|
|
|
|
$wikiPage->getParserOutput( new ParserOptions() ),
|
|
|
|
|
Title::newFromText( 'Category:Foo' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'Foo', '[[:Testing]] added to category' ] ]
|
2015-08-24 17:40:06 +00:00
|
|
|
);
|
|
|
|
|
|
2015-11-15 02:29:37 +00:00
|
|
|
$wikiPage->doEditContent( new WikitextContent( '[[Category:Bar]]' ), 'replaced category' );
|
|
|
|
|
$this->runAllRelatedJobs();
|
|
|
|
|
|
2015-08-24 17:40:06 +00:00
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$title,
|
|
|
|
|
$wikiPage->getParserOutput( new ParserOptions() ),
|
|
|
|
|
Title::newFromText( 'Category:Foo' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[ 'Foo', '[[:Testing]] added to category' ],
|
|
|
|
|
[ 'Foo', '[[:Testing]] removed from category' ],
|
|
|
|
|
]
|
2015-08-24 17:40:06 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$title,
|
|
|
|
|
$wikiPage->getParserOutput( new ParserOptions() ),
|
|
|
|
|
Title::newFromText( 'Category:Bar' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
|
|
|
|
[ 'Bar', '[[:Testing]] added to category' ],
|
|
|
|
|
]
|
2015-08-24 17:40:06 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testOnAddingAndRemovingCategoryToTemplates_embeddingPagesAreIgnored() {
|
|
|
|
|
$this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
|
|
|
|
|
|
|
|
|
|
$templateTitle = Title::newFromText( 'Template:TestingTemplate' );
|
|
|
|
|
$templatePage = new WikiPage( $templateTitle );
|
|
|
|
|
|
|
|
|
|
$wikiPage = new WikiPage( Title::newFromText( 'Testing' ) );
|
|
|
|
|
$wikiPage->doEditContent( new WikitextContent( '{{TestingTemplate}}' ), 'added template' );
|
2015-11-15 02:29:37 +00:00
|
|
|
$this->runAllRelatedJobs();
|
|
|
|
|
|
2015-08-24 17:40:06 +00:00
|
|
|
$otherWikiPage = new WikiPage( Title::newFromText( 'Some_other_page' ) );
|
|
|
|
|
$otherWikiPage->doEditContent( new WikitextContent( '{{TestingTemplate}}' ), 'added template' );
|
2015-11-15 02:29:37 +00:00
|
|
|
$this->runAllRelatedJobs();
|
|
|
|
|
|
|
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$templateTitle,
|
|
|
|
|
$templatePage->getParserOutput( new ParserOptions() ),
|
|
|
|
|
Title::newFromText( 'Baz' ),
|
2016-02-17 09:09:32 +00:00
|
|
|
[]
|
2015-11-15 02:29:37 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$templatePage->doEditContent( new WikitextContent( '[[Category:Baz]]' ), 'added category' );
|
|
|
|
|
$this->runAllRelatedJobs();
|
2015-08-24 17:40:06 +00:00
|
|
|
|
|
|
|
|
$this->assertRecentChangeByCategorization(
|
|
|
|
|
$templateTitle,
|
|
|
|
|
$templatePage->getParserOutput( new ParserOptions() ),
|
2015-11-15 02:29:37 +00:00
|
|
|
Title::newFromText( 'Baz' ),
|
2016-02-26 10:28:16 +00:00
|
|
|
[ [
|
|
|
|
|
'Baz',
|
|
|
|
|
'[[:Template:TestingTemplate]] and [[Special:WhatLinksHere/Template:TestingTemplate|2 pages]] '
|
|
|
|
|
. 'added to category'
|
|
|
|
|
] ]
|
2015-08-24 17:40:06 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addInterwikiLink
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_iwlinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2016-03-07 17:26:25 +00:00
|
|
|
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$target = Title::makeTitleSafe( NS_MAIN, "Foo", '', 'linksupdatetest' );
|
|
|
|
|
$po->addInterwikiLink( $target );
|
|
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'iwlinks',
|
|
|
|
|
'iwl_prefix, iwl_title',
|
2016-03-07 17:26:25 +00:00
|
|
|
'iwl_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'linksupdatetest', 'Foo' ] ]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addTemplate
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_templatelinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2016-03-07 17:26:25 +00:00
|
|
|
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po->addTemplate( Title::newFromText( "Template:Foo" ), 23, 42 );
|
|
|
|
|
|
2014-04-24 10:05:52 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'templatelinks',
|
|
|
|
|
'tl_namespace,
|
|
|
|
|
tl_title',
|
2016-03-07 17:26:25 +00:00
|
|
|
'tl_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ NS_TEMPLATE, 'Foo' ] ]
|
2014-04-24 10:05:52 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addImage
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_imagelinks() {
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2016-03-07 17:26:25 +00:00
|
|
|
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$po->addImage( "Foo.png" );
|
|
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'imagelinks',
|
|
|
|
|
'il_to',
|
2016-03-07 17:26:25 +00:00
|
|
|
'il_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'Foo.png' ] ]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::addLanguageLink
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_langlinks() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->setMwGlobals( [
|
2014-07-07 23:21:09 +00:00
|
|
|
'wgCapitalLinks' => true,
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
2014-07-07 23:21:09 +00:00
|
|
|
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2016-03-07 17:26:25 +00:00
|
|
|
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2012-12-07 11:33:47 +00:00
|
|
|
$po->addLanguageLink( Title::newFromText( "en:Foo" )->getFullText() );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
|
|
|
|
$t,
|
|
|
|
|
$po,
|
|
|
|
|
'langlinks',
|
|
|
|
|
'll_lang, ll_title',
|
2016-03-07 17:26:25 +00:00
|
|
|
'll_from = ' . self::$testingPageId,
|
2016-02-17 09:09:32 +00:00
|
|
|
[ [ 'En', 'Foo' ] ]
|
2015-12-11 13:17:51 +00:00
|
|
|
);
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-10-24 16:45:52 +00:00
|
|
|
/**
|
2014-02-27 19:10:59 +00:00
|
|
|
* @covers ParserOutput::setProperty
|
2013-10-24 16:45:52 +00:00
|
|
|
*/
|
2012-05-10 20:56:34 +00:00
|
|
|
public function testUpdate_page_props() {
|
2014-03-31 11:00:28 +00:00
|
|
|
global $wgPagePropsHaveSortkey;
|
|
|
|
|
|
2014-02-27 19:10:59 +00:00
|
|
|
/** @var ParserOutput $po */
|
2016-03-07 17:26:25 +00:00
|
|
|
list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$fields = [ 'pp_propname', 'pp_value' ];
|
|
|
|
|
$expected = [];
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2014-03-31 11:00:28 +00:00
|
|
|
$po->setProperty( "bool", true );
|
2016-02-17 09:09:32 +00:00
|
|
|
$expected[] = [ "bool", true ];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
2014-07-19 21:12:10 +00:00
|
|
|
$po->setProperty( "float", 4.0 + 1.0 / 4.0 );
|
2016-02-17 09:09:32 +00:00
|
|
|
$expected[] = [ "float", 4.0 + 1.0 / 4.0 ];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
|
|
|
|
$po->setProperty( "int", -7 );
|
2016-02-17 09:09:32 +00:00
|
|
|
$expected[] = [ "int", -7 ];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
|
|
|
|
$po->setProperty( "string", "33 bar" );
|
2016-02-17 09:09:32 +00:00
|
|
|
$expected[] = [ "string", "33 bar" ];
|
2014-03-31 11:00:28 +00:00
|
|
|
|
|
|
|
|
// compute expected sortkey values
|
|
|
|
|
if ( $wgPagePropsHaveSortkey ) {
|
|
|
|
|
$fields[] = 'pp_sortkey';
|
|
|
|
|
|
|
|
|
|
foreach ( $expected as &$row ) {
|
|
|
|
|
$value = $row[1];
|
|
|
|
|
|
|
|
|
|
if ( is_int( $value ) || is_float( $value ) || is_bool( $value ) ) {
|
|
|
|
|
$row[] = floatval( $value );
|
|
|
|
|
} else {
|
|
|
|
|
$row[] = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-11 13:17:51 +00:00
|
|
|
$this->assertLinksUpdate(
|
2016-03-07 17:26:25 +00:00
|
|
|
$t, $po, 'page_props', $fields, 'pp_page = ' . self::$testingPageId, $expected );
|
2014-03-31 11:00:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testUpdate_page_props_without_sortkey() {
|
|
|
|
|
$this->setMwGlobals( 'wgPagePropsHaveSortkey', false );
|
|
|
|
|
|
|
|
|
|
$this->testUpdate_page_props();
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-15 01:12:35 +00:00
|
|
|
// @todo test recursive, too!
|
2012-05-10 20:56:34 +00:00
|
|
|
|
2014-04-24 10:05:52 +00:00
|
|
|
protected function assertLinksUpdate( Title $title, ParserOutput $parserOutput,
|
|
|
|
|
$table, $fields, $condition, array $expectedRows
|
|
|
|
|
) {
|
2012-05-10 20:56:34 +00:00
|
|
|
$update = new LinksUpdate( $title, $parserOutput );
|
|
|
|
|
|
2015-09-11 13:44:59 +00:00
|
|
|
// NOTE: make sure LinksUpdate does not generate warnings when called inside a transaction.
|
2012-06-13 15:43:07 +00:00
|
|
|
$update->beginTransaction();
|
2012-05-10 20:56:34 +00:00
|
|
|
$update->doUpdate();
|
2012-06-13 15:43:07 +00:00
|
|
|
$update->commitTransaction();
|
2012-05-10 20:56:34 +00:00
|
|
|
|
|
|
|
|
$this->assertSelect( $table, $fields, $condition, $expectedRows );
|
2013-10-09 18:48:37 +00:00
|
|
|
return $update;
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|
2015-08-24 17:40:06 +00:00
|
|
|
|
|
|
|
|
protected function assertRecentChangeByCategorization(
|
|
|
|
|
Title $pageTitle, ParserOutput $parserOutput, Title $categoryTitle, $expectedRows
|
|
|
|
|
) {
|
|
|
|
|
$this->assertSelect(
|
|
|
|
|
'recentchanges',
|
|
|
|
|
'rc_title, rc_comment',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2015-08-24 17:40:06 +00:00
|
|
|
'rc_type' => RC_CATEGORIZE,
|
|
|
|
|
'rc_namespace' => NS_CATEGORY,
|
|
|
|
|
'rc_title' => $categoryTitle->getDBkey()
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2015-08-24 17:40:06 +00:00
|
|
|
$expectedRows
|
|
|
|
|
);
|
|
|
|
|
}
|
2015-11-15 02:29:37 +00:00
|
|
|
|
|
|
|
|
private function runAllRelatedJobs() {
|
|
|
|
|
$queueGroup = JobQueueGroup::singleton();
|
|
|
|
|
while ( $job = $queueGroup->pop( 'refreshLinksPrioritized' ) ) {
|
|
|
|
|
$job->run();
|
|
|
|
|
$queueGroup->ack( $job );
|
|
|
|
|
}
|
|
|
|
|
while ( $job = $queueGroup->pop( 'categoryMembershipChange' ) ) {
|
|
|
|
|
$job->run();
|
|
|
|
|
$queueGroup->ack( $job );
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-05-10 20:56:34 +00:00
|
|
|
}
|