blob: ae11697fde3619e4349569532557b3c4b9a5a667 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<?php
namespace MediaWiki\Tests\Storage\Unit;
use ExternalStoreAccess;
use MediaWiki\Config\ServiceOptions;
use MediaWiki\MainConfigNames;
use MediaWiki\Storage\BlobStore;
use MediaWiki\Storage\BlobStoreFactory;
use MediaWiki\Storage\SqlBlobStore;
use MediaWikiUnitTestCase;
use Wikimedia\ObjectCache\WANObjectCache;
use Wikimedia\Rdbms\ILBFactory;
use Wikimedia\Rdbms\ILoadBalancer;
use Wikimedia\TestingAccessWrapper;
/**
* @covers \MediaWiki\Storage\BlobStoreFactory
*/
class BlobStoreFactoryTest extends MediaWikiUnitTestCase {
private function getBlobStoreFactory() {
$lbFactory = $this->createMock( ILBFactory::class );
$lbFactory->method( 'getMainLB' )->willReturn( $this->createMock( ILoadBalancer::class ) );
$options = [
MainConfigNames::CompressRevisions => false,
MainConfigNames::DefaultExternalStore => false,
MainConfigNames::LegacyEncoding => false,
MainConfigNames::RevisionCacheExpiry => 86400 * 7,
];
return new BlobStoreFactory(
$lbFactory,
$this->createMock( ExternalStoreAccess::class ),
$this->createMock( WANObjectCache::class ),
new ServiceOptions( BlobStoreFactory::CONSTRUCTOR_OPTIONS, $options )
);
}
public static function provideDbDomains() {
yield [ false ];
yield [ 'someWiki' ];
}
/**
* @dataProvider provideDbDomains
*/
public function testNewBlobStore( $dbDomain ) {
$factory = $this->getBlobStoreFactory();
$store = $factory->newBlobStore( $dbDomain );
$this->assertInstanceOf( BlobStore::class, $store );
// This only works as we currently know this is a SqlBlobStore object
$wrapper = TestingAccessWrapper::newFromObject( $store );
$this->assertEquals( $dbDomain, $wrapper->dbDomain );
}
/**
* @dataProvider provideDbDomains
*/
public function testNewSqlBlobStore( $dbDomain ) {
$factory = $this->getBlobStoreFactory();
$store = $factory->newSqlBlobStore( $dbDomain );
$this->assertInstanceOf( SqlBlobStore::class, $store );
$wrapper = TestingAccessWrapper::newFromObject( $store );
$this->assertEquals( $dbDomain, $wrapper->dbDomain );
}
}
|