trycourier / courier-php

A PHP package for communicating with the Courier REST API.
https://packagist.org/packages/trycourier/courier
MIT License
11 stars 4 forks source link

Expose CourierClientInterface implemented by CourierClient for easier consumer testing #21

Closed tk26 closed 3 years ago

tk26 commented 3 years ago

Description of the change

Expose CourierClientInterface, which is implemented by CourierClient.

Type of change

Related issues

Fix [#1]()

Checklists

Development

Code review

linear[bot] commented 3 years ago
C-3668 Benevity: PHP SDK suggestion for better interfacing

From Benevity's `@mevans` - "Here's a suggestion for the PHP SDK. `CourierClient` is a final class, which makes it hard to mock using our mocking tools (Mockery). To get around this, I have defined `CourierClientInterface` and a `CourierClientWrapper` that implements the interface. `CourierClientInterface` defines the same `sendNotification` method as `CourierClient`. The wrapper's constructor accepts an instance of `CourierClient` and delegates its implemented `sendNotification` method calls to it. Then I can mock `CourierClientInterface` and create the needed test double without PHP raising errors at me. If instead the SDK provided an interface and the final class implemented it, then SDK consumers could use and mock that interface without the need for the wrapper.Food for thought. I'm not blocked."