From 4b928c87dcb939ef41333d120ec841bdcb912d6a Mon Sep 17 00:00:00 2001 From: addshore Date: Thu, 11 Jan 2018 20:55:37 +0000 Subject: [PATCH] Extra tests for SqlBlobStore with 'windows-1252' legacy encoding Bug: T184749 Change-Id: Ida717dbe6ae742b3b61f0f09dc60712307c53a96 --- .../includes/Storage/SqlBlobStoreTest.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/phpunit/includes/Storage/SqlBlobStoreTest.php b/tests/phpunit/includes/Storage/SqlBlobStoreTest.php index 6d2b09b7e0..dbbef11efc 100644 --- a/tests/phpunit/includes/Storage/SqlBlobStoreTest.php +++ b/tests/phpunit/includes/Storage/SqlBlobStoreTest.php @@ -134,6 +134,18 @@ class SqlBlobStoreTest extends MediaWikiTestCase { [ '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', + ]; } /** @@ -190,6 +202,7 @@ class SqlBlobStoreTest extends MediaWikiTestCase { public function provideBlobs() { yield [ '' ]; yield [ 'someText' ]; + yield [ "sammansättningar" ]; } /** @@ -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 ) ); + } + } -- 2.20.1