function it_should_return_new_instance_of_pact_builder_for_every_change(Interaction $interaction) { $consumerPactBuilder = $this->given("provider has cat"); $consumerPactBuilder->shouldNotBe($this); $consumerPactBuilder2 = $consumerPactBuilder->uponReceiving("a request for cat"); $consumerPactBuilder2->shouldNotBe($consumerPactBuilder); $consumerPactBuilder3 = $consumerPactBuilder2->with(["method" => "get", "path" => "/alligators/Mary"]); $consumerPactBuilder3->shouldNotBe($consumerPactBuilder2); $consumerPactBuilder4 = $consumerPactBuilder3->willRespondWith(["status" => 200]); $consumerPactBuilder4->shouldNotBe($consumerPactBuilder3); $this->interactionFactory->create("provider has cat", "a request for cat", ["method" => "get", "path" => "/alligators/Mary"], ["status" => 200])->willReturn($interaction); $interaction = $consumerPactBuilder4->interactionFromBuild(); $interaction->shouldHaveType(Interaction::class); }
/** * Provides interaction based on passed configuration * * @return \Madkom\PactClient\Domain\Interaction\Interaction * @throws PactException */ public function interactionFromBuild() { if (!isset($this->providerState)) { throw new PactException("Before setting up, you need to set provider state"); } if (!isset($this->requestInformation)) { throw new PactException("Before setting up, you need to set request information"); } if (!isset($this->requestData)) { throw new PactException("Before setting up, you need to set request data"); } if (!isset($this->responseData)) { throw new PactException("Before setting up, you need to set response data"); } return $this->interactionFactory->create($this->providerState, $this->requestInformation, $this->requestData, $this->responseData); }