-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Test-Driven Development with PHP 8
By :

The Red-Green-Refactor pattern is a type of programming approach to implementing TDD. It’s a cycle where you first deliberately write a failing test, in which you see a red-colored failing message when you execute the test. Then, you write solution code to pass that test, in which you will see a green-colored passing message. After passing the test, you can then go back to clean up and refactor your test and solution code.
If you open the codebase/symfony/runDebug.sh
file that we created earlier in this book in Chapter 5, Unit Testing, you’ll notice that we are running PHPUnit by adding the --color=always
parameter. Then, whenever we run PHPUnit and we get a failing test, you will notice that we always get a red error or failed test message.
To demonstrate the pattern clearly, let’s go through an example:
HelloTest.php
:codebase/symfony/tests/Unit/HelloTest.php
<?php...