From 10a4b6a9b5e9698654718991561e1d6b21573f94 Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Sun, 12 May 2024 13:44:09 +0700 Subject: [PATCH] test: Test map matching for protobuf --- .../PersonMessageHandlerTest.php | 20 +++++++++++++++++++ .../library/proto/say_hello.proto | 1 + 2 files changed, 21 insertions(+) diff --git a/example/protobuf-async-message/consumer/tests/MessageHandler/PersonMessageHandlerTest.php b/example/protobuf-async-message/consumer/tests/MessageHandler/PersonMessageHandlerTest.php index 3b4c683e..c528d47f 100644 --- a/example/protobuf-async-message/consumer/tests/MessageHandler/PersonMessageHandlerTest.php +++ b/example/protobuf-async-message/consumer/tests/MessageHandler/PersonMessageHandlerTest.php @@ -58,6 +58,26 @@ public function testInvoke(): void 'given' => $this->matcher->like($this->given), 'surname' => $this->matcher->like($this->surname), ], + 'children' => $this->matcher->matchAll( + ['Zane' => 12], + [ + $this->matcher->eachKey( + [], + [$this->matcher->string()] + ), + $this->matcher->eachValue( + [], + [ + $this->matcher->number(23), + ], + ), + $this->matcher->atLeast(0), + $this->matcher->atMost(3), + // These matchers are allowed, but are not recommend + // $this->matcher->atLeastLike(123, 2), + // $this->matcher->atMostLike(234, 3), + ], + ), ]), 'application/protobuf' )); diff --git a/example/protobuf-async-message/library/proto/say_hello.proto b/example/protobuf-async-message/library/proto/say_hello.proto index 7db28ef6..b64c26ac 100644 --- a/example/protobuf-async-message/library/proto/say_hello.proto +++ b/example/protobuf-async-message/library/proto/say_hello.proto @@ -5,6 +5,7 @@ package library; message Person { string id = 1; Name name = 2; + map children = 3; } message Name {