jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/390228 )
Change subject: Add tests for various simple Revision get and is methods
......................................................................
Add tests for various simple Revision get and is methods
These tests dont cover all code paths for these methods
in some cases but it does ensure that tests actually call
them / test basical functionality.
Some of these methods are touched in
I4f24e7fbb683cb51f3fd8b250732bae9c7541ba2
hence adding some test coverage now.
Change-Id: I7eb67cb5876f89034238591c0a98f4ec6d890a40
---
M tests/phpunit/includes/RevisionIntegrationTest.php
1 file changed, 143 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 ad211c6..403983c 100644
--- a/tests/phpunit/includes/RevisionIntegrationTest.php
+++ b/tests/phpunit/includes/RevisionIntegrationTest.php
@@ -1077,4 +1077,147 @@
$this->assertNull( $rev->getTitle() );
}
+ /**
+ * @covers Revision::isMinor
+ */
+ public function testIsMinor_true() {
+ // Use a sysop to ensure we can mark edits as minor
+ $sysop = $this->getTestSysop()->getUser();
+
+ $this->testPage->doEditContent(
+ new WikitextContent( __METHOD__ ),
+ __METHOD__,
+ EDIT_MINOR,
+ false,
+ $sysop
+ );
+ $rev = $this->testPage->getRevision();
+
+ $this->assertSame( true, $rev->isMinor() );
+ }
+
+ /**
+ * @covers Revision::isMinor
+ */
+ public function testIsMinor_false() {
+ $this->testPage->doEditContent(
+ new WikitextContent( __METHOD__ ),
+ __METHOD__,
+ 0
+ );
+ $rev = $this->testPage->getRevision();
+
+ $this->assertSame( false, $rev->isMinor() );
+ }
+
+ /**
+ * @covers Revision::getTimestamp
+ */
+ public function testGetTimestamp() {
+ $testTimestamp = wfTimestampNow();
+
+ $this->testPage->doEditContent(
+ new WikitextContent( __METHOD__ ),
+ __METHOD__
+ );
+ $rev = $this->testPage->getRevision();
+
+ $this->assertInternalType( 'string', $rev->getTimestamp() );
+ $this->assertTrue( strlen( $rev->getTimestamp() ) == strlen(
'YYYYMMDDHHMMSS' ) );
+ $this->assertContains( substr( $testTimestamp, 0, 10 ),
$rev->getTimestamp() );
+ }
+
+ /**
+ * @covers Revision::getUser
+ * @covers Revision::getUserText
+ */
+ public function testGetUserAndText() {
+ $sysop = $this->getTestSysop()->getUser();
+
+ $this->testPage->doEditContent(
+ new WikitextContent( __METHOD__ ),
+ __METHOD__,
+ 0,
+ false,
+ $sysop
+ );
+ $rev = $this->testPage->getRevision();
+
+ $this->assertSame( $sysop->getId(), $rev->getUser() );
+ $this->assertSame( $sysop->getName(), $rev->getUserText() );
+ }
+
+ /**
+ * @covers Revision::isDeleted
+ */
+ public function testIsDeleted_nothingDeleted() {
+ $rev = $this->testPage->getRevision();
+
+ $this->assertSame( false, $rev->isDeleted(
Revision::DELETED_TEXT ) );
+ $this->assertSame( false, $rev->isDeleted(
Revision::DELETED_COMMENT ) );
+ $this->assertSame( false, $rev->isDeleted(
Revision::DELETED_RESTRICTED ) );
+ $this->assertSame( false, $rev->isDeleted(
Revision::DELETED_USER ) );
+ }
+
+ /**
+ * @covers Revision::getVisibility
+ */
+ public function testGetVisibility_nothingDeleted() {
+ $rev = $this->testPage->getRevision();
+
+ $this->assertSame( 0, $rev->getVisibility() );
+ }
+
+ /**
+ * @covers Revision::getComment
+ */
+ public function testGetComment_notDeleted() {
+ $expectedSummary = 'goatlicious summary';
+
+ $this->testPage->doEditContent(
+ new WikitextContent( __METHOD__ ),
+ $expectedSummary
+ );
+ $rev = $this->testPage->getRevision();
+
+ $this->assertSame( $expectedSummary, $rev->getComment() );
+ }
+
+ /**
+ * This is a simple blanket test for all simple getters and is methods
to provide some
+ * coverage before the split of Revision into multiple classes for MCR
work.
+ * @covers Revision::isUnpatrolled
+ */
+ public function testIsUnpatrolled_true() {
+ $rev = $this->testPage->getRevision();
+
+ $this->assertSame( 0, $rev->isUnpatrolled() );
+ }
+
+ /**
+ * This is a simple blanket test for all simple content getters and is
methods to provide some
+ * coverage before the split of Revision into multiple classes for MCR
work.
+ * @covers Revision::getContent
+ * @covers Revision::getSerializedData
+ * @covers Revision::getContentModel
+ * @covers Revision::getContentFormat
+ * @covers Revision::getContentHandler
+ */
+ public function testSimpleContentGetters() {
+ $expectedText = 'testSimpleContentGetters in Revision. Goats
love MCR...';
+ $expectedSummary = 'goatlicious testSimpleContentGetters
summary';
+
+ $this->testPage->doEditContent(
+ new WikitextContent( $expectedText ),
+ $expectedSummary
+ );
+ $rev = $this->testPage->getRevision();
+
+ $this->assertSame( $expectedText,
$rev->getContent()->getNativeData() );
+ $this->assertSame( $expectedText, $rev->getSerializedData() );
+ $this->assertSame( $this->testPage->getContentModel(),
$rev->getContentModel() );
+ $this->assertSame(
$this->testPage->getContent()->getDefaultFormat(), $rev->getContentFormat() );
+ $this->assertSame( $this->testPage->getContentHandler(),
$rev->getContentHandler() );
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/390228
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7eb67cb5876f89034238591c0a98f4ec6d890a40
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Reedy <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits