jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/391183 )

Change subject: Initial tests for Revision::getRevisionText
......................................................................


Initial tests for Revision::getRevisionText

Bug: T180210
Change-Id: Idd5c1af7ecc336ba3f32b15fd8d5cb5bd19f649b
---
M tests/phpunit/includes/RevisionTest.php
1 file changed, 66 insertions(+), 0 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/includes/RevisionTest.php 
b/tests/phpunit/includes/RevisionTest.php
index 953c795..ca8ed2b 100644
--- a/tests/phpunit/includes/RevisionTest.php
+++ b/tests/phpunit/includes/RevisionTest.php
@@ -466,4 +466,70 @@
                );
        }
 
+       /**
+        * @covers Revision::getRevisionText
+        */
+       public function testGetRevisionText_returnsFalseWhenNoTextField() {
+               $this->assertFalse( Revision::getRevisionText( new stdClass() ) 
);
+       }
+
+       public function 
provideTestGetRevisionText_returnsDecompressedTextFieldWhenNotExternal() {
+               yield 'Just text' => [
+                       (object)[ 'old_text' => 'SomeText' ],
+                       'old_',
+                       'SomeText'
+               ];
+               // gzip string below generated with gzdeflate( 'AAAABBAAA' )
+               yield 'gzip text' => [
+                       (object)[
+                               'old_text' => "sttttr\002\022\000",
+                               'old_flags' => 'gzip'
+                       ],
+                       'old_',
+                       'AAAABBAAA'
+               ];
+               yield 'gzip text and different prefix' => [
+                       (object)[
+                               'jojo_text' => "sttttr\002\022\000",
+                               'jojo_flags' => 'gzip'
+                       ],
+                       'jojo_',
+                       'AAAABBAAA'
+               ];
+       }
+
+       /**
+        * @dataProvider 
provideTestGetRevisionText_returnsDecompressedTextFieldWhenNotExternal
+        * @covers Revision::getRevisionText
+        */
+       public function 
testGetRevisionText_returnsDecompressedTextFieldWhenNotExternal(
+               $row,
+               $prefix,
+               $expected
+       ) {
+               $this->assertSame( $expected, Revision::getRevisionText( $row, 
$prefix ) );
+       }
+
+       public function 
provideTestGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts() {
+               yield 'Just some text' => [ 'someNonUrlText' ];
+               yield 'No second URL part' => [ 'someProtocol://' ];
+       }
+
+       /**
+        * @dataProvider 
provideTestGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts
+        * @covers Revision::getRevisionText
+        */
+       public function 
testGetRevisionText_external_returnsFalseWhenNotEnoughUrlParts(
+               $text
+       ) {
+               $this->assertFalse(
+                       Revision::getRevisionText(
+                               (object)[
+                                       'old_text' => $text,
+                                       'old_flags' => 'external',
+                               ]
+                       )
+               );
+       }
+
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/391183
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idd5c1af7ecc336ba3f32b15fd8d5cb5bd19f649b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <addshorew...@gmail.com>
Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to