aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit
diff options
context:
space:
mode:
authorDerick Alangi <alangiderick@gmail.com>2021-10-04 18:10:37 +0100
committerDerick Alangi <alangiderick@gmail.com>2021-10-05 07:18:17 +0100
commitd62ba36bba1de4a2d5b25eac5956bbf6ba288aa1 (patch)
tree5615d2972f688ba0ac63488dc3c4829fbf8437b1 /tests/phpunit
parent5bfcf8975709cdad62fe71cd0906ae7ebf14058a (diff)
downloadmediawikicore-d62ba36bba1de4a2d5b25eac5956bbf6ba288aa1.tar.gz
mediawikicore-d62ba36bba1de4a2d5b25eac5956bbf6ba288aa1.zip
Use PageUpdater's fluent interface
Change-Id: I541b7ae565c46d00ab5e1de08a2447461a9e73a7
Diffstat (limited to 'tests/phpunit')
-rw-r--r--tests/phpunit/includes/Revision/RevisionStoreDbTest.php6
-rw-r--r--tests/phpunit/includes/cache/MessageCacheTest.php13
-rw-r--r--tests/phpunit/includes/page/ArticleViewTest.php5
-rw-r--r--tests/phpunit/includes/page/WikiPageDbTest.php9
-rw-r--r--tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php4
5 files changed, 18 insertions, 19 deletions
diff --git a/tests/phpunit/includes/Revision/RevisionStoreDbTest.php b/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
index 938c3bdc2452..4923f42a7260 100644
--- a/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
+++ b/tests/phpunit/includes/Revision/RevisionStoreDbTest.php
@@ -2074,10 +2074,10 @@ class RevisionStoreDbTest extends MediaWikiIntegrationTestCase {
*/
private function createRevisionStoreCacheRecord( $page, $store ) {
$user = MediaWikiIntegrationTestCase::getMutableTestUser()->getUser();
- $updater = $page->newPageUpdater( $user )
- ->setContent( SlotRecord::MAIN, new WikitextContent( __METHOD__ ) );
$summary = CommentStoreComment::newUnsavedComment( __METHOD__ );
- $rev = $updater->saveRevision( $summary, EDIT_NEW );
+ $rev = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, new WikitextContent( __METHOD__ ) )
+ ->saveRevision( $summary, EDIT_NEW );
return $store->getKnownCurrentRevision( $page->getTitle(), $rev->getId() );
}
diff --git a/tests/phpunit/includes/cache/MessageCacheTest.php b/tests/phpunit/includes/cache/MessageCacheTest.php
index 2b73d709c76f..80846101072a 100644
--- a/tests/phpunit/includes/cache/MessageCacheTest.php
+++ b/tests/phpunit/includes/cache/MessageCacheTest.php
@@ -1,6 +1,7 @@
<?php
use MediaWiki\MediaWikiServices;
+use MediaWiki\Revision\RevisionRecord;
use MediaWiki\Revision\SlotRecord;
use Wikimedia\TestingAccessWrapper;
@@ -73,15 +74,15 @@ class MessageCacheTest extends MediaWikiLangTestCase {
$title = Title::newFromText( $title, NS_MEDIAWIKI );
$wikiPage = new WikiPage( $title );
$content = ContentHandler::makeContent( $content, $title );
-
- $updater = $wikiPage->newPageUpdater( $this->getTestSysop()->getUser() )
- ->setContent( SlotRecord::MAIN, $content );
$summary = CommentStoreComment::newUnsavedComment( "$lang translation test case" );
- $inserted = $updater->saveRevision( $summary );
+
+ $newRevision = $wikiPage->newPageUpdater( $this->getTestSysop()->getUser() )
+ ->setContent( SlotRecord::MAIN, $content )
+ ->saveRevision( $summary );
// sanity
- $this->assertTrue( $updater->wasSuccessful(), 'Create page ' . $title->getPrefixedDBkey() );
- return $inserted;
+ $this->assertNotNull( $newRevision, 'Create page ' . $title->getPrefixedDBkey() );
+ return $newRevision;
}
/**
diff --git a/tests/phpunit/includes/page/ArticleViewTest.php b/tests/phpunit/includes/page/ArticleViewTest.php
index 7e05d392bc53..142d3289b7c5 100644
--- a/tests/phpunit/includes/page/ArticleViewTest.php
+++ b/tests/phpunit/includes/page/ArticleViewTest.php
@@ -50,8 +50,9 @@ class ArticleViewTest extends MediaWikiIntegrationTestCase {
$cont = new WikitextContent( $cont );
}
- $u = $page->newPageUpdater( $user )->setContent( SlotRecord::MAIN, $cont );
- $rev = $u->saveRevision( CommentStoreComment::newUnsavedComment( 'Rev ' . $key ) );
+ $rev = $page->newPageUpdater( $user )
+ ->setContent( SlotRecord::MAIN, $cont )
+ ->saveRevision( CommentStoreComment::newUnsavedComment( 'Rev ' . $key ) );
$revisions[ $key ] = $rev;
MWTimestamp::setFakeTime( ++$time );
diff --git a/tests/phpunit/includes/page/WikiPageDbTest.php b/tests/phpunit/includes/page/WikiPageDbTest.php
index 4e25bf5bc864..8fb3a44a8a62 100644
--- a/tests/phpunit/includes/page/WikiPageDbTest.php
+++ b/tests/phpunit/includes/page/WikiPageDbTest.php
@@ -2057,12 +2057,9 @@ more stuff
$slotsUpdate = new revisionSlotsUpdate();
$slotsUpdate->modifyContent( SlotRecord::MAIN, $content );
- $updater = $page->newPageUpdater( $user, $slotsUpdate )
- ->setContent( SlotRecord::MAIN, $content );
- $revision = $updater->saveRevision(
- CommentStoreComment::newUnsavedComment( 'test' ),
- EDIT_NEW
- );
+ $revision = $page->newPageUpdater( $user, $slotsUpdate )
+ ->setContent( SlotRecord::MAIN, $content )
+ ->saveRevision( CommentStoreComment::newUnsavedComment( 'test' ), EDIT_NEW );
$preparedEditAfter = $page->prepareContentForEdit( $content, $revision, $user );
diff --git a/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php b/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
index afc1b5b975af..07d6ec8981a0 100644
--- a/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
+++ b/tests/phpunit/includes/poolcounter/PoolWorkArticleViewTest.php
@@ -59,11 +59,11 @@ class PoolWorkArticleViewTest extends MediaWikiIntegrationTestCase {
private function makeRevision( WikiPage $page, $text ) {
$user = $this->getTestUser()->getUser();
- $updater = $page->newPageUpdater( $user )
+ $revision = $page->newPageUpdater( $user )
->setContent( SlotRecord::MAIN, new WikitextContent( $text ) )
->saveRevision( CommentStoreComment::newUnsavedComment( 'testing' ) );
- return $updater;
+ return $revision;
}
public function testDoWorkLoadRevision() {