wiki.techinc.nl/tests/phpunit/unit/includes/parser/ParserCacheFactoryTest.php
Amir Sarabadani 09b18a8f4c Reorg: Move Title-related classes to title/
These three classes:
 - TitleArray
 - TitleArrayFromResult
 - TitleFactory

We need to move these and the rest of files under title/ to Title/ (and
namespace them) but the patch will become way too big given that Title class is
also one of them.

Bug: T321882
Change-Id: Iac1688172ee457348a08a470c86e047571feb8e0
2022-11-26 09:30:32 +00:00

65 lines
1.7 KiB
PHP

<?php
use MediaWiki\Config\ServiceOptions;
use MediaWiki\Json\JsonCodec;
use MediaWiki\MainConfigNames;
use MediaWiki\Page\WikiPageFactory;
use MediaWiki\Parser\ParserCacheFactory;
use MediaWiki\Parser\RevisionOutputCache;
use MediaWiki\Title\TitleFactory;
use Psr\Log\NullLogger;
/**
* @covers \MediaWiki\Parser\ParserCacheFactory
*/
class ParserCacheFactoryTest extends MediaWikiUnitTestCase {
/**
* @return ParserCacheFactory
*/
private function newParserCacheFactory() {
$options = new ServiceOptions( ParserCacheFactory::CONSTRUCTOR_OPTIONS, [
MainConfigNames::CacheEpoch => '20200202112233',
MainConfigNames::OldRevisionParserCacheExpireTime => 60,
] );
return new ParserCacheFactory(
new HashBagOStuff(),
new WANObjectCache( [ 'cache' => new HashBagOStuff() ] ),
$this->createHookContainer(),
new JsonCodec(),
new NullStatsdDataFactory(),
new NullLogger(),
$options,
$this->createNoOpMock( TitleFactory::class ),
$this->createNoOpMock( WikiPageFactory::class )
);
}
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 );
}
}