2021-09-08 17:19:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use MediaWiki\Cache\BacklinkCacheFactory;
|
2023-10-02 18:10:11 +00:00
|
|
|
use MediaWiki\Config\ServiceOptions;
|
|
|
|
|
use MediaWiki\Linker\LinksMigration;
|
2021-09-08 17:19:11 +00:00
|
|
|
use MediaWiki\Page\PageReferenceValue;
|
2023-07-05 08:57:11 +00:00
|
|
|
use Wikimedia\Rdbms\IConnectionProvider;
|
2021-09-08 17:19:11 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @group Cache
|
|
|
|
|
*/
|
|
|
|
|
class BacklinkCacheFactoryTest extends MediaWikiUnitTestCase {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @covers MediaWiki\Cache\BacklinkCacheFactory::getBacklinkCache
|
|
|
|
|
*/
|
|
|
|
|
public function testGetBacklinkCache() {
|
|
|
|
|
$wanCache = new WANObjectCache( [ 'cache' => new EmptyBagOStuff() ] );
|
2023-07-05 08:57:11 +00:00
|
|
|
$dbProvider = $this->createMock( IConnectionProvider::class );
|
2021-09-08 17:19:11 +00:00
|
|
|
$page = PageReferenceValue::localReference( NS_CATEGORY, "kittens" );
|
2022-11-19 21:37:44 +00:00
|
|
|
$factory = new BacklinkCacheFactory(
|
2023-10-02 18:10:11 +00:00
|
|
|
$this->createMock( ServiceOptions::class ),
|
|
|
|
|
$this->createMock( LinksMigration::class ),
|
2022-11-19 21:37:44 +00:00
|
|
|
$wanCache,
|
2023-07-05 08:57:11 +00:00
|
|
|
$this->createHookContainer(),
|
|
|
|
|
$dbProvider
|
2022-11-19 21:37:44 +00:00
|
|
|
);
|
2021-09-08 17:19:11 +00:00
|
|
|
$cache = $factory->getBacklinkCache( $page );
|
|
|
|
|
$this->assertTrue( $cache->getPage()->isSamePageAs( $page ) );
|
|
|
|
|
|
|
|
|
|
$cache2 = $factory->getBacklinkCache( $page );
|
|
|
|
|
$this->assertSame( $cache, $cache2 );
|
|
|
|
|
|
|
|
|
|
$page2 = PageReferenceValue::localReference( NS_CATEGORY, "doggos" );
|
|
|
|
|
$cache2 = $factory->getBacklinkCache( $page2 );
|
|
|
|
|
$this->assertNotSame( $cache, $cache2 );
|
|
|
|
|
$this->assertTrue( $cache2->getPage()->isSamePageAs( $page2 ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|