From d76230f91b35d1d0a8b6e5d3f416979e27a0f710 Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Mon, 9 Oct 2023 16:03:33 +0700 Subject: [PATCH] chore: Allow register multiple interactions --- .../Consumer/Driver/Interaction/InteractionDriver.php | 6 ++++-- .../Driver/Interaction/InteractionDriverInterface.php | 2 +- src/PhpPact/Consumer/InteractionBuilder.php | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PhpPact/Consumer/Driver/Interaction/InteractionDriver.php b/src/PhpPact/Consumer/Driver/Interaction/InteractionDriver.php index d9fbde151..8fb2ce7d6 100644 --- a/src/PhpPact/Consumer/Driver/Interaction/InteractionDriver.php +++ b/src/PhpPact/Consumer/Driver/Interaction/InteractionDriver.php @@ -21,10 +21,12 @@ public function verifyInteractions(): bool return $this->mockServer->verify(); } - public function registerInteraction(Interaction $interaction): bool + public function registerInteractions(Interaction ...$interactions): bool { $this->pactDriver->setUp(); - $this->interactionRegistry->registerInteraction($interaction); + foreach ($interactions as $interaction) { + $this->interactionRegistry->registerInteraction($interaction); + } $this->mockServer->start(); return true; diff --git a/src/PhpPact/Consumer/Driver/Interaction/InteractionDriverInterface.php b/src/PhpPact/Consumer/Driver/Interaction/InteractionDriverInterface.php index fe5a3e076..fcb9a5189 100644 --- a/src/PhpPact/Consumer/Driver/Interaction/InteractionDriverInterface.php +++ b/src/PhpPact/Consumer/Driver/Interaction/InteractionDriverInterface.php @@ -6,7 +6,7 @@ interface InteractionDriverInterface { - public function registerInteraction(Interaction $interaction): bool; + public function registerInteractions(Interaction ...$interactions): bool; public function verifyInteractions(): bool; } diff --git a/src/PhpPact/Consumer/InteractionBuilder.php b/src/PhpPact/Consumer/InteractionBuilder.php index 000a08aeb..073e6d77e 100644 --- a/src/PhpPact/Consumer/InteractionBuilder.php +++ b/src/PhpPact/Consumer/InteractionBuilder.php @@ -64,8 +64,9 @@ public function with(ConsumerRequest $request): self public function willRespondWith(ProviderResponse $response): bool { $this->interaction->setResponse($response); + $this->driver->registerInteractions($this->interaction); - return $this->driver->registerInteraction($this->interaction); + return true; } /**