how would you test a method of a class that has collateral effects via self::
? such as:
final class Foo{
private static $effect = false;
public static function doit( $arg ){
if( self::effect ) return;
self::check_args( $arg );
self::$effect = true;
}
private function check_args($arg){
#validate and trhow exception if invalid
}
}
I have to send several args to doit() to test it's validating the values correctly, but after the first run it's just bypassing it. it's basically a initialization method for a singleton that set's a initialized flag.
I can't really afford to mess with the class just yet. Is there any way i can make a copy/instatiate of the object in a way it would work with self::
?