ErrorHandling folder
*/
class HTMLPurifier_HTMLModule_MathMLBasicTest extends HTMLPurifier_HTMLModuleHarness
{
public function setup() {
parent::setup();
$this->config->set('HTML.MathML', true);
// We load each snippet and its purified version each into a
// separate XML document. This normalizes some self-closing
// tags which can be either or or into a
// common format to compare the strings properly.
$this->pre = new DOMDocument();
$this->post = new DOMDocument();
}
// Correctly formed MathML trees
public function testGood()
{
foreach (glob('MathML/basic/good/*.mml') as $filename) {
$snippet = file_get_contents($filename);
$this->pre->loadXML($snippet);
$this->pre->normalizeDocument();
$this->post->loadXML($this->purifier->purify($snippet, $this->config));
$this->post->normalizeDocument();
$this->assertIdentical($this->pre->saveXML(), $this->post->saveXML());
}
}
// Incorrectly formed MathML trees
public function testBad() {
foreach (glob('MathML/basic/bad/*.mml') as $filename) {
$snippet = file_get_contents($filename);
$this->pre->loadXML($snippet);
$this->pre->normalizeDocument();
$this->post->loadXML($this->purifier->purify($snippet, $this->config));
$this->post->normalizeDocument();
$this->assertFalse($this->pre->saveXML() == $this->post->saveXML());
}
}
// Incorrectly formed MathML trees that yield an error
public function testError() {
$snippet = '';
$this->expectError();
$this->pre->loadXML($snippet);
$this->pre->normalizeDocument();
$this->post->loadXML($this->purifier->purify($snippet, $this->config));
$this->post->normalizeDocument();
$this->assertFalse($this->pre->saveXML() == $this->post->saveXML());
}
}
// vim: et sw=4 sts=4