Add tablesUsed to RevisionStoreDbTest
[lhc/web/wiklou.git] / tests / phpunit / includes / Storage / SqlBlobStoreTest.php
index 12d8119..dbbef11 100644 (file)
@@ -37,8 +37,8 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers SqlBlobStore::getCompressBlobs()
-        * @covers SqlBlobStore::setCompressBlobs()
+        * @covers \MediaWiki\Storage\SqlBlobStore::getCompressBlobs()
+        * @covers \MediaWiki\Storage\SqlBlobStore::setCompressBlobs()
         */
        public function testGetSetCompressRevisions() {
                $store = $this->getBlobStore();
@@ -48,9 +48,9 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers SqlBlobStore::getLegacyEncoding()
-        * @covers SqlBlobStore::getLegacyEncodingConversionLang()
-        * @covers SqlBlobStore::setLegacyEncoding()
+        * @covers \MediaWiki\Storage\SqlBlobStore::getLegacyEncoding()
+        * @covers \MediaWiki\Storage\SqlBlobStore::getLegacyEncodingConversionLang()
+        * @covers \MediaWiki\Storage\SqlBlobStore::setLegacyEncoding()
         */
        public function testGetSetLegacyEncoding() {
                $store = $this->getBlobStore();
@@ -63,8 +63,8 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers SqlBlobStore::getCacheExpiry()
-        * @covers SqlBlobStore::setCacheExpiry()
+        * @covers \MediaWiki\Storage\SqlBlobStore::getCacheExpiry()
+        * @covers \MediaWiki\Storage\SqlBlobStore::setCacheExpiry()
         */
        public function testGetSetCacheExpiry() {
                $store = $this->getBlobStore();
@@ -74,8 +74,8 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers SqlBlobStore::getUseExternalStore()
-        * @covers SqlBlobStore::setUseExternalStore()
+        * @covers \MediaWiki\Storage\SqlBlobStore::getUseExternalStore()
+        * @covers \MediaWiki\Storage\SqlBlobStore::setUseExternalStore()
         */
        public function testGetSetUseExternalStore() {
                $store = $this->getBlobStore();
@@ -112,33 +112,45 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
                ];
                yield '(ISO-8859-1 encoding), string in string out' => [
                        'ISO-8859-1',
-                       iconv( 'utf8', 'ISO-8859-1', "1®Àþ1" ),
+                       iconv( 'utf-8', 'ISO-8859-1', "1®Àþ1" ),
                        [],
                        '1®Àþ1',
                ];
                yield '(ISO-8859-1 encoding), serialized object in with gzip flags returns string' => [
                        'ISO-8859-1',
-                       gzdeflate( iconv( 'utf8', 'ISO-8859-1', "4®Àþ4" ) ),
+                       gzdeflate( iconv( 'utf-8', 'ISO-8859-1', "4®Àþ4" ) ),
                        [ 'gzip' ],
                        '4®Àþ4',
                ];
                yield '(ISO-8859-1 encoding), serialized object in with object flags returns string' => [
                        'ISO-8859-1',
-                       serialize( new TitleValue( 0, iconv( 'utf8', 'ISO-8859-1', "3®Àþ3" ) ) ),
+                       serialize( new TitleValue( 0, iconv( 'utf-8', 'ISO-8859-1', "3®Àþ3" ) ) ),
                        [ 'object' ],
                        '3®Àþ3',
                ];
                yield '(ISO-8859-1 encoding), serialized object in with object & gzip flags returns string' => [
                        'ISO-8859-1',
-                       gzdeflate( serialize( new TitleValue( 0, iconv( 'utf8', 'ISO-8859-1', "2®Àþ2" ) ) ) ),
+                       gzdeflate( serialize( new TitleValue( 0, iconv( 'utf-8', 'ISO-8859-1', "2®Àþ2" ) ) ) ),
                        [ 'gzip', 'object' ],
                        '2®Àþ2',
                ];
+               yield 'T184749 (windows-1252 encoding), string in string out' => [
+                       'windows-1252',
+                       iconv( 'utf-8', 'windows-1252', "sammansättningar" ),
+                       [],
+                       'sammansättningar',
+               ];
+               yield 'T184749 (windows-1252 encoding), string in string out with gzip' => [
+                       'windows-1252',
+                       gzdeflate( iconv( 'utf-8', 'windows-1252', "sammansättningar" ) ),
+                       [ 'gzip' ],
+                       'sammansättningar',
+               ];
        }
 
        /**
         * @dataProvider provideDecompress
-        * @covers SqlBlobStore::decompressData
+        * @covers \MediaWiki\Storage\SqlBlobStore::decompressData
         *
         * @param string|bool $legacyEncoding
         * @param mixed $data
@@ -154,7 +166,7 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers SqlBlobStore::compressData
+        * @covers \MediaWiki\Storage\SqlBlobStore::compressData
         */
        public function testCompressRevisionTextUtf8() {
                $store = $this->getBlobStore();
@@ -170,7 +182,7 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
        }
 
        /**
-        * @covers SqlBlobStore::compressData
+        * @covers \MediaWiki\Storage\SqlBlobStore::compressData
         */
        public function testCompressRevisionTextUtf8Gzip() {
                $store = $this->getBlobStore( false, true );
@@ -190,12 +202,13 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
        public function provideBlobs() {
                yield [ '' ];
                yield [ 'someText' ];
+               yield [ "sammansättningar" ];
        }
 
        /**
         * @dataProvider provideBlobs
-        * @covers SqlBlobStore::storeBlob
-        * @covers SqlBlobStore::getBlob
+        * @covers \MediaWiki\Storage\SqlBlobStore::storeBlob
+        * @covers \MediaWiki\Storage\SqlBlobStore::getBlob
         */
        public function testSimpleStoreGetBlobSimpleRoundtrip( $blob ) {
                $store = $this->getBlobStore();
@@ -203,4 +216,26 @@ class SqlBlobStoreTest extends MediaWikiTestCase {
                $this->assertSame( $blob, $store->getBlob( $address ) );
        }
 
+       /**
+        * @dataProvider provideBlobs
+        * @covers \MediaWiki\Storage\SqlBlobStore::storeBlob
+        * @covers \MediaWiki\Storage\SqlBlobStore::getBlob
+        */
+       public function testSimpleStoreGetBlobSimpleRoundtripWindowsLegacyEncoding( $blob ) {
+               $store = $this->getBlobStore( 'windows-1252' );
+               $address = $store->storeBlob( $blob );
+               $this->assertSame( $blob, $store->getBlob( $address ) );
+       }
+
+       /**
+        * @dataProvider provideBlobs
+        * @covers \MediaWiki\Storage\SqlBlobStore::storeBlob
+        * @covers \MediaWiki\Storage\SqlBlobStore::getBlob
+        */
+       public function testSimpleStoreGetBlobSimpleRoundtripWindowsLegacyEncodingGzip( $blob ) {
+               $store = $this->getBlobStore( 'windows-1252', true );
+               $address = $store->storeBlob( $blob );
+               $this->assertSame( $blob, $store->getBlob( $address ) );
+       }
+
 }