Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7451596
EscapeCharacterValidatorTest.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
EscapeCharacterValidatorTest.php
View Options
<?php
declare
(
strict_types
=
1
);
use
MediaWiki\Extension\Translate\MessageLoading\FatMessage
;
use
MediaWiki\Extension\Translate\Validation\Validators\EscapeCharacterValidator
;
/**
* @license GPL-2.0-or-later
* @covers \MediaWiki\Extension\Translate\Validation\Validators\EscapeCharacterValidator
*/
class
EscapeCharacterValidatorTest
extends
BaseValidatorTestCase
{
/** @dataProvider provideTestCases */
public
function
test
(
$constructorParams
,
...
$params
)
{
$validator
=
new
EscapeCharacterValidator
(
$constructorParams
);
$this
->
runValidatorTests
(
$validator
,
'escape'
,
...
$params
);
}
public
static
function
provideTestCases
()
{
$message
=
new
FatMessage
(
'key'
,
'Hello'
);
yield
[
[
'values'
=>
[
'
\n
'
,
'
\\\\
'
]
],
'Hello'
,
'Hello
\n
'
,
[],
'Correct escape is not an issue'
];
yield
[
[
'values'
=>
[
'
\b
'
]
],
'Hello'
,
'Hello
\n
'
,
[
'invalid'
],
'Unsupported escape is an issue'
];
yield
[
[
'values'
=>
[
'
\\\\
'
,
'
\n
'
]
],
'Hello'
,
'Hello
\b
'
,
[
'invalid'
],
'Unsupported escape is an issue'
];
yield
[
[
'values'
=>
[
'
\\\\
'
,
'
\n
'
]
],
'Hello'
,
'Hello
\\\\
'
,
[],
'Correct escape is not an issue'
];
}
public
function
testEmptyValues
()
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
$this
->
expectExceptionMessageMatches
(
'/no values provided/i'
);
new
EscapeCharacterValidator
(
[
'values'
=>
[],
]
);
}
public
function
testInvalidEscape
()
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
$this
->
expectExceptionMessageMatches
(
'/invalid escape character/i'
);
new
EscapeCharacterValidator
(
[
'values'
=>
[
'
\c
'
],
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 21:31 (2 d, 2 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bd/46/436219f8b7cb43c6d7f1088d17ef
Default Alt Text
EscapeCharacterValidatorTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment