* ^--- make sure temporary tables are used.
*/
class LinksUpdateTest extends MediaWikiLangTestCase {
- protected $testingPageId;
+ protected static $testingPageId;
- function __construct( $name = null, array $data = array(), $dataName = '' ) {
+ function __construct( $name = null, array $data = [], $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
$this->tablesUsed = array_merge( $this->tablesUsed,
- array(
+ [
'interwiki',
'page_props',
'pagelinks',
'templatelinks',
'iwlinks',
'recentchanges',
- )
+ ]
);
}
$dbw = wfGetDB( DB_MASTER );
$dbw->replace(
'interwiki',
- array( 'iw_prefix' ),
- array(
+ [ 'iw_prefix' ],
+ [
'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',
- )
+ ]
);
$this->setMwGlobals( 'wgRCWatchCategoryMembership', true );
}
- public function addDBData() {
+ public function addDBDataOnce() {
$res = $this->insertPage( 'Testing' );
- $this->testingPageId = $res['id'];
+ self::$testingPageId = $res['id'];
$this->insertPage( 'Some_other_page' );
$this->insertPage( 'Template:TestingTemplate' );
}
$po = new ParserOutput();
$po->setTitleText( $t->getPrefixedText() );
- return array( $t, $po );
+ return [ $t, $po ];
}
/**
public function testUpdate_pagelinks() {
/** @var Title $t */
/** @var ParserOutput $po */
- list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
$po->addLink( Title::newFromText( "Foo" ) );
$po->addLink( Title::newFromText( "Special:Foo" ) ); // special namespace should be ignored
'pagelinks',
'pl_namespace,
pl_title',
- 'pl_from = ' . $this->testingPageId,
- array( array( NS_MAIN, 'Foo' ) )
+ 'pl_from = ' . self::$testingPageId,
+ [ [ NS_MAIN, 'Foo' ] ]
);
- $this->assertArrayEquals( array(
+ $this->assertArrayEquals( [
Title::makeTitle( NS_MAIN, 'Foo' ), // newFromText doesn't yield the same internal state....
- ), $update->getAddedLinks() );
+ ], $update->getAddedLinks() );
$po = new ParserOutput();
$po->setTitleText( $t->getPrefixedText() );
'pagelinks',
'pl_namespace,
pl_title',
- 'pl_from = ' . $this->testingPageId,
- array(
- array( NS_MAIN, 'Bar' ),
- array( NS_TALK, 'Bar' ),
- )
+ 'pl_from = ' . self::$testingPageId,
+ [
+ [ NS_MAIN, 'Bar' ],
+ [ NS_TALK, 'Bar' ],
+ ]
);
- $this->assertArrayEquals( array(
+ $this->assertArrayEquals( [
Title::makeTitle( NS_MAIN, 'Bar' ),
Title::makeTitle( NS_TALK, 'Bar' ),
- ), $update->getAddedLinks() );
- $this->assertArrayEquals( array(
+ ], $update->getAddedLinks() );
+ $this->assertArrayEquals( [
Title::makeTitle( NS_MAIN, 'Foo' ),
- ), $update->getRemovedLinks() );
+ ], $update->getRemovedLinks() );
}
/**
*/
public function testUpdate_externallinks() {
/** @var ParserOutput $po */
- list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
$po->addExternalLink( "http://testing.com/wiki/Foo" );
$po,
'externallinks',
'el_to, el_index',
- 'el_from = ' . $this->testingPageId,
- array(
- array( 'http://testing.com/wiki/Foo', 'http://com.testing./wiki/Foo' ),
- )
+ 'el_from = ' . self::$testingPageId,
+ [
+ [ 'http://testing.com/wiki/Foo', 'http://com.testing./wiki/Foo' ],
+ ]
);
}
/** @var ParserOutput $po */
$this->setMwGlobals( 'wgCategoryCollation', 'uppercase' );
- list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
$po->addCategory( "Foo", "FOO" );
$po,
'categorylinks',
'cl_to, cl_sortkey',
- 'cl_from = ' . $this->testingPageId,
- array( array( 'Foo', "FOO\nTESTING" ) )
+ 'cl_from = ' . self::$testingPageId,
+ [ [ 'Foo', "FOO\nTESTING" ] ]
);
}
$title,
$wikiPage->getParserOutput( new ParserOptions() ),
Title::newFromText( 'Category:Foo' ),
- array( array( 'Foo', '[[:Testing]] added to category' ) )
+ [ [ 'Foo', '[[:Testing]] added to category' ] ]
);
$wikiPage->doEditContent( new WikitextContent( '[[Category:Bar]]' ), 'replaced category' );
$title,
$wikiPage->getParserOutput( new ParserOptions() ),
Title::newFromText( 'Category:Foo' ),
- array(
- array( 'Foo', '[[:Testing]] added to category' ),
- array( 'Foo', '[[:Testing]] removed from category' ),
- )
+ [
+ [ 'Foo', '[[:Testing]] added to category' ],
+ [ 'Foo', '[[:Testing]] removed from category' ],
+ ]
);
$this->assertRecentChangeByCategorization(
$title,
$wikiPage->getParserOutput( new ParserOptions() ),
Title::newFromText( 'Category:Bar' ),
- array(
- array( 'Bar', '[[:Testing]] added to category' ),
- )
+ [
+ [ 'Bar', '[[:Testing]] added to category' ],
+ ]
);
}
$templateTitle,
$templatePage->getParserOutput( new ParserOptions() ),
Title::newFromText( 'Baz' ),
- array()
+ []
);
$templatePage->doEditContent( new WikitextContent( '[[Category:Baz]]' ), 'added category' );
$templateTitle,
$templatePage->getParserOutput( new ParserOptions() ),
Title::newFromText( 'Baz' ),
- array( array( 'Baz', '[[:Template:TestingTemplate]] and 2 pages added to category' ) )
+ [ [
+ 'Baz',
+ '[[:Template:TestingTemplate]] added to category, ' .
+ '[[Special:WhatLinksHere/Template:TestingTemplate|this page is included within other pages]]'
+ ] ]
);
}
*/
public function testUpdate_iwlinks() {
/** @var ParserOutput $po */
- list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
$target = Title::makeTitleSafe( NS_MAIN, "Foo", '', 'linksupdatetest' );
$po->addInterwikiLink( $target );
$po,
'iwlinks',
'iwl_prefix, iwl_title',
- 'iwl_from = ' . $this->testingPageId,
- array( array( 'linksupdatetest', 'Foo' ) )
+ 'iwl_from = ' . self::$testingPageId,
+ [ [ 'linksupdatetest', 'Foo' ] ]
);
}
*/
public function testUpdate_templatelinks() {
/** @var ParserOutput $po */
- list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
$po->addTemplate( Title::newFromText( "Template:Foo" ), 23, 42 );
'templatelinks',
'tl_namespace,
tl_title',
- 'tl_from = ' . $this->testingPageId,
- array( array( NS_TEMPLATE, 'Foo' ) )
+ 'tl_from = ' . self::$testingPageId,
+ [ [ NS_TEMPLATE, 'Foo' ] ]
);
}
*/
public function testUpdate_imagelinks() {
/** @var ParserOutput $po */
- list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
$po->addImage( "Foo.png" );
$po,
'imagelinks',
'il_to',
- 'il_from = ' . $this->testingPageId,
- array( array( 'Foo.png' ) )
+ 'il_from = ' . self::$testingPageId,
+ [ [ 'Foo.png' ] ]
);
}
* @covers ParserOutput::addLanguageLink
*/
public function testUpdate_langlinks() {
- $this->setMwGlobals( array(
+ $this->setMwGlobals( [
'wgCapitalLinks' => true,
- ) );
+ ] );
/** @var ParserOutput $po */
- list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
$po->addLanguageLink( Title::newFromText( "en:Foo" )->getFullText() );
$po,
'langlinks',
'll_lang, ll_title',
- 'll_from = ' . $this->testingPageId,
- array( array( 'En', 'Foo' ) )
+ 'll_from = ' . self::$testingPageId,
+ [ [ 'En', 'Foo' ] ]
);
}
global $wgPagePropsHaveSortkey;
/** @var ParserOutput $po */
- list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", $this->testingPageId );
+ list( $t, $po ) = $this->makeTitleAndParserOutput( "Testing", self::$testingPageId );
- $fields = array( 'pp_propname', 'pp_value' );
- $expected = array();
+ $fields = [ 'pp_propname', 'pp_value' ];
+ $expected = [];
$po->setProperty( "bool", true );
- $expected[] = array( "bool", true );
+ $expected[] = [ "bool", true ];
$po->setProperty( "float", 4.0 + 1.0 / 4.0 );
- $expected[] = array( "float", 4.0 + 1.0 / 4.0 );
+ $expected[] = [ "float", 4.0 + 1.0 / 4.0 ];
$po->setProperty( "int", -7 );
- $expected[] = array( "int", -7 );
+ $expected[] = [ "int", -7 ];
$po->setProperty( "string", "33 bar" );
- $expected[] = array( "string", "33 bar" );
+ $expected[] = [ "string", "33 bar" ];
// compute expected sortkey values
if ( $wgPagePropsHaveSortkey ) {
}
$this->assertLinksUpdate(
- $t, $po, 'page_props', $fields, 'pp_page = ' . $this->testingPageId, $expected );
+ $t, $po, 'page_props', $fields, 'pp_page = ' . self::$testingPageId, $expected );
}
public function testUpdate_page_props_without_sortkey() {
$this->assertSelect(
'recentchanges',
'rc_title, rc_comment',
- array(
+ [
'rc_type' => RC_CATEGORIZE,
'rc_namespace' => NS_CATEGORY,
'rc_title' => $categoryTitle->getDBkey()
- ),
+ ],
$expectedRows
);
}