PhpStorm: PHP Fatal error: Class 'PHPUnit_TextUI_ResultPrinter'

Recently I ran a good ole composer update on a client project. This updated Drupal and PHPUnit. I ran our PHPUnit tests via PhpStorm and ran into an odd error:

Fatal error: Class 'PHPUnit_TextUI_ResultPrinter' not found in /private/var/folders/dk/1zgcm66d4vqchm8x5w4q57z40000gn/T/ide-phpunit.php on line 253

Call Stack:
    0.0019     446752   1. {main}() /private/var/folders/dk/1zgcm66d4vqchm8x5w4q57z40000gn/T/ide-phpunit.php:0

PHP Fatal error:  Class 'PHPUnit_TextUI_ResultPrinter' not found in /private/var/folders/dk/1zgcm66d4vqchm8x5w4q57z40000gn/T/ide-phpunit.php on line 253
PHP Stack trace:
PHP   1. {main}() /private/var/folders/dk/1zgcm66d4vqchm8x5w4q57z40000gn/T/ide-phpunit.php:0

If you didn't know, PhpStorm creates an ide-phpunit.php script that it invokes. Depending on the PHPUnit version it will generate the required code. In my case, it generated for 4.8.36

//load custom implementation of the PHPUnit_TextUI_ResultPrinter
class IDE_Base_PHPUnit_TextUI_ResultPrinter extends PHPUnit_TextUI_ResultPrinter
{
    /**
     * @param PHPUnit_Util_Printer $printer
     */
    function __construct($printer, $out)
    {
        parent::__construct($out);
        if (!is_null($printer) && $printer instanceof PHPUnit_TextUI_ResultPrinter) {
            $this->out = $printer->out;
            $this->outTarget = $printer->outTarget;
        }
    }

    protected function writeProgress($progress)
    {
        //ignore
    }
}

The quick fix: Let PhpStorm know that the PHPUnit version was updated. The error comes from the scripts PhpStorm generates for running PHPUnit. Once I clicked the refresh button, PHPUnit was recognized as 6.5.8, and the error was resolved.

Thumbnail