Runs the test case and collects the results in a TestResult object. If no TestResult object is passed a new one will be created.
PHPUnit_Framework_TestResult $result:
Overrides PHPUnit_Framework_Test::run
public function run(PHPUnit_Framework_TestResult $result = NULL) {
if ($result === NULL) {
$result = $this
->createResult();
}
if (!$this instanceof PHPUnit_Framework_Warning) {
$this
->setTestResultObject($result);
$this
->setUseErrorHandlerFromAnnotation();
$this
->setUseOutputBufferingFromAnnotation();
}
if ($this->useErrorHandler !== NULL) {
$oldErrorHandlerSetting = $result
->getConvertErrorsToExceptions();
$result
->convertErrorsToExceptions($this->useErrorHandler);
}
if (!$this instanceof PHPUnit_Framework_Warning && !$this
->handleDependencies()) {
return;
}
if ($this->runTestInSeparateProcess === TRUE && $this->inIsolation !== TRUE && !$this instanceof PHPUnit_Extensions_SeleniumTestCase && !$this instanceof PHPUnit_Extensions_PhptTestCase) {
$class = new ReflectionClass($this);
$template = new Text_Template(sprintf('%s%sProcess%sTestCaseMethod.tpl', __DIR__, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR));
if ($this->preserveGlobalState) {
$constants = PHPUnit_Util_GlobalState::getConstantsAsString();
$globals = PHPUnit_Util_GlobalState::getGlobalsAsString();
$includedFiles = PHPUnit_Util_GlobalState::getIncludedFilesAsString();
}
else {
$constants = '';
$globals = '';
$includedFiles = '';
}
if ($result
->getCollectCodeCoverageInformation()) {
$coverage = 'TRUE';
}
else {
$coverage = 'FALSE';
}
if ($result
->isStrict()) {
$strict = 'TRUE';
}
else {
$strict = 'FALSE';
}
if (defined('PHPUNIT_COMPOSER_INSTALL')) {
$composerAutoload = var_export(PHPUNIT_COMPOSER_INSTALL, TRUE);
}
else {
$composerAutoload = '\'\'';
}
$data = var_export(serialize($this->data), TRUE);
$dependencyInput = var_export(serialize($this->dependencyInput), TRUE);
$includePath = var_export(get_include_path(), TRUE);
// must do these fixes because TestCaseMethod.tpl has unserialize('{data}') in it, and we can't break BC
// the lines above used to use addcslashes() rather than var_export(), which breaks null byte escape sequences
$data = "'." . $data . ".'";
$dependencyInput = "'." . $dependencyInput . ".'";
$includePath = "'." . $includePath . ".'";
$template
->setVar(array(
'composerAutoload' => $composerAutoload,
'filename' => $class
->getFileName(),
'className' => $class
->getName(),
'methodName' => $this->name,
'collectCodeCoverageInformation' => $coverage,
'data' => $data,
'dataName' => $this->dataName,
'dependencyInput' => $dependencyInput,
'constants' => $constants,
'globals' => $globals,
'include_path' => $includePath,
'included_files' => $includedFiles,
'strict' => $strict,
));
$this
->prepareTemplate($template);
$php = PHPUnit_Util_PHP::factory();
$php
->runJob($template
->render(), $this, $result);
}
else {
$result
->run($this);
}
if ($this->useErrorHandler !== NULL) {
$result
->convertErrorsToExceptions($oldErrorHandlerSetting);
}
$this->result = NULL;
return $result;
}