| 1 |
mjordaan |
1 |
<?php
|
|
|
2 |
use SebastianBergmann\CodeCoverage\CodeCoverage;
|
|
|
3 |
|
|
|
4 |
if (!defined('STDOUT')) {
|
|
|
5 |
// php://stdout does not obey output buffering. Any output would break
|
|
|
6 |
// unserialization of child process results in the parent process.
|
|
|
7 |
define('STDOUT', fopen('php://temp', 'w+b'));
|
|
|
8 |
define('STDERR', fopen('php://stderr', 'wb'));
|
|
|
9 |
}
|
|
|
10 |
|
|
|
11 |
{iniSettings}
|
|
|
12 |
ini_set('display_errors', 'stderr');
|
|
|
13 |
set_include_path('{include_path}');
|
|
|
14 |
|
|
|
15 |
$composerAutoload = {composerAutoload};
|
|
|
16 |
$phar = {phar};
|
|
|
17 |
|
|
|
18 |
ob_start();
|
|
|
19 |
|
|
|
20 |
if ($composerAutoload) {
|
|
|
21 |
require_once $composerAutoload;
|
|
|
22 |
define('PHPUNIT_COMPOSER_INSTALL', $composerAutoload);
|
|
|
23 |
} else if ($phar) {
|
|
|
24 |
require $phar;
|
|
|
25 |
}
|
|
|
26 |
|
|
|
27 |
function __phpunit_run_isolated_test()
|
|
|
28 |
{
|
|
|
29 |
if (!class_exists('{className}')) {
|
|
|
30 |
require_once '{filename}';
|
|
|
31 |
}
|
|
|
32 |
|
|
|
33 |
$result = new PHPUnit_Framework_TestResult;
|
|
|
34 |
|
|
|
35 |
if ({collectCodeCoverageInformation}) {
|
|
|
36 |
$result->setCodeCoverage(
|
|
|
37 |
new CodeCoverage(
|
|
|
38 |
null,
|
|
|
39 |
unserialize('{codeCoverageFilter}')
|
|
|
40 |
)
|
|
|
41 |
);
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
$result->beStrictAboutTestsThatDoNotTestAnything({isStrictAboutTestsThatDoNotTestAnything});
|
|
|
45 |
$result->beStrictAboutOutputDuringTests({isStrictAboutOutputDuringTests});
|
|
|
46 |
$result->enforceTimeLimit({enforcesTimeLimit});
|
|
|
47 |
$result->beStrictAboutTodoAnnotatedTests({isStrictAboutTodoAnnotatedTests});
|
|
|
48 |
$result->beStrictAboutResourceUsageDuringSmallTests({isStrictAboutResourceUsageDuringSmallTests});
|
|
|
49 |
|
|
|
50 |
$test = new {className}('{methodName}', unserialize('{data}'), '{dataName}');
|
|
|
51 |
$test->setDependencyInput(unserialize('{dependencyInput}'));
|
|
|
52 |
$test->setInIsolation(TRUE);
|
|
|
53 |
|
|
|
54 |
ob_end_clean();
|
|
|
55 |
$test->run($result);
|
|
|
56 |
$output = '';
|
|
|
57 |
if (!$test->hasExpectationOnOutput()) {
|
|
|
58 |
$output = $test->getActualOutput();
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
@rewind(STDOUT); /* @ as not every STDOUT target stream is rewindable */
|
|
|
62 |
if ($stdout = stream_get_contents(STDOUT)) {
|
|
|
63 |
$output = $stdout . $output;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
print serialize(
|
|
|
67 |
array(
|
|
|
68 |
'testResult' => $test->getResult(),
|
|
|
69 |
'numAssertions' => $test->getNumAssertions(),
|
|
|
70 |
'result' => $result,
|
|
|
71 |
'output' => $output
|
|
|
72 |
)
|
|
|
73 |
);
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
$configurationFilePath = '{configurationFilePath}';
|
|
|
77 |
|
|
|
78 |
if ('' !== $configurationFilePath) {
|
|
|
79 |
$configuration = PHPUnit_Util_Configuration::getInstance($configurationFilePath);
|
|
|
80 |
$configuration->handlePHPConfiguration();
|
|
|
81 |
unset($configuration);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext)
|
|
|
85 |
{
|
|
|
86 |
return true;
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
set_error_handler("__phpunit_error_handler");
|
|
|
90 |
|
|
|
91 |
{constants}
|
|
|
92 |
{included_files}
|
|
|
93 |
{globals}
|
|
|
94 |
|
|
|
95 |
restore_error_handler();
|
|
|
96 |
|
|
|
97 |
if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) {
|
|
|
98 |
require_once $GLOBALS['__PHPUNIT_BOOTSTRAP'];
|
|
|
99 |
unset($GLOBALS['__PHPUNIT_BOOTSTRAP']);
|
|
|
100 |
}
|
|
|
101 |
|
|
|
102 |
__phpunit_run_isolated_test();
|