Question: I am attempting to write a test case to ensure a Singleton class cannot be instantiated. The constructor for the Singleton is defined to be private so my test is as follows:

```
$this->expectError();
$test = new TestSingletonClassA();

```

Instead of catching the error and passing the test, I get a 'PHP Fatal error: Call to private Singleton::\_\_construct()'. I've also tried passing a PatternExpectation as a parameter to expectError, but that didn't work either. Do you have any suggestions?

Some background: php5.3, simpletest1.1a

Answer: 
If your php code throws a FATAL ERROR, it will never get to the phpunit, so you have to write "right" code in order to test it. If you call a private method, it will throw an excepcion, so it won't get to the phpunit. You have to change that.

I think you have to mock the object. Try [these posts](http://sebastian-bergmann.de/archives/881-Testing-Your-Privates.html) about this subject (it's a series of 4 posts) and [these slides](http://www.slideshare.net/sebastian_bergmann/phpunit-best-practices) (from slide #43) .
i don't think it's possible to do it that way.. fatal errors are not catchable as i've understood it. you could use reflection to get the constructor method, and then make sure it has the access modifier "private".

this is hard to test in most languages. for example java, c# and c++ would not even let you compile this code. so it could never be run at all D: