Skip to content

Make GuzzleRestClient Mockable / Testable #31

Description

@drzraf

https://github.com/eventfarm/restforcephp/blob/master/src/Rest/GuzzleRestClient.php#L34
uses the following construct:

    public function setBaseUriForRestClient(string $baseUri): void {
        $this->client = new \GuzzleHttp\Client($config);   // $this->client is private
    }

This makes impossible to test an app relying upon restforcephp because we can hardly¹ mock the responses.

  1. You shouldn't use absolute class namespace.
  2. The GuzzleHttp\Client is a dependency that should be passed as an argument
  3. With $this->client being private, we can't overload it.

Could you please improve the situation so that SF depending upon restforce can be tested?

¹ It's actually possible, but using a tons of boilerplate code and workarounds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions