classProcessRunner
final class ProcessRunner
Public API: explicitly declared with
@visibility public.Runs a runner command that writes JUnit XML and reads the verdict from its reports.
The arguments are appended to the configured command without a shell, the reports are written to a fresh temporary directory and removed afterwards. A process that cannot start or exceeds its timeout becomes an "error" result.
$config = new \Requirements\Test\RunnerConfig('custom', [PHP_BINARY, '-r', 'file_put_contents($argv[1], "<testsuite><testcase name=\"a\"/></testsuite>");'], sys_get_temp_dir());
$result = (new \Requirements\Test\ProcessRunner())->run($config, static fn (string $directory): array => [$directory . '/report.xml']);
[$result->status, $result->tests] // => ['passed', 1]Methods§
public function run(RunnerConfig $config, callable(string): list<string> $arguments): TestResultRuns the command and reads the JUnit reports it wrote.
Parameters
$config | RunnerConfig | The command, working directory and timeout |
$arguments | callable(string): list<string> | Builds the arguments from the report directory |
Returns
TestResult The verdict read from the reportsThrows
RuntimeException When the temporary report directory cannot be createdTest cases 10
ProcessRunnerTest::testRunAppendsTheArgumentsToTheCommandcallsProcessRunnerTest::testRunFailsOnTimeoutAndMissingReportcallsProcessRunnerTest::testRunFailsWithTheOutputOfAFailingExitcallsProcessRunnerTest::testRunReadsEveryXmlReportAndIgnoresOtherFilescallsProcessRunnerTest::testRunReadsTheReportWrittenToTheFreshDirectorycallsProcessRunnerTest::testRunRemovesTheReportDirectorycallsProcessRunnerTest::testRunReportsACommandThatCannotStartcallsProcessRunnerTest::testRunReportsTheOutputOfARunWithoutReportscallsProcessRunnerTest::testRunReportsTheTimeoutMessagecallsProcessRunnerTest::testRunRunsInTheConfiguredDirectorycalls
Called from 2
Calls 16
- function-call
sys_get_temp_dirline 39 - function-call
bin2hexline 39 - function-call
random_bytesline 39 - function-call
mkdirline 40 - new
RuntimeExceptionline 41 - new
Processline 44 - method-call
Process::run()line 45 - function-call
globline 46 - method-call JUnit::read() line 47
- new JUnit line 47
- method-call
Process::getOutput()line 47 - method-call
Process::getErrorOutput()line 47 - new TestResult line 49
- function-call
is_fileline 53 - function-call
unlinkline 54 - function-call
rmdirline 57
Test cases 13§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 10
ProcessRunnerTest::testRunAppendsTheArgumentsToTheCommandcallsProcessRunnerTest::testRunFailsOnTimeoutAndMissingReportcallsProcessRunnerTest::testRunFailsWithTheOutputOfAFailingExitcallsProcessRunnerTest::testRunReadsEveryXmlReportAndIgnoresOtherFilescallsProcessRunnerTest::testRunReadsTheReportWrittenToTheFreshDirectorycallsProcessRunnerTest::testRunRemovesTheReportDirectorycallsProcessRunnerTest::testRunReportsACommandThatCannotStartcallsProcessRunnerTest::testRunReportsTheOutputOfARunWithoutReportscallsProcessRunnerTest::testRunReportsTheTimeoutMessagecallsProcessRunnerTest::testRunRunsInTheConfiguredDirectorycalls
Other tests reaching this symbol 3
ExtensionCommandTestcallsBehatRunnerTestcallsPhpUnitRunnerTestcalls