wiki.techinc.nl/tests/phpunit/unit/includes/cache/LinkBatchFactoryTest.php
mainframe98 297a89069a Add LinkBatchFactory to inject services into LinkBatch
All services required by LinkBatch are now injected by the
LinkBatchFactory. The constructor for LinkBatch has been
soft-deprecated, but the required services are still optional.

Bug: T239855
Depends-On: If49cbb730d4ac48586b891908cf24601efbc5d6a
Change-Id: I93d931ab60305ad49a6e419f8269c77791a3938d
2020-01-06 17:02:31 +01:00

43 lines
1,001 B
PHP

<?php
use MediaWiki\Cache\LinkBatchFactory;
use Wikimedia\Rdbms\ILoadBalancer;
/**
* @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;
}
public function testNewLinkBatch() {
$factory = new LinkBatchFactory(
$this->createMock( LinkCache::class ),
$this->createMock( TitleFormatter::class ),
$this->createMock( Language::class ),
$this->createMock( GenderCache::class ),
$this->createMock( ILoadBalancer::class )
);
$linkBatch = $factory->newLinkBatch( [
new TitleValue( NS_MAIN, 'Foo' ),
new TitleValue( NS_TALK, 'Bar' ),
] );
$this->assertFalse( $linkBatch->isEmpty() );
$this->assertSame( 2, $linkBatch->getSize() );
}
}