sebastianbergmann/phpunit — pull request #1360 by sun (2014-07-27 18:06:58+00:00)
Title: Allow a test to identify whether it runs in isolation

A custom setup of test fixtures may use the new `PHPUnit_Framework_TestCase::isTestInIsolation()` method to determine whether to skip additional performance optimizations that only make sense if multiple tests are executed in the same process.

The tests I'm currently working on need to boot up application framework objects that are very expensive to (re-)build (a full-stack Symfony Kernel/ContainerBuilder). In my case, all test methods of a single test class are always initialized in the same way, so precompiling it once and cloning it for every test method dramatically improved performance (related: symfony/symfony#11422). — However, that obviously doesn't make sense in case only one test is executed in isolation.

It is possible to identify this already, but the `$isInIsolation` property is private, so it's clunky:
```php
protected function isTestInIsolation() {
return function_exists('__phpunit_run_isolated_test');
}
```

In light of #950, I named the new method `isTestInIsolation()` instead of `isInIsolation()`.

As this is a minor addition, my hope is to get it into the next 4.1.5 stable.

---
Additionally necessary for #1359 (in case that solution is acceptable)