Skip to content

Commit

Permalink
test: Test atLeast atMost not useful outside matchAll
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed May 11, 2024
1 parent b806bc9 commit 6f2b603
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions example/matchers/consumer/tests/Service/MatchersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public function testGetMatchers(): void
$this->matcher->atMost(3),
],
),
'atLeast' => $this->matcher->atLeast(2), // Not useful when outside of `matchAll`
'atMost' => $this->matcher->atMost(4), // Not useful when outside of `matchAll`

// Don't mind this. This is for demonstrating what query values provider will received.
'query' => [
Expand Down Expand Up @@ -218,6 +220,8 @@ public function testGetMatchers(): void
],
'url' => 'http://localhost:8080/users/1234/posts/latest',
'matchAll' => ['desktop' => '2000 usd'],
'atLeast' => [null, null],
'atMost' => [null],

// Don't mind this. This is for demonstrating what query values provider will received.
'query' => [
Expand Down
25 changes: 25 additions & 0 deletions example/matchers/pacts/matchersConsumer-matchersProvider.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,20 @@
111,
"2fbd41cc-4bbc-44ea-a419-67f767691407"
],
"atLeast": [
null,
null
],
"atLeastLike": [
1,
1,
1,
1,
1
],
"atMost": [
null
],
"atMostLike": [
1
],
Expand Down Expand Up @@ -278,6 +285,15 @@
}
]
},
"$.atLeast": {
"combine": "AND",
"matchers": [
{
"match": "type",
"min": 2
}
]
},
"$.atLeastLike": {
"combine": "AND",
"matchers": [
Expand All @@ -287,6 +303,15 @@
}
]
},
"$.atMost": {
"combine": "AND",
"matchers": [
{
"match": "type",
"max": 4
}
]
},
"$.atMostLike": {
"combine": "AND",
"matchers": [
Expand Down
9 changes: 9 additions & 0 deletions example/matchers/provider/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
'tablet' => '300 usd',
'laptop' => '1200 usd',
],
'atLeast' => [
null,
null,
],
'atMost' => [
null,
],

// Don't mind this. This is for demonstrating what query values provider will received.
'query' => $request->getQueryParams(),
]));

Expand Down

0 comments on commit 6f2b603

Please sign in to comment.