/** * Runs this installation script * @return null */ function run() { $action = null; if (array_key_exists('action', $_GET)) { $action = $_GET['action']; } try { $baseUrl = getBaseUrl(); $url = getBaseUrl() . str_replace(__DIR__, '', __FILE__); $content = '<p>This script will help you download and launch the latest Zibo installation.</p>'; $requirements = checkRequirements(); if ($requirements) { $content .= '<div class="error">'; $content .= '<p>Not all requirements are met, please solve the following issues:</p>'; $content .= '<ul>'; foreach ($requirements as $requirement) { $content .= '<li>' . $requirement . '</li>'; } $content .= '</ul>'; $content .= '</div>'; $content .= '<form action="' . $url . '"><input type="submit" value="Check again" /></form>'; } else { if (!$action) { $content .= '<p class="success">All the requirements are met.</p>'; $content .= '<p>The script is ready to download Zibo.</p>'; $content .= '<p>Zibo download:<br /><code><a href="' . PACKAGE . '">' . PACKAGE . '</a></code></p>'; $content .= '<p>Installation directory:<br /><code>' . getInstallationDirectory() . '</code></p>'; $content .= '<form action="' . $url . '?action=download" method="post"><input type="submit" value="Proceed" /></form>'; } elseif ($action == 'download') { downloadAndUnpack(); header('Location: ' . $baseUrl); } } } catch (Exception $exception) { $content = '<div class="error"><pre>'; $content .= $exception->getMessage() . "\n" . $exception->getTraceAsString(); $content .= '</pre></div>'; } echo renderOutput($content); }
function displayTestResults($testResults) { echo renderOutput($testResults); return count($testResults->failedAssertions) ? 1 : 0; }
$sampleTopic = (include __DIR__ . '/../examples/topic-calculus.php'); $expectedOutput = <<<OUTPUT topics: 1 features: 2 assertions: 5 FAILED: calculus: addition adds two numbers Expected values to be equal, instead got: --- Actual +++ Expected @@ @@ -2 +3 FAILED: calculus: addition is difficult Expected values to be equal, instead got: --- Actual +++ Expected @@ @@ -6 +33 FAILED: calculus: subtraction looks strange Expected value to be false OUTPUT; return within("integration", describe("output from complete suite", it("renders everything we need to know", function () use($expectedOutput, $sampleTopic) { $renderedOutput = renderOutput(testResults([$sampleTopic])); return $renderedOutput === $expectedOutput; })));