diff --git a/doc/test/php_tests.md b/doc/test/php_tests.md index 6149e703d..d010cadcb 100644 --- a/doc/test/php_tests.md +++ b/doc/test/php_tests.md @@ -28,6 +28,37 @@ modules/mymodule/library/MyModule/Helper/MyClass.php. } } +## Testing Singletons + +When test methods **modify static** class properties (which is the case when using singletons), add the PHPUnit +[`@backupStaticAttributes enabled`](http://phpunit.de/manual/3.7/en/appendixes.annotations.html#appendixes.annotations.backupStaticAttributes) +annotation to their [DockBlock](http://www.phpdoc.org/docs/latest/for-users/phpdoc/basic-syntax.html#what-is-a-docblock) +in order to backup and restore static attributes before and after the method execution respectively. For reference you +should **document** that the test interacts with static attributes: + +