Skip to content

Commit

Permalink
chore: Add array contains matcher example
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Oct 30, 2024
1 parent dd1164d commit f779deb
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public function createUser(): string
'question-mark' => '?',
'equals-sign' => '=',
]) .
'&roles[]=User&roles[]=Manager',
'&roles[]=User&roles[]=Manager' .
'&orders[]=&orders[]=ASC&orders[]=DESC',
'headers' => [
'Accept' => 'application/x-www-form-urlencoded',
'Content-Type' => 'application/x-www-form-urlencoded',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public function testGetMovies()
'password' => $matcher->regex('user@password111', '^[\w\d@$!%*#?&^_-]{8,}$'),
'age' => $matcher->number(27),
'roles[]' => $matcher->eachValue(['User'], [$matcher->regex('User', 'Admin|User|Manager')]),
'orders[]' => $matcher->arrayContaining([
$matcher->equal('DESC'),
$matcher->equal('ASC'),
$matcher->equal(''),
]),
// Null, boolean and object values are not supported, so the values and matchers will be ignored
'null' => $matcher->nullValue(),
'boolean' => $matcher->booleanV3(true),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}
],
"request": {
"body": "age=27&agree=false&ampersand=%26&email=user%40email.test&empty=&equals-sign=%3D&fullname=User+name&password=user%40password111&question-mark=%3F&roles%5B%5D=User&slash=%2F",
"body": "age=27&agree=false&ampersand=%26&email=user%40email.test&empty=&equals-sign=%3D&fullname=User+name&orders%5B%5D=DESC&orders%5B%5D=ASC&orders%5B%5D=&password=user%40password111&question-mark=%3F&roles%5B%5D=User&slash=%2F",
"headers": {
"Accept": "application/x-www-form-urlencoded",
"Content-Type": "application/x-www-form-urlencoded"
Expand Down Expand Up @@ -85,6 +85,55 @@
}
]
},
"$['orders[]']": {
"combine": "AND",
"matchers": [
{
"match": "arrayContains",
"variants": [
{
"index": 0,
"rules": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "equality"
}
]
}
}
},
{
"index": 1,
"rules": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "equality"
}
]
}
}
},
{
"index": 2,
"rules": {
"$": {
"combine": "AND",
"matchers": [
{
"match": "equality"
}
]
}
}
}
]
}
]
},
"$['roles[]']": {
"combine": "AND",
"matchers": [
Expand Down

0 comments on commit f779deb

Please sign in to comment.