Anomie has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403759 )

Change subject: Add tests for RevisionStore::newMutableRevisionFromArray and 
legacy encoding
......................................................................

Add tests for RevisionStore::newMutableRevisionFromArray and legacy encoding

Bug: T184749
Change-Id: I6dcfc0497bfce6605fa5517c9f91faf7131f4334
---
M tests/phpunit/includes/Storage/RevisionStoreDbTest.php
1 file changed, 44 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/59/403759/1

diff --git a/tests/phpunit/includes/Storage/RevisionStoreDbTest.php 
b/tests/phpunit/includes/Storage/RevisionStoreDbTest.php
index 15f173a..d685424 100644
--- a/tests/phpunit/includes/Storage/RevisionStoreDbTest.php
+++ b/tests/phpunit/includes/Storage/RevisionStoreDbTest.php
@@ -6,6 +6,7 @@
 use Exception;
 use HashBagOStuff;
 use InvalidArgumentException;
+use Language;
 use MediaWiki\Linker\LinkTarget;
 use MediaWiki\MediaWikiServices;
 use MediaWiki\Storage\IncompleteRevisionException;
@@ -1026,6 +1027,22 @@
                                'content' => new WikitextContent( 'Some 
Content' ),
                        ]
                ];
+               yield 'Basic array, serialized text' => [
+                       [
+                               'id' => 2,
+                               'page' => 1,
+                               'timestamp' => '20171017114835',
+                               'user_text' => '111.0.1.2',
+                               'user' => 0,
+                               'minor_edit' => false,
+                               'deleted' => 0,
+                               'len' => 46,
+                               'parent_id' => 1,
+                               'sha1' => 'rdqbbzs3pkhihgbs8qf2q9jsvheag5z',
+                               'comment' => 'Goat Comment!',
+                               'text' => ( new WikitextContent( 'Söme Content' 
) )->serialize(),
+                       ]
+               ];
                yield 'Basic array, with title' => [
                        [
                                'title' => Title::newFromText( 'SomeText' ),
@@ -1092,6 +1109,8 @@
                        $this->assertTrue(
                                $result->getSlot( 'main' 
)->getContent()->equals( $array['content'] )
                        );
+               } elseif ( isset( $array['text'] ) ) {
+                       $this->assertSame( $array['text'], $result->getSlot( 
'main' )->getContent()->serialize() );
                } else {
                        $this->assertSame(
                                $array['content_format'],
@@ -1101,4 +1120,29 @@
                }
        }
 
+       /**
+        * @dataProvider provideNewMutableRevisionFromArray
+        * @covers \MediaWiki\Storage\RevisionStore::newMutableRevisionFromArray
+        */
+       public function testNewMutableRevisionFromArray_legacyEncoding( array 
$array ) {
+               $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] 
);
+               $blobStore = new SqlBlobStore( wfGetLB(), $cache );
+               $blobStore->setLegacyEncoding( 'windows-1252', 
Language::factory( 'en' ) );
+
+               $factory = $this->getMockBuilder( BlobStoreFactory::class )
+                       ->setMethods( [ 'newBlobStore', 'newSqlBlobStore' ] )
+                       ->disableOriginalConstructor()
+                       ->getMock();
+               $factory->expects( $this->any() )
+                       ->method( 'newBlobStore' )
+                       ->willReturn( $blobStore );
+               $factory->expects( $this->any() )
+                       ->method( 'newSqlBlobStore' )
+                       ->willReturn( $blobStore );
+
+               $this->setService( 'BlobStoreFactory', $factory );
+
+               $this->testNewMutableRevisionFromArray( $array );
+       }
+
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6dcfc0497bfce6605fa5517c9f91faf7131f4334
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to