1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-11 16:44:59 +02:00

[3.1.0] When flush fails, fail SimpleTest

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1641 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-04-03 21:24:16 +00:00
parent 1d25be875d
commit e78df4dc9f
5 changed files with 53 additions and 27 deletions

View File

@@ -178,3 +178,33 @@ function printTokens($tokens, $index = null) {
$string .= '</pre>';
echo $string;
}
/**
* Convenient "insta-fail" test-case to add if any outside things fail
*/
class FailedTest extends UnitTestCase {
protected $msg, $details;
public function __construct($msg, $details = null) {
$this->msg = $msg;
$this->details = $details;
}
public function test() {
$this->fail($this->msg);
if ($this->details) $this->_reporter->paintFormattedMessage($this->details);
}
}
/**
* Flushes all caches, and fatally errors out if there's a problem.
*/
function htmlpurifier_flush($php, $reporter) {
exec($php . ' ../maintenance/flush.php', $out, $status);
if ($status) {
$test = new FailedTest(
'maintenance/flush.php returned non-zero exit status',
wordwrap(implode("\n", $out), 80)
);
$test->run($reporter);
exit(1);
}
}