Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Lakion Blog:
TDD your API with Symfony and PHPUnit
Dec 31, 2015 @ 09:16:52

On the Lakion blog there's a post showing you how to use a simple test class/tool they've created to unit test your APIs with PHPUnit.

At Lakion we truly believe in TDD approach. We are convinced that rapid development can not be achieved without proper testing and SOLID code. We always start with defining our needs and writing scenarios, specifications or tests that reflect them. Thanks to this approach, we get exactly what we need and tests are protecting us from regressions. [...] We have come up with a very simple but useful PHPUnit test case for testing APIs. - ApiTestCase.

They start with a bit about the ApiTestCase library and some background on why they created it and some of the features it provides (and other libraries it includes). They then show an example of a simple project using the testing tool to make a request to an endpoint (POST) and check the response matches what's expected. According to the TDD approach, the test fails first then they go back and create the functionality behind to to make it all work.

tagged: tdd phpunit api testing unittest integration apitestcase library tool

Link: http://lakion.com/blog/tdd-your-api-with-symfony-and-phpunit