Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix fatal error when reponse's status is not set #348

Merged
merged 1 commit into from Oct 27, 2023

Conversation

tienvx
Copy link
Contributor

@tienvx tienvx commented Oct 23, 2023

Fix Fatal error: Typed property PhpPact\Consumer\Model\ProviderResponse::$status must not be accessed before initialization (Behat\Testwork\Call\Exception\FatalThrowableError)

  • This is mainly for compatibility suite
  • For end-user, this change will save them a line of code:
        $request = new ConsumerRequest();
        $request
            ->setMethod('GET')
            ->setPath('/goodbye/Bob')
            ->addHeader('Content-Type', 'application/json');

        $response = new ProviderResponse(); // still need to define an object like this, but it's future improvement, not right now
        // $response->setStatus(200); // no need to do this

        $config = new MockServerConfig();
        $config
            ->setConsumer('jsonConsumer')
            ->setProvider('jsonProvider')
            ->setPactDir(__DIR__.'/../../../pacts');
        $builder = new InteractionBuilder($config);
        $builder
            ->given('Get Goodbye')
            ->uponReceiving('A get request to /goodbye/{name}')
            ->with($request)
            ->willRespondWith($response); // need to call this, but it's future improvement, not right now

@YOU54F YOU54F merged commit b68558d into pact-foundation:ffi Oct 27, 2023
26 checks passed
@tienvx tienvx deleted the default-response-status branch October 27, 2023 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants