public function ScssUnitTest::assertScss in Sassy 7.3
Same name and namespace in other branches
- 7 phamlp/tests/test_inc.php \ScssUnitTest::assertScss()
8 calls to ScssUnitTest::assertScss()
- IssuesTest::test_border_radius in phpsass/
tests/ tests_compass.php - IssuesTest::test_extend3 in phpsass/
tests/ tests_extend.php - IssuesTest::test_extend_issue54 in phpsass/
tests/ tests_issues.php - IssuesTest::test_extend_issue80 in phpsass/
tests/ tests_extend.php - IssuesTest::test_ifs in phpsass/
tests/ tests_ifs.php
File
- phpsass/
tests/ test_inc.php, line 51
Class
Code
public function assertScss($scss, $css) {
$out = '<table class="testunit">';
$out .= '<tr>';
$out .= '<th>source Scss</th>';
$out .= '<th>Result</th>';
$out .= '<th>Output css</th>';
$out .= '<th>expected css</th>';
$out .= '</tr>';
if (!is_array($scss)) {
$scss = array(
$scss,
);
$css = array(
$css,
);
}
for ($i = 0, $k = count($scss); $i < $k; $i++) {
$css[$i] = trim($css[$i]);
try {
$result = $this->sass
->toCss($scss[$i], false);
$result = trim($result);
} catch (Exception $e) {
$result = $e
->getMessage();
}
$css[$i] = str_replace(array(
"\r\n",
"\n\r",
"\r",
), "\n", $css[$i]);
$pass = $css[$i] == $result;
$out .= '<tr>';
$out .= '<td><pre>' . htmlspecialchars($scss[$i]) . '</pre></td>';
$out .= '<td style="background-color:' . ($pass ? '#CFC' : '#FCC') . ';">' . ($pass ? '<h5>Pass!</h5>' : '<h5>Failed!</h5>') . '</td>';
$out .= '<td style="background-color:' . ($pass ? '#CFC' : '#FCC') . ';">' . '<pre>' . htmlspecialchars($result) . '</pre></td>';
$out .= '<td><pre>' . htmlspecialchars($css[$i]) . '</pre></td>';
$out .= '</tr>';
}
$out .= '</table>';
echo $out;
}