wiki.techinc.nl/tests/phpunit/unit/includes/parser/ParserCacheFactoryTest.php
daniel 00a3439dce Introduce RevisionOutputCache
Bug: T267981
Change-Id: Ib1dc641ed10d786918362b25bd655780d5844ba1
2020-12-14 16:50:28 +00:00

61 lines
1.5 KiB
PHP

<?php
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Json\JsonCodec;
use MediaWiki\Parser\ParserCacheFactory;
use MediaWiki\Parser\RevisionOutputCache;
use Psr\Log\NullLogger;
/**
* @covers \MediaWiki\Parser\ParserCacheFactory
*/
class ParserCacheFactoryTest extends MediaWikiUnitTestCase {
/**
* @return ParserCacheFactory
*/
private function newParserCacheFactory() {
$options = new ServiceOptions( ParserCacheFactory::CONSTRUCTOR_OPTIONS, [
'ParserCacheUseJson' => true,
'CacheEpoch' => '20200202112233',
'OldRevisionParserCacheExpireTime' => 60,
] );
return new ParserCacheFactory(
new HashBagOStuff(),
new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ),
$this->createHookContainer(),
new JsonCodec(),
new NullStatsdDataFactory(),
new NullLogger(),
$options
);
}
public function testGetParserCache() {
$factory = $this->newParserCacheFactory();
$a = $factory->getParserCache( 'test' );
$this->assertInstanceOf( ParserCache::class, $a );
$b = $factory->getParserCache( 'test' );
$this->assertSame( $a, $b );
$c = $factory->getParserCache( 'xyzzy' );
$this->assertNotSame( $a, $c );
}
public function testGetRevisionOutputCache() {
$factory = $this->newParserCacheFactory();
$a = $factory->getRevisionOutputCache( 'test' );
$this->assertInstanceOf( RevisionOutputCache::class, $a );
$b = $factory->getRevisionOutputCache( 'test' );
$this->assertSame( $a, $b );
$c = $factory->getRevisionOutputCache( 'xyzzy' );
$this->assertNotSame( $a, $c );
}
}