From: addshore Date: Tue, 14 Nov 2017 12:03:39 +0000 (+0000) Subject: Tests for Revision::getRevisionText with ExternalStore usage X-Git-Tag: 1.31.0-rc.0~1523 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=962e7a4f2a78ad93e7354ff75d8529692afb1c1f;p=lhc%2Fweb%2Fwiklou.git Tests for Revision::getRevisionText with ExternalStore usage Bug: T180210 Change-Id: I20e47a44a064ede4f5e674f57ec4d8e39b379ad6 --- diff --git a/tests/phpunit/includes/RevisionTest.php b/tests/phpunit/includes/RevisionTest.php index ca8ed2bcc1..b7e410c14d 100644 --- a/tests/phpunit/includes/RevisionTest.php +++ b/tests/phpunit/includes/RevisionTest.php @@ -532,4 +532,49 @@ class RevisionTest extends MediaWikiTestCase { ); } + /** + * @covers Revision::getRevisionText + */ + public function testGetRevisionText_external_noOldId() { + $this->setService( + 'ExternalStoreFactory', + new ExternalStoreFactory( [ 'ForTesting' ] ) + ); + $this->assertSame( + 'AAAABBAAA', + Revision::getRevisionText( + (object)[ + 'old_text' => 'ForTesting://cluster1/12345', + 'old_flags' => 'external,gzip', + ] + ) + ); + } + + /** + * @covers Revision::getRevisionText + */ + public function testGetRevisionText_external_oldId() { + $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ); + $this->setService( 'MainWANObjectCache', $cache ); + $this->setService( + 'ExternalStoreFactory', + new ExternalStoreFactory( [ 'ForTesting' ] ) + ); + + $cacheKey = $cache->makeKey( 'revisiontext', 'textid', '7777' ); + + $this->assertSame( + 'AAAABBAAA', + Revision::getRevisionText( + (object)[ + 'old_text' => 'ForTesting://cluster1/12345', + 'old_flags' => 'external,gzip', + 'old_id' => '7777', + ] + ) + ); + $this->assertSame( 'AAAABBAAA', $cache->get( $cacheKey ) ); + } + } diff --git a/tests/phpunit/includes/externalstore/ExternalStoreForTesting.php b/tests/phpunit/includes/externalstore/ExternalStoreForTesting.php index b151957f9b..50f1e523b1 100644 --- a/tests/phpunit/includes/externalstore/ExternalStoreForTesting.php +++ b/tests/phpunit/includes/externalstore/ExternalStoreForTesting.php @@ -8,6 +8,8 @@ class ExternalStoreForTesting { '300' => [ 'Hello', 'World', ], + // gzip string below generated with gzdeflate( 'AAAABBAAA' ) + '12345' => "sttttr\002\022\000", ], ];