Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F13142817
SomeTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
SomeTest.php
View Options
<?php
namespace
Keruald\OmniTools\Tests\DataTypes\Option
;
use
InvalidArgumentException
;
use
Keruald\OmniTools\DataTypes\Option\Some
;
use
Keruald\OmniTools\DataTypes\Option\Option
;
use
PHPUnit\Framework\TestCase
;
class
SomeTest
extends
TestCase
{
private
Option
$v
;
public
function
setUp
()
:
void
{
$this
->
v
=
new
Some
;
$this
->
v
->
setValue
(
42
);
}
public
function
testIsSome
()
:
void
{
$this
->
assertTrue
(
$this
->
v
->
isSome
());
}
public
function
testIsNone
()
:
void
{
$this
->
assertFalse
(
$this
->
v
->
isNone
());
}
public
function
testGetValue
()
:
void
{
$this
->
assertEquals
(
42
,
$this
->
v
->
getValue
());
}
public
function
testSetValue
()
:
void
{
$this
->
v
->
setValue
(
666
);
$this
->
assertEquals
(
666
,
$this
->
v
->
getValue
());
}
public
function
testSetValueWhenTypeIsMutated
()
:
void
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
$this
->
v
->
setValue
(
"Another type"
);
}
public
function
testMap
()
:
void
{
$callback
=
function
(
$n
)
{
return
$n
*
2
;
};
$mapped_v
=
$this
->
v
->
map
(
$callback
);
$this
->
assertEquals
(
84
,
$mapped_v
->
getValue
());
}
public
function
testOrElse
()
:
void
{
$value
=
$this
->
v
->
orElse
(
666
);
$this
->
assertEquals
(
42
,
$value
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 16:20 (22 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3159564
Default Alt Text
SomeTest.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment