* @group medium
* ^--- tell phpunit that these test cases may take longer than 2 seconds.
*/
-class EditPageTest extends MediaWikiTestCase {
+class EditPageTest extends MediaWikiLangTestCase {
/**
* @dataProvider provideExtractSectionTitle
$dbw = wfGetDB( DB_MASTER );
$dbw->update( 'revision',
- array( 'rev_timestamp' => $timestamp ),
+ array( 'rev_timestamp' => $dbw->timestamp( $timestamp ) ),
array( 'rev_id' => $page->getLatest() ) );
$page->clear();
* wrapper around assertEquals() which calls rrtrim() to normalize the
* expected and actual texts.
*/
- function assertEditedTextEquals( $expected, $actual, $msg='' ) {
- return $this->assertEquals( rtrim($expected), rtrim($actual), $msg );
+ function assertEditedTextEquals( $expected, $actual, $msg = '' ) {
+ return $this->assertEquals( rtrim( $expected ), rtrim( $actual ), $msg );
}
/**
}
public function testCreatePage() {
- $text = "Hello World!";
- $edit = array(
- 'wpTextbox1' => $text,
- 'wpSummary' => 'just testing',
+ $this->assertEdit(
+ 'EditPageTest_testCreatePage',
+ null,
+ null,
+ array(
+ 'wpTextbox1' => "Hello World!",
+ ),
+ EditPage::AS_SUCCESS_NEW_ARTICLE,
+ "Hello World!",
+ "expected article being created"
+ )->doDeleteArticleReal( 'EditPageTest_testCreatePage' );
+
+ $this->assertEdit(
+ 'EditPageTest_testCreatePage',
+ null,
+ null,
+ array(
+ 'wpTextbox1' => "",
+ ),
+ EditPage::AS_BLANK_ARTICLE,
+ null,
+ "expected article not being created if empty"
);
- $this->assertEdit( 'EditPageTest_testCreatePafe', null, null, $edit,
- EditPage::AS_SUCCESS_NEW_ARTICLE, $text,
- "expected successfull creation with given text" );
+
+ $this->assertEdit(
+ 'MediaWiki:January',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "Not January",
+ ),
+ EditPage::AS_SUCCESS_NEW_ARTICLE,
+ "Not January",
+ "expected MediaWiki: page being created"
+ )->doDeleteArticleReal( 'EditPageTest_testCreatePage' );
+
+ $this->assertEdit(
+ 'MediaWiki:EditPageTest_testCreatePage',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "",
+ ),
+ EditPage::AS_BLANK_ARTICLE,
+ null,
+ "expected not-registered MediaWiki: page not being created if empty"
+ );
+
+ $this->assertEdit(
+ 'MediaWiki:January',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "",
+ ),
+ EditPage::AS_SUCCESS_NEW_ARTICLE,
+ "",
+ "expected registered MediaWiki: page being created even if empty"
+ )->doDeleteArticleReal( 'EditPageTest_testCreatePage' );
+
+ $this->assertEdit(
+ 'MediaWiki:Ipb-default-expiry',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "",
+ ),
+ EditPage::AS_BLANK_ARTICLE,
+ "",
+ "expected registered MediaWiki: page whose default content is empty not being created if empty"
+ );
+
+ $this->assertEdit(
+ 'MediaWiki:January',
+ null,
+ 'UTSysop',
+ array(
+ 'wpTextbox1' => "January",
+ ),
+ EditPage::AS_BLANK_ARTICLE,
+ null,
+ "expected MediaWiki: page not being created if text equals default message"
+ );
}
public function testUpdatePage() {
}
public static function provideSectionEdit() {
- $text =
-'Intro
+ $text = 'Intro
== one ==
first section.
second section.
';
- $sectionOne =
-'== one ==
+ $sectionOne = '== one ==
hello
';
- $newSection =
-'== new section ==
+ $newSection = '== new section ==
hello
';
- $textWithNewSectionOne = preg_replace( '/== one ==.*== two ==/ms',
- "$sectionOne\n== two ==", $text );
+ $textWithNewSectionOne = preg_replace(
+ '/== one ==.*== two ==/ms',
+ "$sectionOne\n== two ==", $text
+ );
$textWithNewSectionAdded = "$text\n$newSection";
);
// see whether it makes a difference who did the base edit
- $testsWithAdam = array_map( function( $test ) {
+ $testsWithAdam = array_map( function ( $test ) {
$test[0] = 'Adam'; // change base edit user
return $test;
}, $tests );
- $testsWithBerta = array_map( function( $test ) {
+ $testsWithBerta = array_map( function ( $test ) {
$test[0] = 'Berta'; // change base edit user
return $test;
}, $tests );
* @dataProvider provideAutoMerge
*/
public function testAutoMerge( $baseUser, $text, $adamsEdit, $bertasEdit,
- $expectedCode, $expectedText, $message = null
+ $expectedCode, $expectedText, $message = null
) {
$this->checkHasDiff3();
);
$page = $this->assertEdit( 'EditPageTest_testAutoMerge', null,
- $baseUser, $baseEdit, null, null, __METHOD__ );
+ $baseUser, $baseEdit, null, null, __METHOD__ );
$this->forceRevisionDate( $page, '20120101000000' );