Addshore has uploaded a new change for review. (
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core
refs/changes/28/390228/1
diff --git a/tests/phpunit/includes/RevisionIntegrationTest.php
b/tests/phpunit/includes/RevisionIntegrationTest.php
index 4909fff..4a87383 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: newchange
Gerrit-Change-Id: I7eb67cb5876f89034238591c0a98f4ec6d890a40
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits