Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5977569
BlobStoreFactoryTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
BlobStoreFactoryTest.php
View Options
<?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
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 19:59 (2 d, 22 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5c/2c/dc71c9cd502ad8b2457dbb2072bd
Default Alt Text
BlobStoreFactoryTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment