Test doubles: Difference between revisions
move and separate footnotes |
|||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
A '''[[wp:Test double]]''' is any object that stands in for a real dependency in automated testing. Usually in [[PHPUnit]], we make test doubles for other classes, but you can also double PHP native functions or <abbr title="Closures are small use-once functions which are useful as parameters for callback functions like array_walk, array_map, etc. Using closure functions in PHP can help to make code more succinct, expressive, and safer. Closures can access private data of an object.">closures</abbr><ref>aka anonymous functions<br>https://www.php.net/manual/en/functions.anonymous.php<br>https://www.php.net/manual/en/class.closure.php</ref><ref>These 'other things' being doubled are sometimes referred to as the "Depended On Component" | A '''[[wp:Test double]]''' is any object that stands in for a real dependency in automated testing<ref> | ||
'''Important Material''' | |||
see [https://docs.phpunit.de/en/9.6/test-doubles.html Test Doubles in PHPUnit (v9.6)] or ([https://docs.phpunit.de/en/10.5/test-doubles.html v10.5]) | |||
see the 'original' '''book on XUnit''' - [http://xunitpatterns.com/Using%20Test%20Doubles.html chapter on Test Doubles], including diagrams to help illustrate the various types of doubles</ref>. Usually in [[PHPUnit]], we make test doubles for other classes, but you can also double PHP native functions or <abbr title="Closures are small use-once functions which are useful as parameters for callback functions like array_walk, array_map, etc. Using closure functions in PHP can help to make code more succinct, expressive, and safer. Closures can access private data of an object.">closures</abbr><ref>aka anonymous functions<br>https://www.php.net/manual/en/functions.anonymous.php<br>https://www.php.net/manual/en/class.closure.php</ref><ref>These 'other things' being doubled are sometimes referred to as the "Depended On Component"</ref>. | |||
There are 5 types of Test doubles | There are 5 types of Test doubles | ||