021: End to End & Integration Testing Using Test Driven Development (TDD) to create a REST API (PHP)

Опубликовано: 12 Октябрь 2024
на канале: Testing All The Things
1,454
13

In this episode we continue to use Test Driven Development (TDD) to drive out the implementation the simple HTTP REST(ish) API microservice in PHP.

We add a new endpoint GET to retrieve a book by its ISBN.

Starting with an End to End Test write using PHP Unit and Guzzle HTTP Client for PHP to design out how consumers of the API will interact with the endpoint.
We then add an Integration test to ensure our code uses Doctrine PHP ORM to interact with the Postgres database to get the book data.

Finally we add a Unit Test to the Book object to enable it to render itself into JSON using PHP's JsonSerializable interface.

Don't miss the excellent demonstration why we need to use different types of test at 33.15 (   • 021: End to End & Integration Testing...  ) the moment all the Unit Tests pass and the End to End Tests still fails

The code produced during this episode can be found on GitHub:
https://github.com/testingallthething...

You can follow me on twitter:   / braddle  

** Please Rate, Review, Subscribe and Share these videos **

During this video we use:
PHP Slim Framework: http://www.slimframework.com/
PHPUnit: https://phpunit.de/
Guzzle: http://docs.guzzlephp.org/en/stable/
Doctrine ORM: https://www.doctrine-project.org/
PHP DI: http://php-di.org/