$id = $page->getId();
# ------------------------
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
$this->assertTrue( $content->equals( $retrieved ), 'retrieved content doesn\'t equal original' );
# ------------------------
- $dbr = wfGetDB( DB_SLAVE );
- $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::doEdit
- * @deprecated since 1.21. Should be removed when WikiPage::doEdit() gets removed
- */
- public function testDoEdit() {
- $this->hideDeprecated( "WikiPage::doEdit" );
- $this->hideDeprecated( "Revision::getText" );
-
- // NOTE: assume help namespace will default to wikitext
- $title = Title::newFromText( "Help:WikiPageTest_testDoEdit" );
-
- $page = $this->newPage( $title );
-
- $text = "[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
- . " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.";
-
- $page->doEdit( $text, "[[testing]] 1" );
-
- $this->assertTrue( $title->getArticleID() > 0, "Title object should have new page id" );
- $this->assertTrue( $page->getId() > 0, "WikiPage should have new page id" );
- $this->assertTrue( $title->exists(), "Title object should indicate that the page now exists" );
- $this->assertTrue( $page->exists(), "WikiPage object should indicate that the page now exists" );
-
- $id = $page->getId();
-
- # ------------------------
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
- $n = $res->numRows();
- $res->free();
-
- $this->assertEquals( 1, $n, 'pagelinks should contain one link from the page' );
-
- # ------------------------
- $text = "At vero eos et accusam et justo duo [[dolores]] et ea rebum. "
- . "Stet clita kasd [[gubergren]], no sea takimata sanctus est.";
-
- $page->doEdit( $text, "testing 2" );
-
- # ------------------------
- $page = new WikiPage( $title );
-
- $retrieved = $page->getContent()->getNativeData();
- $this->assertEquals( $text, $retrieved, 'retrieved text doesn\'t equal original' );
-
- # ------------------------
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
$jobs->execute();
# ------------------------
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
$jobs->execute();
# ------------------------
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );
$n = $res->numRows();
$res->free();
public static function provideGetParserOutput() {
return [
- [ CONTENT_MODEL_WIKITEXT, "hello ''world''\n", "<p>hello <i>world</i></p>" ],
+ [
+ CONTENT_MODEL_WIKITEXT,
+ "hello ''world''\n",
+ "<div class=\"mw-parser-output\"><p>hello <i>world</i></p></div>"
+ ],
// @todo more...?
];
}
$text = $po->getText();
$text = trim( preg_replace( '/<!--.*?-->/sm', '', $text ) ); # strip injected comments
- $text = preg_replace( '!\s*(</p>)!sm', '\1', $text ); # don't let tidy confuse us
+ $text = preg_replace( '!\s*(</p>|</div>)!sm', '\1', $text ); # don't let tidy confuse us
$this->assertEquals( $expectedHtml, $text );
return [
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"0",
"No more",
null,
- trim( preg_replace( '/^Intro/sm', 'No more', WikiPageTest::$sections ) )
+ trim( preg_replace( '/^Intro/sm', 'No more', self::$sections ) )
],
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"",
"No more",
null,
],
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"2",
"== TEST ==\nmore fun",
null,
trim( preg_replace( '/^== test ==.*== foo ==/sm',
"== TEST ==\nmore fun\n\n== foo ==",
- WikiPageTest::$sections ) )
+ self::$sections ) )
],
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"8",
"No more",
null,
- trim( WikiPageTest::$sections )
+ trim( self::$sections )
],
[ 'Help:WikiPageTest_testReplaceSection',
CONTENT_MODEL_WIKITEXT,
- WikiPageTest::$sections,
+ self::$sections,
"new",
"No more",
"New",
- trim( WikiPageTest::$sections ) . "\n\n== New ==\n\nNo more"
+ trim( self::$sections ) . "\n\n== New ==\n\nNo more"
],
];
}
}
*/
+ /**
+ * @covers WikiPage::getOldestRevision
+ */
+ public function testGetOldestRevision() {
+ $page = $this->newPage( "WikiPageTest_testGetOldestRevision" );
+ $page->doEditContent(
+ new WikitextContent( 'one' ),
+ "first edit",
+ EDIT_NEW
+ );
+ $rev1 = $page->getRevision();
+
+ $page = new WikiPage( $page->getTitle() );
+ $page->doEditContent(
+ new WikitextContent( 'two' ),
+ "second edit",
+ EDIT_UPDATE
+ );
+
+ $page = new WikiPage( $page->getTitle() );
+ $page->doEditContent(
+ new WikitextContent( 'three' ),
+ "third edit",
+ EDIT_UPDATE
+ );
+
+ // sanity check
+ $this->assertNotEquals(
+ $rev1->getId(),
+ $page->getRevision()->getId(),
+ '$page->getRevision()->getId()'
+ );
+
+ // actual test
+ $this->assertEquals(
+ $rev1->getId(),
+ $page->getOldestRevision()->getId(),
+ '$page->getOldestRevision()->getId()'
+ );
+ }
+
/**
* @todo FIXME: this is a better rollback test than the one below, but it
* keeps failing in jenkins for some reason.
# we are having issues with doRollback spuriously failing. Apparently
# the last revision somehow goes missing or not committed under some
# circumstances. So, make sure the last revision has the right user name.
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$this->assertEquals( 3, Revision::countByPageId( $dbr, $page->getId() ) );
$page = new WikiPage( $page->getTitle() );
$this->assertEquals( 'Admin', $rev1->getUserText() );
# now, try the actual rollback
+ $admin->addToDatabase();
$admin->addGroup( "sysop" ); # XXX: make the test user a sysop...
$token = $admin->getEditToken(
[ $page->getTitle()->getPrefixedText(), $user2->getName() ],
public function testDoRollback() {
$admin = new User();
$admin->setName( "Admin" );
+ $admin->addToDatabase();
$text = "one";
$page = $this->newPage( "WikiPageTest_testDoRollback" );
# now, try the rollback
$admin->addGroup( "sysop" ); # XXX: make the test user a sysop...
- $token = $admin->getEditToken(
- [ $page->getTitle()->getPrefixedText(), $user1->getName() ],
- null
- );
+ $token = $admin->getEditToken( 'rollback' );
$errors = $page->doRollback(
$user1->getName(),
"testing revert",
public function testDoRollbackFailureSameContent() {
$admin = new User();
$admin->setName( "Admin" );
+ $admin->addToDatabase();
$admin->addGroup( "sysop" ); # XXX: make the test user a sysop...
$text = "one";
$user1 = new User();
$user1->setName( "127.0.1.11" );
+ $user1->addToDatabase();
$user1->addGroup( "sysop" ); # XXX: make the test user a sysop...
$text .= "\n\ntwo";
$page = new WikiPage( $page->getTitle() );
# now, do a the rollback from the same user was doing the edit before
$resultDetails = [];
- $token = $user1->getEditToken(
- [ $page->getTitle()->getPrefixedText(), $user1->getName() ],
- null
- );
+ $token = $user1->getEditToken( 'rollback' );
$errors = $page->doRollback(
$user1->getName(),
"testing revert same user",
# now, try the rollback
$resultDetails = [];
- $token = $admin->getEditToken(
- [ $page->getTitle()->getPrefixedText(), $user1->getName() ],
- null
- );
+ $token = $admin->getEditToken( 'rollback' );
$errors = $page->doRollback(
$user1->getName(),
"testing revert",