Tests for Revision::getRevisionText with ExternalStore usage
Bug: T180210 Change-Id: I20e47a44a064ede4f5e674f57ec4d8e39b379ad6
This commit is contained in:
parent
d6a25bd8c9
commit
962e7a4f2a
2 changed files with 47 additions and 0 deletions
|
|
@ -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 ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ class ExternalStoreForTesting {
|
|||
'300' => [
|
||||
'Hello', 'World',
|
||||
],
|
||||
// gzip string below generated with gzdeflate( 'AAAABBAAA' )
|
||||
'12345' => "sttttr\002\022\000",
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue