protected $pages_to_delete;
- 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( 'page',
+ [ 'page',
'revision',
'text',
'externallinks',
'imagelinks',
'templatelinks',
- 'iwlinks' ) );
+ 'iwlinks' ] );
}
protected function setUp() {
parent::setUp();
- $this->pages_to_delete = array();
+ $this->pages_to_delete = [];
LinkCache::singleton()->clear(); # avoid cached redirect status, etc
}
/**
* @covers WikiPage::doEditContent
+ * @covers WikiPage::doModify
+ * @covers WikiPage::doCreate
+ * @covers WikiPage::doEditUpdates
*/
public function testDoEditContent() {
$page = $this->newPage( "WikiPageTest_testDoEditContent" );
# ------------------------
$dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'pagelinks', '*', array( 'pl_from' => $id ) );
+ $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
# ------------------------
$dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'pagelinks', '*', array( 'pl_from' => $id ) );
+ $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
/**
* @covers WikiPage::doEdit
+ * @deprecated since 1.21. Should be removed when WikiPage::doEdit() gets removed
*/
public function testDoEdit() {
$this->hideDeprecated( "WikiPage::doEdit" );
# ------------------------
$dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'pagelinks', '*', array( 'pl_from' => $id ) );
+ $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
# ------------------------
$dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'pagelinks', '*', array( 'pl_from' => $id ) );
+ $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
$this->assertEquals( 2, $n, 'pagelinks should contain two links from the page' );
}
- /**
- * @covers WikiPage::doQuickEditContent
- */
- public function testDoQuickEditContent() {
- global $wgUser;
-
- $page = $this->createPage(
- "WikiPageTest_testDoQuickEditContent",
- "original text",
- CONTENT_MODEL_WIKITEXT
- );
-
- $content = ContentHandler::makeContent(
- "quick text",
- $page->getTitle(),
- CONTENT_MODEL_WIKITEXT
- );
- $page->doQuickEditContent( $content, $wgUser, "testing q" );
-
- # ---------------------
- $page = new WikiPage( $page->getTitle() );
- $this->assertTrue( $content->equals( $page->getContent() ) );
- }
-
/**
* @covers WikiPage::doDeleteArticle
*/
// Run the job queue
JobQueueGroup::destroySingletons();
$jobs = new RunJobs;
- $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
+ $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
$jobs->execute();
# ------------------------
$dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'pagelinks', '*', array( 'pl_from' => $id ) );
+ $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
$id = $page->getId();
// Similar to MovePage logic
- wfGetDB( DB_MASTER )->delete( 'page', array( 'page_id' => $id ), __METHOD__ );
+ wfGetDB( DB_MASTER )->delete( 'page', [ 'page_id' => $id ], __METHOD__ );
$page->doDeleteUpdates( $id );
// Run the job queue
JobQueueGroup::destroySingletons();
$jobs = new RunJobs;
- $jobs->loadParamsAndArgs( null, array( 'quiet' => true ), null );
+ $jobs->loadParamsAndArgs( null, [ 'quiet' => true ], null );
$jobs->execute();
# ------------------------
$dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'pagelinks', '*', array( 'pl_from' => $id ) );
+ $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
}
public static function provideHasViewableContent() {
- return array(
- array( 'WikiPageTest_testHasViewableContent', false, true ),
- array( 'Special:WikiPageTest_testHasViewableContent', false ),
- array( 'MediaWiki:WikiPageTest_testHasViewableContent', false ),
- array( 'Special:Userlogin', true ),
- array( 'MediaWiki:help', true ),
- );
+ return [
+ [ 'WikiPageTest_testHasViewableContent', false, true ],
+ [ 'Special:WikiPageTest_testHasViewableContent', false ],
+ [ 'MediaWiki:WikiPageTest_testHasViewableContent', false ],
+ [ 'Special:Userlogin', true ],
+ [ 'MediaWiki:help', true ],
+ ];
}
/**
}
public static function provideGetRedirectTarget() {
- return array(
- array( 'WikiPageTest_testGetRedirectTarget_1', CONTENT_MODEL_WIKITEXT, "hello world", null ),
- array(
+ return [
+ [ 'WikiPageTest_testGetRedirectTarget_1', CONTENT_MODEL_WIKITEXT, "hello world", null ],
+ [
'WikiPageTest_testGetRedirectTarget_2',
CONTENT_MODEL_WIKITEXT,
"#REDIRECT [[hello world]]",
"Hello world"
- ),
- );
+ ],
+ ];
}
/**
* @covers WikiPage::getRedirectTarget
*/
public function testGetRedirectTarget( $title, $model, $text, $target ) {
- $this->setMwGlobals( array(
+ $this->setMwGlobals( [
'wgCapitalLinks' => true,
- ) );
+ ] );
$page = $this->createPage( $title, $text, $model );
}
public static function provideIsCountable() {
- return array(
+ return [
// any
- array( 'WikiPageTest_testIsCountable',
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'',
'any',
true
- ),
- array( 'WikiPageTest_testIsCountable',
+ ],
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'Foo',
'any',
true
- ),
+ ],
// comma
- array( 'WikiPageTest_testIsCountable',
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'Foo',
'comma',
false
- ),
- array( 'WikiPageTest_testIsCountable',
+ ],
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'Foo, bar',
'comma',
true
- ),
+ ],
// link
- array( 'WikiPageTest_testIsCountable',
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'Foo',
'link',
false
- ),
- array( 'WikiPageTest_testIsCountable',
+ ],
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'Foo [[bar]]',
'link',
true
- ),
+ ],
// redirects
- array( 'WikiPageTest_testIsCountable',
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'#REDIRECT [[bar]]',
'any',
false
- ),
- array( 'WikiPageTest_testIsCountable',
+ ],
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'#REDIRECT [[bar]]',
'comma',
false
- ),
- array( 'WikiPageTest_testIsCountable',
+ ],
+ [ 'WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'#REDIRECT [[bar]]',
'link',
false
- ),
+ ],
// not a content namespace
- array( 'Talk:WikiPageTest_testIsCountable',
+ [ 'Talk:WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'Foo',
'any',
false
- ),
- array( 'Talk:WikiPageTest_testIsCountable',
+ ],
+ [ 'Talk:WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'Foo, bar',
'comma',
false
- ),
- array( 'Talk:WikiPageTest_testIsCountable',
+ ],
+ [ 'Talk:WikiPageTest_testIsCountable',
CONTENT_MODEL_WIKITEXT,
'Foo [[bar]]',
'link',
false
- ),
+ ],
// not a content namespace, different model
- array( 'MediaWiki:WikiPageTest_testIsCountable.js',
+ [ 'MediaWiki:WikiPageTest_testIsCountable.js',
null,
'Foo',
'any',
false
- ),
- array( 'MediaWiki:WikiPageTest_testIsCountable.js',
+ ],
+ [ 'MediaWiki:WikiPageTest_testIsCountable.js',
null,
'Foo, bar',
'comma',
false
- ),
- array( 'MediaWiki:WikiPageTest_testIsCountable.js',
+ ],
+ [ 'MediaWiki:WikiPageTest_testIsCountable.js',
null,
'Foo [[bar]]',
'link',
false
- ),
- );
+ ],
+ ];
}
/**
}
public static function provideGetParserOutput() {
- return array(
- array( CONTENT_MODEL_WIKITEXT, "hello ''world''\n", "<p>hello <i>world</i></p>" ),
+ return [
+ [ CONTENT_MODEL_WIKITEXT, "hello ''world''\n", "<p>hello <i>world</i></p>" ],
// @todo more...?
- );
+ ];
}
/**
public function dataReplaceSection() {
// NOTE: assume the Help namespace to contain wikitext
- return array(
- array( 'Help:WikiPageTest_testReplaceSection',
+ return [
+ [ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
WikiPageTest::$sections,
"0",
"No more",
null,
trim( preg_replace( '/^Intro/sm', 'No more', WikiPageTest::$sections ) )
- ),
- array( 'Help:WikiPageTest_testReplaceSection',
+ ],
+ [ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
WikiPageTest::$sections,
"",
"No more",
null,
"No more"
- ),
- array( 'Help:WikiPageTest_testReplaceSection',
+ ],
+ [ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
WikiPageTest::$sections,
"2",
trim( preg_replace( '/^== test ==.*== foo ==/sm',
"== TEST ==\nmore fun\n\n== foo ==",
WikiPageTest::$sections ) )
- ),
- array( 'Help:WikiPageTest_testReplaceSection',
+ ],
+ [ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
WikiPageTest::$sections,
"8",
"No more",
null,
trim( WikiPageTest::$sections )
- ),
- array( 'Help:WikiPageTest_testReplaceSection',
+ ],
+ [ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
WikiPageTest::$sections,
"new",
"No more",
"New",
trim( WikiPageTest::$sections ) . "\n\n== New ==\n\nNo more"
- ),
- );
- }
-
- /**
- * @dataProvider dataReplaceSection
- * @covers WikiPage::replaceSection
- */
- public function testReplaceSection( $title, $model, $text, $section, $with,
- $sectionTitle, $expected
- ) {
- $this->hideDeprecated( "WikiPage::replaceSection" );
-
- $page = $this->createPage( $title, $text, $model );
- $text = $page->replaceSection( $section, $with, $sectionTitle );
- $text = trim( $text );
-
- $this->assertEquals( $expected, $text );
+ ],
+ ];
}
/**
# now, try the actual rollback
$admin->addGroup( "sysop" ); # XXX: make the test user a sysop...
$token = $admin->getEditToken(
- array( $page->getTitle()->getPrefixedText(), $user2->getName() ),
+ [ $page->getTitle()->getPrefixedText(), $user2->getName() ],
null
);
$errors = $page->doRollback(
# now, try the rollback
$admin->addGroup( "sysop" ); # XXX: make the test user a sysop...
$token = $admin->getEditToken(
- array( $page->getTitle()->getPrefixedText(), $user1->getName() ),
+ [ $page->getTitle()->getPrefixedText(), $user1->getName() ],
null
);
$errors = $page->doRollback(
);
# now, do a the rollback from the same user was doing the edit before
- $resultDetails = array();
+ $resultDetails = [];
$token = $user1->getEditToken(
- array( $page->getTitle()->getPrefixedText(), $user1->getName() ),
+ [ $page->getTitle()->getPrefixedText(), $user1->getName() ],
null
);
$errors = $page->doRollback(
$admin
);
- $this->assertEquals( array(), $errors, "Rollback failed same user" );
+ $this->assertEquals( [], $errors, "Rollback failed same user" );
# now, try the rollback
- $resultDetails = array();
+ $resultDetails = [];
$token = $admin->getEditToken(
- array( $page->getTitle()->getPrefixedText(), $user1->getName() ),
+ [ $page->getTitle()->getPrefixedText(), $user1->getName() ],
null
);
$errors = $page->doRollback(
$admin
);
- $this->assertEquals( array( array( 'alreadyrolled', 'WikiPageTest testDoRollback',
- '127.0.1.11', 'Admin' ) ), $errors, "Rollback not failed" );
+ $this->assertEquals( [ [ 'alreadyrolled', 'WikiPageTest testDoRollback',
+ '127.0.1.11', 'Admin' ] ], $errors, "Rollback not failed" );
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( $rev1->getSha1(), $page->getRevision()->getSha1(),
}
public static function provideGetAutosummary() {
- return array(
- array(
+ return [
+ [
'Hello there, world!',
'#REDIRECT [[Foo]]',
0,
'/^Redirected page .*Foo/'
- ),
+ ],
- array(
+ [
null,
'Hello world!',
EDIT_NEW,
'/^Created page .*Hello/'
- ),
+ ],
- array(
+ [
'Hello there, world!',
'',
0,
'/^Blanked/'
- ),
+ ],
- array(
+ [
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet
'Hello world!',
0,
'/^Replaced .*Hello/'
- ),
+ ],
- array(
+ [
'foo',
'bar',
0,
'/^$/'
- ),
- );
+ ],
+ ];
}
/**
}
public static function provideGetAutoDeleteReason() {
- return array(
- array(
- array(),
+ return [
+ [
+ [],
false,
false
- ),
+ ],
- array(
- array(
- array( "first edit", null ),
- ),
+ [
+ [
+ [ "first edit", null ],
+ ],
"/first edit.*only contributor/",
false
- ),
+ ],
- array(
- array(
- array( "first edit", null ),
- array( "second edit", null ),
- ),
+ [
+ [
+ [ "first edit", null ],
+ [ "second edit", null ],
+ ],
"/second edit.*only contributor/",
true
- ),
+ ],
- array(
- array(
- array( "first edit", "127.0.2.22" ),
- array( "second edit", "127.0.3.33" ),
- ),
+ [
+ [
+ [ "first edit", "127.0.2.22" ],
+ [ "second edit", "127.0.3.33" ],
+ ],
"/second edit/",
true
- ),
+ ],
- array(
- array(
- array(
+ [
+ [
+ [
"first edit: "
. "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam "
. " nonumy eirmod tempor invidunt ut labore et dolore magna "
. "et justo duo dolores et ea rebum. Stet clita kasd gubergren, "
. "no sea takimata sanctus est Lorem ipsum dolor sit amet.'",
null
- ),
- ),
+ ],
+ ],
'/first edit:.*\.\.\."/',
false
- ),
+ ],
- array(
- array(
- array( "first edit", "127.0.2.22" ),
- array( "", "127.0.3.33" ),
- ),
+ [
+ [
+ [ "first edit", "127.0.2.22" ],
+ [ "", "127.0.3.33" ],
+ ],
"/before blanking.*first edit/",
true
- ),
+ ],
- );
+ ];
}
/**
}
public static function providePreSaveTransform() {
- return array(
- array( 'hello this is ~~~',
+ return [
+ [ 'hello this is ~~~',
"hello this is [[Special:Contributions/127.0.0.1|127.0.0.1]]",
- ),
- array( 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
+ ],
+ [ 'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
'hello \'\'this\'\' is <nowiki>~~~</nowiki>',
- ),
- );
+ ],
+ ];
}
/**