aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit
diff options
context:
space:
mode:
authorDerick Alangi <alangiderick@gmail.com>2021-09-23 00:03:30 +0100
committerDerick Alangi <alangiderick@gmail.com>2021-09-23 00:31:33 +0100
commit2432cc2bb4dbaabfe84939e599e20e8a92b9e279 (patch)
tree63b2c51290f4d5288f774565b1cbdda3091e8e2e /tests/phpunit
parent7a545309c7a5df3a1bd7f98f2c15efb297f58eda (diff)
downloadmediawikicore-2432cc2bb4dbaabfe84939e599e20e8a92b9e279.tar.gz
mediawikicore-2432cc2bb4dbaabfe84939e599e20e8a92b9e279.zip
Use PageUpdater's fluent interface as in some parts of our codebase
Some methods in the PageUpdater's class implements the fluent interface design pattern. Use the fluent interface where need be. Change-Id: If76a4b8c5070c20ed40038a4ee78e2d677de5180
Diffstat (limited to 'tests/phpunit')
-rw-r--r--tests/phpunit/includes/Revision/RevisionStoreDbTest.php4
-rw-r--r--tests/phpunit/includes/Storage/PageUpdaterTest.php44
-rw-r--r--tests/phpunit/includes/cache/MessageCacheTest.php7
-rw-r--r--tests/phpunit/includes/page/ArticleViewTest.php3
-rw-r--r--tests/phpunit/includes/page/WikiPageDbTest.php4
-rw-r--r--tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php7
-rw-r--r--tests/phpunit/integration/includes/page/DeletePageTest.php4
7 files changed, 35 insertions, 38 deletions
diff --git a/tests/phpunit/includes/Revision/RevisionStoreDbTest.php b/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
index af0627ae62e4..938c3bdc2452 100644
--- a/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
+++ b/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
@@ -2074,8 +2074,8 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
*/
private function createRevisionStoreCacheRecord( $page, $store ) {
$user = MediaWikiIntegrationTestCase::getMutableTestUser()->getUser();
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( SlotRecord::MAIN, new WikitextContent( __METHOD__ ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new WikitextContent( __METHOD__ ) );
$summary = CommentStoreComment::newUnsavedComment( __METHOD__ );
$rev = $updater->saveRevision( $summary, EDIT_NEW );
return $store->getKnownCurrentRevision( $page->getTitle(), $rev->getId() );
diff --git a/tests/phpunit/includes/Storage/PageUpdaterTest.php b/tests/phpunit/includes/Storage/PageUpdaterTest.php
index 39a9a1748b4a..cc562e4c004d 100644
--- a/tests/phpunit/includes/Storage/PageUpdaterTest.php
+++ b/tests/phpunit/includes/Storage/PageUpdaterTest.php
@@ -170,8 +170,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
$this->assertSame( $oldStats->ss_total_edits + 1, (int)$stats->ss_total_edits );
// re-edit with same content - should be a "null-edit"
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( SlotRecord::MAIN, $content );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, $content );
$summary = CommentStoreComment::newUnsavedComment( 'to to re-edit' );
$rev = $updater->saveRevision( $summary );
@@ -266,8 +266,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
$this->assertNotNull( $rc, 'RecentChange' );
// re-edit
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
$summary = CommentStoreComment::newUnsavedComment( 're-edit' );
$updater->saveRevision( $summary );
@@ -278,8 +278,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
$topRevisionId = $updater->getNewRevision()->getId();
// perform a null edit
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
$summary = CommentStoreComment::newUnsavedComment( 'null edit' );
$updater->saveRevision( $summary );
@@ -310,21 +310,21 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
$user = $this->getTestUser()->getUser();
$summary = CommentStoreComment::newUnsavedComment( '1' );
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( SlotRecord::MAIN, new TextContent( '1' ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new TextContent( '1' ) );
$updater->saveRevision( $summary );
$revId1 = $updater->getNewRevision()->getId();
$summary = CommentStoreComment::newUnsavedComment( '2' );
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( SlotRecord::MAIN, new TextContent( '2' ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new TextContent( '2' ) );
$updater->saveRevision( $summary );
$revId2 = $updater->getNewRevision()->getId();
// Perform a rollback
- $updater = $page->newPageUpdater( $this->getTestSysop()->getUser() );
- $updater->setContent( SlotRecord::MAIN, new TextContent( '1' ) );
- $updater->markAsRevert( EditResult::REVERT_ROLLBACK, $revId2, $revId1 );
+ $updater = $page->newPageUpdater( $this->getTestSysop()->getUser() )
+ ->setContent( SlotRecord::MAIN, new TextContent( '1' ) )
+ ->markAsRevert( EditResult::REVERT_ROLLBACK, $revId2, $revId1 );
$summary = CommentStoreComment::newUnsavedComment( 'revert' );
$updater->saveRevision( $summary );
@@ -465,8 +465,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
// start editing non-existing page
$page = WikiPage::factory( $title );
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( SlotRecord::MAIN, new TextContent( 'Lorem Ipsum' ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new TextContent( 'Lorem Ipsum' ) );
$summary = CommentStoreComment::newUnsavedComment( 'Just a test' );
@@ -570,8 +570,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
// update with EDIT_NEW flag should fail
$summary = CommentStoreComment::newUnsavedComment( 'create?!' );
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new TextContent( 'dolor sit amet' ) );
$updater->saveRevision( $summary, EDIT_NEW );
$status = $updater->getStatus();
@@ -591,11 +591,11 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
// start editing non-existing page
$page = WikiPage::factory( $title );
- $updater = $page->newPageUpdater( $user );
// plain text content should fail in aux slot (the main slot doesn't care)
- $updater->setContent( 'main', new TextContent( 'Main Content' ) );
- $updater->setContent( 'aux', new TextContent( 'Aux Content' ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( 'main', new TextContent( 'Main Content' ) )
+ ->setContent( 'aux', new TextContent( 'Aux Content' ) );
$summary = CommentStoreComment::newUnsavedComment( 'udpate?!' );
$updater->saveRevision( $summary, EDIT_UPDATE );
@@ -648,8 +648,8 @@ class PageUpdaterTest extends MediaWikiIntegrationTestCase {
// Create page
$page = WikiPage::factory( $title );
- $updater = $page->newPageUpdater( $user );
- $updater->setContent( 'main', new TextContent( 'Content 1' ) );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( 'main', new TextContent( 'Content 1' ) );
$updater->saveRevision( $summary, EDIT_NEW );
$this->assertTrue( $updater->wasSuccessful(), 'wasSuccessful()' );
diff --git a/tests/phpunit/includes/cache/MessageCacheTest.php b/tests/phpunit/includes/cache/MessageCacheTest.php
index c58dc1586a7e..2b73d709c76f 100644
--- a/tests/phpunit/includes/cache/MessageCacheTest.php
+++ b/tests/phpunit/includes/cache/MessageCacheTest.php
@@ -74,11 +74,8 @@ class MessageCacheTest extends MediaWikiLangTestCase {
$wikiPage = new WikiPage( $title );
$content = ContentHandler::makeContent( $content, $title );
- $updater = $wikiPage->newPageUpdater( $this->getTestSysop()->getUser() );
- $updater->setContent(
- SlotRecord::MAIN,
- $content
- );
+ $updater = $wikiPage->newPageUpdater( $this->getTestSysop()->getUser() )
+ ->setContent( SlotRecord::MAIN, $content );
$summary = CommentStoreComment::newUnsavedComment( "$lang translation test case" );
$inserted = $updater->saveRevision( $summary );
diff --git a/tests/phpunit/includes/page/ArticleViewTest.php b/tests/phpunit/includes/page/ArticleViewTest.php
index 22032a8216fa..7e05d392bc53 100644
--- a/tests/phpunit/includes/page/ArticleViewTest.php
+++ b/tests/phpunit/includes/page/ArticleViewTest.php
@@ -50,8 +50,7 @@ class ArticleViewTest extends MediaWikiIntegrationTestCase {
$cont = new WikitextContent( $cont );
}
- $u = $page->newPageUpdater( $user );
- $u->setContent( SlotRecord::MAIN, $cont );
+ $u = $page->newPageUpdater( $user )->setContent( SlotRecord::MAIN, $cont );
$rev = $u->saveRevision( CommentStoreComment::newUnsavedComment( 'Rev ' . $key ) );
$revisions[ $key ] = $rev;
diff --git a/tests/phpunit/includes/page/WikiPageDbTest.php b/tests/phpunit/includes/page/WikiPageDbTest.php
index baddcb14e616..96d695d67459 100644
--- a/tests/phpunit/includes/page/WikiPageDbTest.php
+++ b/tests/phpunit/includes/page/WikiPageDbTest.php
@@ -2057,8 +2057,8 @@ more stuff
$slotsUpdate = new revisionSlotsUpdate();
$slotsUpdate->modifyContent( SlotRecord::MAIN, $content );
- $updater = $page->newPageUpdater( $user, $slotsUpdate );
- $updater->setContent( SlotRecord::MAIN, $content );
+ $updater = $page->newPageUpdater( $user, $slotsUpdate )
+ ->setContent( SlotRecord::MAIN, $content );
$revision = $updater->saveRevision(
CommentStoreComment::newUnsavedComment( 'test' ),
EDIT_NEW
diff --git a/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php b/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
index 77b0ba3917c4..afc1b5b975af 100644
--- a/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
+++ b/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
@@ -59,10 +59,11 @@ class PoolWorkArticleViewTest extends MediaWikiIntegrationTestCase {
private function makeRevision( WikiPage $page, $text ) {
$user = $this->getTestUser()->getUser();
- $updater = $page->newPageUpdater( $user );
+ $updater = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new WikitextContent( $text ) )
+ ->saveRevision( CommentStoreComment::newUnsavedComment( 'testing' ) );
- $updater->setContent( SlotRecord::MAIN, new WikitextContent( $text ) );
- return $updater->saveRevision( CommentStoreComment::newUnsavedComment( 'testing' ) );
+ return $updater;
}
public function testDoWorkLoadRevision() {
diff --git a/tests/phpunit/integration/includes/page/DeletePageTest.php b/tests/phpunit/integration/includes/page/DeletePageTest.php
index 822bd187b529..4239e12bf6a9 100644
--- a/tests/phpunit/integration/includes/page/DeletePageTest.php
+++ b/tests/phpunit/integration/includes/page/DeletePageTest.php
@@ -62,8 +62,8 @@ class DeletePageTest extends MediaWikiIntegrationTestCase {
$content = ContentHandler::makeContent( $content, $page->getTitle(), CONTENT_MODEL_WIKITEXT );
- $updater = $page->newPageUpdater( $performer );
- $updater->setContent( 'main', $content );
+ $updater = $page->newPageUpdater( $performer )
+ ->setContent( 'main', $content );
$updater->saveRevision( CommentStoreComment::newUnsavedComment( "testing" ) );
if ( !$updater->wasSuccessful() ) {