Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4057723
InsertableFactoryTest.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
InsertableFactoryTest.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
MediaWiki\Extension\Translate\TranslatorInterface\Insertable
;
use
InvalidArgumentException
;
use
MediaWikiUnitTestCase
;
use
MockTranslateValidator
;
/** @covers \MediaWiki\Extension\Translate\TranslatorInterface\Insertable\InsertableFactory */
class
InsertableFactoryTest
extends
MediaWikiUnitTestCase
{
/**
* @dataProvider providePreProvidedInsertables
* @dataProvider provideCustomInsertables
*/
public
function
testValidLoadInstance
(
string
$className
,
$params
=
null
)
{
$instance
=
InsertableFactory
::
make
(
$className
,
$params
);
$this
->
assertInstanceOf
(
InsertablesSuggester
::
class
,
$instance
,
'Existing class returns an instance of the InsertableSuggester'
);
}
public
function
testNonExistentInsertable
()
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
$this
->
expectExceptionMessageMatches
(
'/could not find/i'
);
InsertableFactory
::
make
(
'TranslateNonExistentClass'
,
''
);
}
public
function
testInvalidInsertable
()
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
$this
->
expectExceptionMessageMatches
(
'/does not implement/i'
);
InsertableFactory
::
make
(
MockTranslateValidator
::
class
,
''
);
}
public
static
function
providePreProvidedInsertables
()
{
yield
[
HtmlTagInsertablesSuggester
::
class
];
yield
[
RegexInsertablesSuggester
::
class
,
[
'regex'
=>
'abcd'
]
];
yield
[
RegexInsertablesSuggester
::
class
,
'abcd'
];
yield
'Preprovided insertables without fully qualified namespace'
=>
[
// Not using ::class since that would add the fully qualified namespace
'NumericalParameterInsertablesSuggester'
];
}
public
static
function
provideCustomInsertables
()
{
yield
[
\MockCustomInsertableSuggester
::
class
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 16 2026, 04:16 (12 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
93/ff/567fb91f5a5e266a39d7468457a2
Default Alt Text
InsertableFactoryTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment