From 9c73802ce652c66badf92c84cd718d1bce412af8 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 3 Sep 2013 17:20:38 +0200 Subject: [PATCH] Doc: Add Testing Singletons paragraph refs #4548 --- doc/test/php_tests.md | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) 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: + +