Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12587281
TraversableUtilitiesTest.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
TraversableUtilitiesTest.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\Tests\Collections
;
use
Keruald\OmniTools\Collections\TraversableUtilities
;
use
PHPUnit\Framework\TestCase
;
use
Countable
;
class
TraversableUtilitiesTest
extends
TestCase
{
/**
* @dataProvider provideCountables
*/
public
function
testCount
(
$expectedCount
,
$countable
)
{
$this
->
assertEquals
(
$expectedCount
,
TraversableUtilities
::
count
(
$countable
)
);
}
/**
* @dataProvider provideNotCountables
*/
public
function
testCountWithNotCountables
(
$notCountable
)
{
$this
->
expectException
(
"TypeError"
);
TraversableUtilities
::
count
(
$notCountable
);
}
///
/// Data providers
///
public
function
provideCountables
()
:
iterable
{
yield
[
0
,
null
];
yield
[
0
,
false
];
yield
[
0
,
[]];
yield
[
3
,
[
"a"
,
"b"
,
"c"
]];
yield
[
42
,
new
class
implements
Countable
{
public
function
count
()
:
int
{
return
42
;
}
}
];
}
public
function
provideNotCountables
()
:
iterable
{
yield
[
true
];
yield
[
new
\stdClass
];
yield
[
0
];
yield
[
""
];
yield
[
"abc"
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Nov 13, 15:34 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3139287
Default Alt Text
TraversableUtilitiesTest.php (1 KB)
Attached To
Mode
rKOT Keruald OmniTools
Attached
Detach File
Event Timeline
Log In to Comment