Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F6063368
UtilsTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 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
Fri, May 22, 4:05 AM (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
749270
Default Alt Text
UtilsTest.php (2 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment