Cleaned up UNKNOWN PRAGMA exception test.

This commit is contained in:
Justin Hileman
2010-04-29 19:24:44 -04:00
parent 537ebc44c8
commit e962cbac8c
+5 -6
View File
@@ -7,17 +7,15 @@ class MustachePragmaTest extends PHPUnit_Framework_TestCase {
public function testUnknownPragmaException() { public function testUnknownPragmaException() {
$m = new Mustache(); $m = new Mustache();
$caught_exception = null;
try { try {
$m->render('{{%I-HAVE-THE-GREATEST-MUSTACHE}}'); $m->render('{{%I-HAVE-THE-GREATEST-MUSTACHE}}');
} catch (Exception $e) { } catch (MustacheException $e) {
$caught_exception = $e; $this->assertEquals(MustacheException::UNKNOWN_PRAGMA, $e->getCode(), 'Caught exception code was not MustacheException::UNKNOWN_PRAGMA');
return;
} }
$this->assertNotNull($caught_exception, 'No exception caught'); $this->fail('Mustache should have thrown an unknown pragma exception');
$this->assertType('MustacheException', $caught_exception);
$this->assertEquals($caught_exception->getCode(), MustacheException::UNKNOWN_PRAGMA, 'Caught exception code was not MustacheException::UNKNOWN_PRAGMA');
} }
public function testPragmaReplace() { public function testPragmaReplace() {
@@ -37,4 +35,5 @@ class MustachePragmaTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($m->render("\n{{%DOT-NOTATION}}\n"), "\n", 'Too many newlines removed with pragma tag'); $this->assertEquals($m->render("\n{{%DOT-NOTATION}}\n"), "\n", 'Too many newlines removed with pragma tag');
$this->assertEquals($m->render("1\n2{{%DOT-NOTATION}}\n3"), "1\n23", 'Wrong newline removed with pragma tag'); $this->assertEquals($m->render("1\n2{{%DOT-NOTATION}}\n3"), "1\n23", 'Wrong newline removed with pragma tag');
} }
} }