jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/386604 )
Change subject: Add test for Revision::insertOn ...................................................................... Add test for Revision::insertOn The success test indicates a change in behaviour of the insertOn method once I4f24e7fbb683cb51f3fd8b250732bae9c7541ba2 is applied. Change-Id: I987d64c5bc3788b7d6b0a858ff39e97fae38de3c --- M tests/phpunit/includes/RevisionIntegrationTest.php 1 file changed, 72 insertions(+), 0 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/tests/phpunit/includes/RevisionIntegrationTest.php b/tests/phpunit/includes/RevisionIntegrationTest.php index 9dcd0cf..10186ed 100644 --- a/tests/phpunit/includes/RevisionIntegrationTest.php +++ b/tests/phpunit/includes/RevisionIntegrationTest.php @@ -152,6 +152,78 @@ } /** + * @covers Revision::insertOn + */ + public function testInsertOn_success() { + $parentId = $this->testPage->getLatest(); + + // If an ExternalStore is set don't use it. + $this->setMwGlobals( 'wgDefaultExternalStore', false ); + + $rev = new Revision( [ + 'page' => $this->testPage->getId(), + 'title' => $this->testPage->getTitle(), + 'text' => 'Revision Text', + 'comment' => 'Revision comment', + ] ); + + $revId = $rev->insertOn( wfGetDB( DB_MASTER ) ); + + $this->assertInternalType( 'integer', $revId ); + $this->assertInternalType( 'integer', $rev->getTextId() ); + $this->assertSame( $revId, $rev->getId() ); + + $this->assertSelect( + 'text', + [ 'old_id', 'old_text' ], + "old_id = {$rev->getTextId()}", + [ [ strval( $rev->getTextId() ), 'Revision Text' ] ] + ); + $this->assertSelect( + 'revision', + [ + 'rev_id', + 'rev_page', + 'rev_text_id', + 'rev_user', + 'rev_minor_edit', + 'rev_deleted', + 'rev_len', + 'rev_parent_id', + 'rev_sha1', + ], + "rev_id = {$rev->getId()}", + [ [ + strval( $rev->getId() ), + strval( $this->testPage->getId() ), + strval( $rev->getTextId() ), + '0', + '0', + '0', + '13', + strval( $parentId ), + 's0ngbdoxagreuf2vjtuxzwdz64n29xm', + ] ] + ); + } + + /** + * @covers Revision::insertOn + */ + public function testInsertOn_exceptionOnNoPage() { + // If an ExternalStore is set don't use it. + $this->setMwGlobals( 'wgDefaultExternalStore', false ); + $this->setExpectedException( + MWException::class, + "Cannot insert revision: page ID must be nonzero" + ); + + $rev = new Revision( [] ); + + $rev->insertOn( wfGetDB( DB_MASTER ) ); + } + + /** * @covers Revision::newFromTitle */ public function testNewFromTitle_withoutId() { -- To view, visit https://gerrit.wikimedia.org/r/386604 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I987d64c5bc3788b7d6b0a858ff39e97fae38de3c Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Legoktm <lego...@member.fsf.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits