|
| 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}(null, 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 | + $streamMetaData = stream_get_meta_data(STDOUT); |
| 65 | + if (!empty($streamMetaData['stream_type']) && 'STDIO' === $streamMetaData['stream_type']) { |
| 66 | + @ftruncate(STDOUT, 0); |
| 67 | + @rewind(STDOUT); |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + print serialize( |
| 72 | + array( |
| 73 | + 'testResult' => $test->getResult(), |
| 74 | + 'numAssertions' => $test->getNumAssertions(), |
| 75 | + 'result' => $result, |
| 76 | + 'output' => $output |
| 77 | + ) |
| 78 | + ); |
| 79 | +} |
| 80 | + |
| 81 | +$configurationFilePath = '{configurationFilePath}'; |
| 82 | + |
| 83 | +if ('' !== $configurationFilePath) { |
| 84 | + $configuration = PHPUnit\Util\Configuration::getInstance($configurationFilePath); |
| 85 | + $configuration->handlePHPConfiguration(); |
| 86 | + unset($configuration); |
| 87 | +} |
| 88 | + |
| 89 | +function __phpunit_error_handler($errno, $errstr, $errfile, $errline, $errcontext) |
| 90 | +{ |
| 91 | + return true; |
| 92 | +} |
| 93 | + |
| 94 | +set_error_handler("__phpunit_error_handler"); |
| 95 | + |
| 96 | +{constants} |
| 97 | +{included_files} |
| 98 | +{globals} |
| 99 | + |
| 100 | +restore_error_handler(); |
| 101 | + |
| 102 | +if (isset($GLOBALS['__PHPUNIT_BOOTSTRAP'])) { |
| 103 | + require_once $GLOBALS['__PHPUNIT_BOOTSTRAP']; |
| 104 | + unset($GLOBALS['__PHPUNIT_BOOTSTRAP']); |
| 105 | +} |
| 106 | + |
| 107 | +__phpunit_run_isolated_test(); |
0 commit comments