wiki.techinc.nl/tests/phpunit/unit/includes/cache/LinkBatchFactoryTest.php
Amir Sarabadani d44c45c76a watcheditem: Switch out of LB for picking db connection
A bit of a clean up. Switching out of lbFactory to ICP is not possible
at the moment because there is $this->lbFactory->getLocalDomainID()
for cache prefix. Fixable later.

Bug: T330641
Change-Id: I2d4537f75f5877552c6d9fd2b76c5be1959ea400
2023-05-05 15:42:10 +02:00

56 lines
1.4 KiB
PHP

<?php
use MediaWiki\Cache\LinkBatchFactory;
use MediaWiki\Linker\LinksMigration;
use MediaWiki\Logger\LoggerFactory;
use MediaWiki\Page\PageReference;
use MediaWiki\Page\PageReferenceValue;
use Wikimedia\Rdbms\IConnectionProvider;
/**
* @group Cache
* @covers \MediaWiki\Cache\LinkBatchFactory
*/
class LinkBatchFactoryTest extends MediaWikiUnitTestCase {
use FactoryArgTestTrait;
protected static function getFactoryClass() {
return LinkBatchFactory::class;
}
protected static function getInstanceClass() {
return LinkBatch::class;
}
protected static function getExtraClassArgCount() {
// $arr
return 1;
}
protected function getOverriddenMockValueForParam( ReflectionParameter $param ) {
if ( $param->getName() === 'initialItems' ) {
return [ [] ];
}
return [];
}
public function testNewLinkBatch() {
$factory = new LinkBatchFactory(
$this->createMock( LinkCache::class ),
$this->createMock( TitleFormatter::class ),
$this->createMock( Language::class ),
$this->createMock( GenderCache::class ),
$this->createMock( IConnectionProvider::class ),
$this->createMock( LinksMigration::class ),
LoggerFactory::getInstance( 'LinkBatch' )
);
$linkBatch = $factory->newLinkBatch( [
new TitleValue( NS_MAIN, 'Foo' ),
new PageReferenceValue( NS_TALK, 'Bar', PageReference::LOCAL ),
] );
$this->assertFalse( $linkBatch->isEmpty() );
$this->assertSame( 2, $linkBatch->getSize() );
}
}