Debian Codegraph @

tests/phpunit/unit/includes/cache/LinkBatchFactoryTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Cache\GenderCache;
4 use MediaWiki\Cache\LinkBatch;
5 use MediaWiki\Cache\LinkBatchFactory;
6 use MediaWiki\Cache\LinkCache;
7 use MediaWiki\Language\Language;
8 use MediaWiki\Linker\LinksMigration;
9 use MediaWiki\Logger\LoggerFactory;
10 use MediaWiki\Page\PageReference;
11 use MediaWiki\Page\PageReferenceValue;
12 use MediaWiki\Title\TitleFormatter;
13 use MediaWiki\Title\TitleValue;
14 use Wikimedia\Rdbms\IConnectionProvider;
15
16 /**
17 * @group Cache
18 * @covers \MediaWiki\Cache\LinkBatchFactory
19 */
20 class LinkBatchFactoryTest extends MediaWikiUnitTestCase {
21 use FactoryArgTestTrait;
22
23 protected static function getFactoryClass() {
24 return LinkBatchFactory::class;
25 }
26
27 protected static function getInstanceClass() {
28 return LinkBatch::class;
29 }
30
31 protected static function getExtraClassArgCount() {
32 // $arr
33 return 1;
34 }
35
36 protected function getOverriddenMockValueForParam( ReflectionParameter $param ) {
37 if ( $param->getName() === 'initialItems' ) {
38 return [ [] ];
39 }
40 return [];
41 }
42
43 public function testNewLinkBatch() {
44 $factory = new LinkBatchFactory(
45 $this->createMock( LinkCache::class ),
46 $this->createMock( TitleFormatter::class ),
47 $this->createMock( Language::class ),
48 $this->createMock( GenderCache::class ),
49 $this->createMock( IConnectionProvider::class ),
50 $this->createMock( LinksMigration::class ),
51 LoggerFactory::getInstance( 'LinkBatch' )
52 );
53
54 $linkBatch = $factory->newLinkBatch( [
55 new TitleValue( NS_MAIN, 'Foo' ),
56 new PageReferenceValue( NS_TALK, 'Bar', PageReference::LOCAL ),
57 ] );
58
59 $this->assertFalse( $linkBatch->isEmpty() );
60 $this->assertSame( 2, $linkBatch->getSize() );
61 }
62 }