Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4141981
RegexGeneratorTest.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
RegexGeneratorTest.php
View Options
<?php
namespace
Eris\Generator
;
use
Eris\Random\RandomRange
;
use
Eris\Random\RandSource
;
class
RegexGeneratorTest
extends
\PHPUnit\Framework\TestCase
{
/**
* @var int
*/
private
$size
;
/**
* @var RandomRange
*/
private
$rand
;
public
static
function
supportedRegexes
()
{
return
[
// [".{0,100}"] sometimes generates NULL
[
"[a-z0-9]{24}"
],
[
"[a-z]{1,5}"
],
[
"^[a-z]$"
],
[
"a|b|c"
],
[
"
\d\s\w
"
],
];
}
protected
function
setUp
():
void
{
$this
->
size
=
10
;
$this
->
rand
=
new
RandomRange
(
new
RandSource
());
}
/**
* @dataProvider supportedRegexes
*/
public
function
testGeneratesOnlyValuesThatMatchTheRegex
(
$expression
)
{
$generator
=
new
RegexGenerator
(
$expression
);
for
(
$i
=
0
;
$i
<
100
;
$i
++)
{
$value
=
$generator
(
$this
->
size
,
$this
->
rand
)->
unbox
();
\Eris\PHPUnitDeprecationHelper
::
assertMatchesRegularExpression
(
"/{$expression}/"
,
$value
);
}
}
public
function
testShrinkingIsNotImplementedYet
()
{
$generator
=
new
RegexGenerator
(
".*"
);
$word
=
GeneratedValueSingle
::
fromJustValue
(
"something"
);
$this
->
assertEquals
(
$word
,
$generator
->
shrink
(
$word
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Aug 19, 16:10 (4 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
e3/aa/a8244e6ad74bb3a0dedd8c2fb45f
Default Alt Text
RegexGeneratorTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment