Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F6040359
NamesGeneratorTest.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
NamesGeneratorTest.php
View Options
<?php
namespace
Eris\Generator
;
use
Eris\Random\RandomRange
;
use
Eris\Random\RandSource
;
class
NamesGeneratorTest
extends
\PHPUnit\Framework\TestCase
{
/**
* @var RandomRange
*/
private
$rand
;
public
function
setUp
():
void
{
$this
->
rand
=
new
RandomRange
(
new
RandSource
());
}
public
function
testItRespectsTheGenerationSize
():
void
{
$generator
=
NamesGenerator
::
defaultDataSet
();
for
(
$i
=
5
;
$i
<
50
;
$i
++)
{
$value
=
$generator
(
$maxLength
=
$i
,
$this
->
rand
)->
unbox
();
$this
->
assertTrue
(
$maxLength
>=
strlen
(
$value
),
"Names generator is not respecting the generation size. Asked a name with max size {$maxLength} and returned {$value}"
);
}
}
public
function
testGeneratesANameFromAFixedDataset
():
void
{
$generator
=
NamesGenerator
::
defaultDataSet
();
for
(
$i
=
0
;
$i
<
50
;
$i
++)
{
$value
=
$generator
(
$_size
=
10
,
$this
->
rand
);
\Eris\PHPUnitDeprecationHelper
::
assertIsString
(
$value
->
unbox
());
}
}
public
static
function
namesToShrink
():
array
{
return
[
[
"Malene"
,
"Maxence"
],
[
"Columban"
,
"Columbano"
],
[
"Carol-Anne"
,
"Carole-Anne"
],
[
"Annie"
,
"Zinnia"
],
[
"Aletta"
,
"Lucetta"
],
[
"Tekla"
,
"Thekla"
],
[
"Ursin"
,
"Ursine"
],
[
"Gwennan"
,
"Gwenegan"
],
[
"Eliane"
,
"Eliabel"
],
[
"Ed"
,
"Ed"
],
[
"Di"
,
"Di"
],
];
}
/**
* @dataProvider namesToShrink
*/
public
function
testShrinksToTheNameWithTheImmediatelyLowerLengthWhichHasTheMinimumDistance
(
$shrunk
,
$original
):
void
{
$generator
=
NamesGenerator
::
defaultDataSet
();
$this
->
assertEquals
(
$shrunk
,
$generator
->
shrink
(
GeneratedValueSingle
::
fromJustValue
(
$original
))
->
unbox
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Oct 4 2026, 20:27 (5 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4f/ad/3f00b8d114a2a352cd8b44c78652
Default Alt Text
NamesGeneratorTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment