From e6dd3de5092f2e3d18be352c0797562d011c6fce Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Fri, 15 Dec 2023 10:38:27 +0700 Subject: [PATCH] refactor: Add Includes matcher class --- .../Consumer/Matcher/Matchers/Includes.php | 31 +++++++++++++++++++ .../Matcher/Matchers/IncludesTest.php | 18 +++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/PhpPact/Consumer/Matcher/Matchers/Includes.php create mode 100644 tests/PhpPact/Consumer/Matcher/Matchers/IncludesTest.php diff --git a/src/PhpPact/Consumer/Matcher/Matchers/Includes.php b/src/PhpPact/Consumer/Matcher/Matchers/Includes.php new file mode 100644 index 00000000..7435d919 --- /dev/null +++ b/src/PhpPact/Consumer/Matcher/Matchers/Includes.php @@ -0,0 +1,31 @@ + + */ + public function jsonSerialize(): array + { + return [ + 'pact:matcher:type' => $this->getType(), + 'value' => $this->value, + ]; + } + + public function getType(): string + { + return 'include'; + } +} diff --git a/tests/PhpPact/Consumer/Matcher/Matchers/IncludesTest.php b/tests/PhpPact/Consumer/Matcher/Matchers/IncludesTest.php new file mode 100644 index 00000000..6310f3fe --- /dev/null +++ b/tests/PhpPact/Consumer/Matcher/Matchers/IncludesTest.php @@ -0,0 +1,18 @@ +assertSame( + '{"pact:matcher:type":"include","value":"contains this string"}', + json_encode($string) + ); + } +}