Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7411632
RepoGroupTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
RepoGroupTest.php
View Options
<?php
use
MediaWiki\MainConfigNames
;
/**
* @covers \RepoGroup
*/
class
RepoGroupTest
extends
MediaWikiIntegrationTestCase
{
public
function
testHasForeignRepoNegative
()
{
$this
->
overrideConfigValue
(
MainConfigNames
::
ForeignFileRepos
,
[]
);
$this
->
assertFalse
(
$this
->
getServiceContainer
()->
getRepoGroup
()->
hasForeignRepos
()
);
}
public
function
testHasForeignRepoPositive
()
{
$this
->
setUpForeignRepo
();
$this
->
assertTrue
(
$this
->
getServiceContainer
()->
getRepoGroup
()->
hasForeignRepos
()
);
}
public
function
testForEachForeignRepo
()
{
$this
->
setUpForeignRepo
();
$fakeCallback
=
$this
->
createMock
(
RepoGroupTestHelper
::
class
);
$fakeCallback
->
expects
(
$this
->
once
()
)->
method
(
'callback'
);
$this
->
getServiceContainer
()->
getRepoGroup
()->
forEachForeignRepo
(
[
$fakeCallback
,
'callback'
],
[
[]
]
);
}
public
function
testForEachForeignRepoNone
()
{
$this
->
overrideConfigValue
(
MainConfigNames
::
ForeignFileRepos
,
[]
);
$fakeCallback
=
$this
->
createMock
(
RepoGroupTestHelper
::
class
);
$fakeCallback
->
expects
(
$this
->
never
()
)->
method
(
'callback'
);
$this
->
getServiceContainer
()->
getRepoGroup
()->
forEachForeignRepo
(
[
$fakeCallback
,
'callback'
],
[
[]
]
);
}
private
function
setUpForeignRepo
()
{
global
$wgUploadDirectory
;
$this
->
overrideConfigValue
(
MainConfigNames
::
ForeignFileRepos
,
[
[
'class'
=>
ForeignAPIRepo
::
class
,
'name'
=>
'wikimediacommons'
,
'backend'
=>
'wikimediacommons-backend'
,
'apibase'
=>
'https://commons.wikimedia.org/w/api.php'
,
'hashLevels'
=>
2
,
'fetchDescription'
=>
true
,
'descriptionCacheExpiry'
=>
43200
,
'apiThumbCacheExpiry'
=>
86400
,
'directory'
=>
$wgUploadDirectory
]
]
);
}
}
/**
* Quick helper class to use as a mock callback for RepoGroup::forEachForeignRepo.
*/
class
RepoGroupTestHelper
{
public
function
callback
(
FileRepo
$repo
,
array
$foo
)
{
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 23:43 (1 d, 21 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
6c/30/d78a291b0fb389add8a1419be8bd
Default Alt Text
RepoGroupTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment