Skip to content

Instantly share code, notes, and snippets.

@danilobatistaqueiroz
Last active January 3, 2018 15:32
Show Gist options
  • Save danilobatistaqueiroz/f8a8b5e865f64d6ab97b0cc6e8f6e50c to your computer and use it in GitHub Desktop.
Save danilobatistaqueiroz/f8a8b5e865f64d6ab97b0cc6e8f6e50c to your computer and use it in GitHub Desktop.
TDD with PHP

TDD WITH PHP

Start with an error test

Try to start simple, making test about methods without implementation

Increase the implementation step by step (baby steps)

Always make an error test to avoid false positives

Start using constants, returning static content, and after, improve to Lists and dynamic content.

In the beginning the methods need to be the simplest possible.
One logic, and using baby steps, the logic is improved more logics.

Its possible to use a dox type test with phpunit
phptdd1

Or the common type
phptdd2

Improve with baby steps

Use mocks with caution, they increase the couple between classes

Do persistence tests with some real resource, I used sqlLite3 as database test

All tests ok

phptdd3

phptdd4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment