X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FStorage%2FPageUpdaterTest.php;h=bdabf9c0cb5d973caf2475c56011845ce1b76e02;hb=297ceb4fa5c810005cb52ec264480bb305e844c2;hp=24107b1d1f8602016fec60c104deedbccf0fe09e;hpb=b5d0251882e79790cc5635d8d20eb8cd79976678;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/Storage/PageUpdaterTest.php b/tests/phpunit/includes/Storage/PageUpdaterTest.php index 24107b1d1f..bdabf9c0cb 100644 --- a/tests/phpunit/includes/Storage/PageUpdaterTest.php +++ b/tests/phpunit/includes/Storage/PageUpdaterTest.php @@ -58,12 +58,9 @@ class PageUpdaterTest extends MediaWikiTestCase { $oldStats = $this->db->selectRow( 'site_stats', '*', '1=1' ); $this->assertFalse( $updater->wasCommitted(), 'wasCommitted' ); - $this->assertFalse( $updater->getBaseRevisionId(), 'getBaseRevisionId' ); + $this->assertFalse( $updater->getOriginalRevisionId(), 'getOriginalRevisionId' ); $this->assertSame( 0, $updater->getUndidRevisionId(), 'getUndidRevisionId' ); - $updater->setBaseRevisionId( 0 ); - $this->assertSame( 0, $updater->getBaseRevisionId(), 'getBaseRevisionId' ); - $updater->addTag( 'foo' ); $updater->addTags( [ 'bar', 'qux' ] ); @@ -77,10 +74,12 @@ class PageUpdaterTest extends MediaWikiTestCase { $parent = $updater->grabParentRevision(); - // TODO: test that hasEditConflict() grabs the parent revision $this->assertNull( $parent, 'getParentRevision' ); $this->assertFalse( $updater->wasCommitted(), 'wasCommitted' ); - $this->assertFalse( $updater->hasEditConflict(), 'hasEditConflict' ); + + // TODO: test that hasEditConflict() grabs the parent revision + $this->assertFalse( $updater->hasEditConflict( 0 ), 'hasEditConflict' ); + $this->assertTrue( $updater->hasEditConflict( 1 ), 'hasEditConflict' ); // TODO: test failure with EDIT_UPDATE // TODO: test EDIT_MINOR, EDIT_BOT, etc @@ -158,10 +157,12 @@ class PageUpdaterTest extends MediaWikiTestCase { $oldStats = $this->db->selectRow( 'site_stats', '*', '1=1' ); - // TODO: test page update does not fail with mismatching base rev ID - $baseRev = $title->getLatestRevID( Title::GAID_FOR_UPDATE ); - $updater->setBaseRevisionId( $baseRev ); - $this->assertSame( $baseRev, $updater->getBaseRevisionId(), 'getBaseRevisionId' ); + $updater->setOriginalRevisionId( 7 ); + $this->assertSame( 7, $updater->getOriginalRevisionId(), 'getOriginalRevisionId' ); + + $this->assertFalse( $updater->hasEditConflict( $parentId ), 'hasEditConflict' ); + $this->assertTrue( $updater->hasEditConflict( $parentId - 1 ), 'hasEditConflict' ); + $this->assertTrue( $updater->hasEditConflict( 0 ), 'hasEditConflict' ); // TODO: MCR: test additional slots $updater->setContent( 'main', new TextContent( 'Lorem Ipsum' ) ); @@ -332,48 +333,6 @@ class PageUpdaterTest extends MediaWikiTestCase { $this->assertTrue( $status->hasMessage( 'edit-already-exists' ), 'edit-already-exists' ); } - /** - * @covers \MediaWiki\Storage\PageUpdater::saveRevision() - * @covers \MediaWiki\Storage\PageUpdater::setBaseRevisionId() - */ - public function testFailureOnBaseRevision() { - $user = $this->getTestUser()->getUser(); - - $title = $this->getDummyTitle( __METHOD__ ); - - // start editing non-existing page - $page = WikiPage::factory( $title ); - $updater = $page->newPageUpdater( $user ); - - // update for base revision 7 should fail - $summary = CommentStoreComment::newUnsavedComment( 'udpate?!' ); - $updater->setBaseRevisionId( 7 ); // expect page to exist - $updater->setContent( 'main', new TextContent( 'Lorem ipsum' ) ); - $updater->saveRevision( $summary ); - $status = $updater->getStatus(); - - $this->assertFalse( $updater->wasSuccessful(), 'wasSuccessful()' ); - $this->assertNull( $updater->getNewRevision(), 'getNewRevision()' ); - $this->assertFalse( $status->isOK(), 'getStatus()->isOK()' ); - $this->assertTrue( $status->hasMessage( 'edit-gone-missing' ), 'edit-gone-missing' ); - - // create the page - $this->createRevision( $page, __METHOD__ ); - - // update for base revision 0 should fail - $summary = CommentStoreComment::newUnsavedComment( 'create?!' ); - $updater = $page->newPageUpdater( $user ); - $updater->setBaseRevisionId( 0 ); // expect page to not exist - $updater->setContent( 'main', new TextContent( 'dolor sit amet' ) ); - $updater->saveRevision( $summary ); - $status = $updater->getStatus(); - - $this->assertFalse( $updater->wasSuccessful(), 'wasSuccessful()' ); - $this->assertNull( $updater->getNewRevision(), 'getNewRevision()' ); - $this->assertFalse( $status->isOK(), 'getStatus()->isOK()' ); - $this->assertTrue( $status->hasMessage( 'edit-already-exists' ), 'edit-already-exists' ); - } - public function provideSetRcPatrolStatus( $patrolled ) { yield [ RecentChange::PRC_UNPATROLLED ]; yield [ RecentChange::PRC_AUTOPATROLLED ];