FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
iter/tests/unit/SearchWithKeysTest.php at next · php-standard-library/iter · GitHub
php-standard-library
/
iter
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Actions
Security and quality
0
Insights
Additional navigation options
Code
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
iter
/
tests
/
unit
/
SearchWithKeysTest.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (34 loc) · 1.32 KB
Breadcrumbs
iter
/
tests
/
unit
/
SearchWithKeysTest.php
Copy path
File metadata and controls
42 lines (34 loc) · 1.32 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare
(strict_types=
1
);
namespace
Psl
\
Iter
\
Tests
\
Unit
;
use
PHPUnit
\
Framework
\
Attributes
\
DataProvider
;
use
PHPUnit
\
Framework
\
TestCase
;
use
Psl
\
Iter
;
final
class
SearchWithKeysTest
extends
TestCase
{
#[DataProvider(
'
provideDataSome
'
)]
public
function
testSearchSome
(
string
$
expected
,
iterable
$
iterable
,
callable
$
predicate
):
void
{
static
::
assertSame
(
$
expected
,
Iter
\search_with_keys
(
$
iterable
,
$
predicate
));
}
public
static
function
provideDataSome
():
iterable
{
yield
[
'
baz
'
, [
'
foo
'
,
'
bar
'
,
'
baz
'
],
static
fn
(
int
$
k
,
string
$
v
):
bool
=>
2
===
$
k
&&
'
baz
'
===
$
v
];
yield
[
'
baz
'
,
Iter
\to_iterator
([
'
foo
'
,
'
bar
'
,
'
baz
'
]),
static
fn
(
int
$
k
,
string
$
v
):
bool
=>
2
===
$
k
&&
'
baz
'
===
$
v
,
];
}
#[DataProvider(
'
provideDataNone
'
)]
public
function
testSearchNone
(
iterable
$
iterable
,
callable
$
predicate
):
void
{
static
::
assertNull
(
Iter
\search_with_keys
(
$
iterable
,
$
predicate
));
}
public
static
function
provideDataNone
():
iterable
{
yield
[[],
static
fn
(
int
$
_
,
string
$
v
):
bool
=>
'
qux
'
===
$
v
];
yield
[
Iter
\to_iterator
([]),
static
fn
(
int
$
_
,
string
$
v
):
bool
=>
'
qux
'
===
$
v
];
yield
[
Iter
\to_iterator
([
'
foo
'
,
'
bar
'
,
'
baz
'
]),
static
fn
(
int
$
_
,
string
$
v
):
bool
=>
'
qux
'
===
$
v
];
}
}
Back
|
FazBrowse Home
|
New Git URL