Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7438236
StringTest.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
StringTest.php
View Options
<?php
use
Eris\Generators
;
use
Eris\Listeners
;
function
string_concatenation
(
$first
,
$second
)
{
if
(
strlen
(
$second
)
>
5
)
{
$second
.=
'ERROR'
;
}
return
$first
.
$second
;
}
class
StringTest
extends
\PHPUnit\Framework\TestCase
{
use
Eris\TestTrait
;
public
function
testRightIdentityElement
()
{
$this
->
forAll
(
Generators
::
string
()
)
->
then
(
function
(
$string
)
{
$this
->
assertEquals
(
$string
,
string_concatenation
(
$string
,
''
),
"Concatenating '$string' to ''"
);
});
}
public
function
testLengthPreservation
()
{
$this
->
forAll
(
Generators
::
string
(),
Generators
::
string
()
)
->
hook
(
Listeners
::
log
(
sys_get_temp_dir
().
'/eris-string-shrinking.log'
))
->
then
(
function
(
$first
,
$second
)
{
$result
=
string_concatenation
(
$first
,
$second
);
$this
->
assertEquals
(
strlen
(
$first
)
+
strlen
(
$second
),
strlen
(
$result
),
"Concatenating '$first' to '$second' gives '$result'"
.
PHP_EOL
.
var_export
(
$first
,
true
)
.
PHP_EOL
.
"strlen(): "
.
strlen
(
$first
)
.
PHP_EOL
.
var_export
(
$second
,
true
)
.
PHP_EOL
.
"strlen(): "
.
strlen
(
$second
)
.
PHP_EOL
.
var_export
(
$result
,
true
)
.
PHP_EOL
.
"strlen(): "
.
strlen
(
$result
)
.
PHP_EOL
.
"First hex: "
.
var_export
(
bin2hex
(
$first
),
true
)
.
PHP_EOL
.
"Second hex: "
.
var_export
(
bin2hex
(
$second
),
true
)
.
PHP_EOL
.
"Result hex: "
.
var_export
(
bin2hex
(
$result
),
true
)
.
PHP_EOL
);
});
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 14:25 (8 h, 43 s ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c5/d2/153f19903f0d9f42e57a5aa3798b
Default Alt Text
StringTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment