Add Architecture Tests to Saloon API Integrations with Lawman
Last updated on by Paul Redmond
Lawman is a Pest PHP plugin that makes adding arch tests to your application for your API integrations easy, with a set of Saloon Expectations!
This weekend I worked on something new and shiny for SaloonPHP. I'd like to introduce you to Lawman.
— Jon Purvis (@JonPurvis_) February 14, 2024
Lawman is a @pestphp plugin that makes adding arch tests to your application for your API integrations easy, with a set of Saloon Expectations!https://t.co/WUIGnHriNo
✨🤠
It is already possible to write architecture tests for Saloon with PestPHP, but Lawman aims to make it quicker to write and easier to read. Take this example of a connector arch test with and without Lawman:
// Without Lawmantest('connector') ->expect('App\Http\Integrations\Integration\Connector') ->toExtend('Saloon\Http\Connector') ->toUse('Saloon\Traits\Plugins\AcceptsJson') ->toUse('Saloon\Traits\Plugins\AlwaysThrowOnErrors'); // With Lawmantest('connector') ->expect('App\Http\Integrations\Integration\Connector') ->toBeSaloonConnector() ->toUseAcceptsJsonTrait() ->toUseAlwaysThrowOnErrorsTrait();
You can see examples and a complete list of expectations available in Lawman by checking out the plugin documentation page in the Saloon docs.