private function runExample($testFile)
{
$this->testFile = $testFile;
$examplesDir = realpath(__DIR__ . '/../examples');
$samplesTestCase = $examplesDir . '/' . $testFile;
$logFile = tempnam(sys_get_temp_dir(), 'phpunit_log_');
$environmentVariables = [];
foreach ($this->environment as $name => $value) {
$environmentVariables[] .= "{$name}={$value}";
}
$phpunitCommand = implode(" ", $environmentVariables) . " vendor/bin/phpunit --log-junit {$logFile} {$samplesTestCase}";
exec($phpunitCommand, $output);
$contentsOfXmlLog = file_get_contents($logFile);
if (!$contentsOfXmlLog) {
$this->fail("It appears the command" . PHP_EOL . $phpunitCommand . PHP_EOL . "has crashed without leaving a log for us to analyze." . PHP_EOL . "This was its output: " . implode(PHP_EOL, $output) . PHP_EOL);
}
$this->results = new SimpleXMLElement($contentsOfXmlLog);
}