You are here

protected function PHPUnit_TextUI_Command::handlePrinter in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/TextUI/Command.php \PHPUnit_TextUI_Command::handlePrinter()

Handles the loading of the PHPUnit_Util_Printer implementation.

Parameters

string $printerClass:

string $printerFile:

Return value

PHPUnit_Util_Printer

1 call to PHPUnit_TextUI_Command::handlePrinter()
PHPUnit_TextUI_Command::handleArguments in vendor/phpunit/phpunit/src/TextUI/Command.php
Handles the command-line arguments.

File

vendor/phpunit/phpunit/src/TextUI/Command.php, line 716

Class

PHPUnit_TextUI_Command
A TestRunner for the Command Line Interface (CLI) PHP SAPI Module.

Code

protected function handlePrinter($printerClass, $printerFile = '') {
  if (!class_exists($printerClass, false)) {
    if ($printerFile == '') {
      $printerFile = PHPUnit_Util_Filesystem::classNameToFilename($printerClass);
    }
    $printerFile = stream_resolve_include_path($printerFile);
    if ($printerFile) {
      require $printerFile;
    }
  }
  if (class_exists($printerClass)) {
    $class = new ReflectionClass($printerClass);
    if ($class
      ->implementsInterface('PHPUnit_Framework_TestListener') && $class
      ->isSubclassOf('PHPUnit_Util_Printer') && $class
      ->isInstantiable()) {
      if ($class
        ->isSubclassOf('PHPUnit_TextUI_ResultPrinter')) {
        return $printerClass;
      }
      $outputStream = isset($this->arguments['stderr']) ? 'php://stderr' : null;
      return $class
        ->newInstance($outputStream);
    }
  }
  $this
    ->showError(sprintf('Could not use "%s" as printer.', $printerClass));
}