From 6f2b603c6fc985541b513f093c8c9ac723dd06fb Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Sat, 11 May 2024 18:27:15 +0700 Subject: [PATCH] test: Test atLeast atMost not useful outside matchAll --- .../consumer/tests/Service/MatchersTest.php | 4 +++ .../matchersConsumer-matchersProvider.json | 25 +++++++++++++++++++ example/matchers/provider/public/index.php | 9 +++++++ 3 files changed, 38 insertions(+) diff --git a/example/matchers/consumer/tests/Service/MatchersTest.php b/example/matchers/consumer/tests/Service/MatchersTest.php index 9cbec9bf..923d781c 100644 --- a/example/matchers/consumer/tests/Service/MatchersTest.php +++ b/example/matchers/consumer/tests/Service/MatchersTest.php @@ -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' => [ @@ -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' => [ diff --git a/example/matchers/pacts/matchersConsumer-matchersProvider.json b/example/matchers/pacts/matchersConsumer-matchersProvider.json index d3a17bce..879465cd 100644 --- a/example/matchers/pacts/matchersConsumer-matchersProvider.json +++ b/example/matchers/pacts/matchersConsumer-matchersProvider.json @@ -135,6 +135,10 @@ 111, "2fbd41cc-4bbc-44ea-a419-67f767691407" ], + "atLeast": [ + null, + null + ], "atLeastLike": [ 1, 1, @@ -142,6 +146,9 @@ 1, 1 ], + "atMost": [ + null + ], "atMostLike": [ 1 ], @@ -278,6 +285,15 @@ } ] }, + "$.atLeast": { + "combine": "AND", + "matchers": [ + { + "match": "type", + "min": 2 + } + ] + }, "$.atLeastLike": { "combine": "AND", "matchers": [ @@ -287,6 +303,15 @@ } ] }, + "$.atMost": { + "combine": "AND", + "matchers": [ + { + "match": "type", + "max": 4 + } + ] + }, "$.atMostLike": { "combine": "AND", "matchers": [ diff --git a/example/matchers/provider/public/index.php b/example/matchers/provider/public/index.php index 66a7ff0f..9debe29e 100644 --- a/example/matchers/provider/public/index.php +++ b/example/matchers/provider/public/index.php @@ -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(), ]));