Closed nate-williams-auctane closed 3 years ago
@KaseyCantu Thanks for pointing out the pre-commit config and pre-commit install
and act
tools. Once I ran those locally, the whitespace/braces were formatted and I eventually got the risky test error to appear and corrected that. Note that I switch the covers
annotations to uses
for some classes, let me know if that is not best practice here.
Background
This pull request adds a test for ensuring the
RequestSentEvent
is fired when a request is sent by the ShipEngine client. It should be similar to thejs
SDK tests, at: https://github.com/ShipEngine/shipengine-js/blob/6363c722569436a69c4ffa7fe5f1c51e17c12e8d/test/specs/events.spec.js#L9-L37.There were a number of complications with testing the event using PHPUnit, I am open to documenting more of these in the code itself, subject to what is appropriate for the SDKs. Of note:
final
classes in PHPUnit cannot be directly tested, but here this is addressed by using the Mockery library, which also allows us to create aspy
.on
vswith
vswithArgs
at http://docs.mockery.io/en/latest/reference/argument_validation.html#complex-argument-validation$event_result
, for thisspy
and this is based on similar code for Mockery mocks, which use the same approach for itscapture
method. Seevendor/mockery/mockery/library/Mockery.php
line 434.Testing
./vendor/bin/phpunit --process-isolation --filter RequestSentEventTest
tests/Message/Events/RequestSentEventTest.php
, like$this->assertEquals($event_result->retry, 1);
.composer phpunit
.