Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117881578
UtilsTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
UtilsTest.php
View Options
<?php
namespace
Tests\Unit
;
use
App\Utils
;
use
Tests\TestCase
;
class
UtilsTest
extends
TestCase
{
/**
* Test for Utils::powerSet()
*
* @return void
*/
public
function
testPowerSet
()
{
$set
=
[];
$result
=
\App\Utils
::
powerSet
(
$set
);
$this
->
assertIsArray
(
$result
);
$this
->
assertCount
(
0
,
$result
);
$set
=
[
"a1"
];
$result
=
\App\Utils
::
powerSet
(
$set
);
$this
->
assertIsArray
(
$result
);
$this
->
assertCount
(
1
,
$result
);
$this
->
assertTrue
(
in_array
([
"a1"
],
$result
));
$set
=
[
"a1"
,
"a2"
];
$result
=
\App\Utils
::
powerSet
(
$set
);
$this
->
assertIsArray
(
$result
);
$this
->
assertCount
(
3
,
$result
);
$this
->
assertTrue
(
in_array
([
"a1"
],
$result
));
$this
->
assertTrue
(
in_array
([
"a2"
],
$result
));
$this
->
assertTrue
(
in_array
([
"a1"
,
"a2"
],
$result
));
$set
=
[
"a1"
,
"a2"
,
"a3"
];
$result
=
\App\Utils
::
powerSet
(
$set
);
$this
->
assertIsArray
(
$result
);
$this
->
assertCount
(
7
,
$result
);
$this
->
assertTrue
(
in_array
([
"a1"
],
$result
));
$this
->
assertTrue
(
in_array
([
"a2"
],
$result
));
$this
->
assertTrue
(
in_array
([
"a3"
],
$result
));
$this
->
assertTrue
(
in_array
([
"a1"
,
"a2"
],
$result
));
$this
->
assertTrue
(
in_array
([
"a1"
,
"a3"
],
$result
));
$this
->
assertTrue
(
in_array
([
"a2"
,
"a3"
],
$result
));
$this
->
assertTrue
(
in_array
([
"a1"
,
"a2"
,
"a3"
],
$result
));
}
/**
* Test for Utils::uuidInt()
*
* @return void
*/
public
function
testUuidInt
()
{
$result
=
Utils
::
uuidInt
();
$this
->
assertTrue
(
is_int
(
$result
));
$this
->
assertTrue
(
$result
>
0
);
}
/**
* Test for Utils::uuidStr()
*
* @return void
*/
public
function
testUuidStr
()
{
$result
=
Utils
::
uuidStr
();
$this
->
assertTrue
(
is_string
(
$result
));
$this
->
assertTrue
(
strlen
(
$result
)
===
36
);
$this
->
assertTrue
(
preg_match
(
'/[^a-f0-9-]/i'
,
$result
)
===
0
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Apr 5, 11:58 PM (1 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
72/17/4d7c50b22de88db52bd61ed64d86
Default Alt Text
UtilsTest.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline