Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12944235
NoneTest.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
NoneTest.php
View Options
<?php
namespace
Keruald\OmniTools\Tests\DataTypes\Option
;
use
InvalidArgumentException
;
use
Keruald\OmniTools\DataTypes\Option\None
;
use
Keruald\OmniTools\DataTypes\Option\Option
;
use
Keruald\OmniTools\DataTypes\Option\Some
;
use
PHPUnit\Framework\TestCase
;
class
NoneTest
extends
TestCase
{
private
Option
$v
;
public
function
setUp
()
:
void
{
$this
->
v
=
new
None
;
}
public
function
testIsSome
()
:
void
{
$this
->
assertFalse
(
$this
->
v
->
isSome
());
}
public
function
testIsNone
()
:
void
{
$this
->
assertTrue
(
$this
->
v
->
isNone
());
}
public
function
testGetValue
()
:
void
{
$this
->
expectException
(
InvalidArgumentException
::
class
);
$this
->
v
->
getValue
();
}
public
function
testMap
()
:
void
{
$callback
=
function
(
$n
)
{
return
$n
*
2
;
};
$mapped_v
=
$this
->
v
->
map
(
$callback
);
$this
->
assertEquals
(
$mapped_v
,
$this
->
v
);
}
public
function
testOr
()
:
void
{
$actual
=
$this
->
v
->
or
(
new
Some
(
666
));
$this
->
assertTrue
(
$actual
->
isSome
());
$this
->
assertEquals
(
666
,
$actual
->
getValue
());
}
public
function
testOrElse
()
:
void
{
$actual
=
$this
->
v
->
orElse
(
fn
()
=>
new
Some
(
666
));
$this
->
assertTrue
(
$actual
->
isSome
());
$this
->
assertEquals
(
666
,
$actual
->
getValue
());
}
public
function
testGetValueOr
()
:
void
{
$value
=
$this
->
v
->
getValueOr
(
666
);
$this
->
assertEquals
(
666
,
$value
);
}
public
function
testGetValueOrElse
()
:
void
{
$value
=
$this
->
v
->
getValueOrElse
(
fn
()
=>
666
);
$this
->
assertEquals
(
666
,
$value
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Nov 18, 17:09 (19 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3174123
Default Alt Text
NoneTest.php (1 KB)
Attached To
Mode
rKOT Keruald OmniTools
Attached
Detach File
Event Timeline
Log In to Comment