Improve Mustache exception types, catchability.
* Subclass common exception types (runtime, logic, invalid argument). * Add new "unknown x" exceptions for filters, helpers and templates. * Make all Mustache exceptions implement Mustache_Exception interface… Gotta catch 'em all!
This commit is contained in:
@@ -85,9 +85,9 @@ class Mustache_Test_CompilerTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException Mustache_Exception_SyntaxException
|
||||
*/
|
||||
public function testCompilerThrowsUnknownNodeTypeException()
|
||||
public function testCompilerThrowsSyntaxException()
|
||||
{
|
||||
$compiler = new Mustache_Compiler;
|
||||
$compiler->compile('', array(array(Mustache_Tokenizer::TYPE => 'invalid')), 'SomeClass');
|
||||
|
||||
@@ -141,7 +141,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException Mustache_Exception_InvalidArgumentException
|
||||
* @dataProvider getBadEscapers
|
||||
*/
|
||||
public function testNonCallableEscapeThrowsException($escape)
|
||||
@@ -158,7 +158,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
* @expectedException Mustache_Exception_RuntimeException
|
||||
*/
|
||||
public function testImmutablePartialsLoadersThrowException()
|
||||
{
|
||||
@@ -223,7 +223,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException Mustache_Exception_InvalidArgumentException
|
||||
*/
|
||||
public function testSetHelpersThrowsExceptions()
|
||||
{
|
||||
@@ -232,7 +232,7 @@ class Mustache_Test_EngineTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException Mustache_Exception_InvalidArgumentException
|
||||
*/
|
||||
public function testSetLoggerThrowsExceptions()
|
||||
{
|
||||
|
||||
@@ -67,7 +67,7 @@ class Mustache_Test_FiveThree_Functional_FiltersTest extends PHPUnit_Framework_T
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException UnexpectedValueException
|
||||
* @expectedException Mustache_Exception_UnknownFilterException
|
||||
* @dataProvider getBrokenPipes
|
||||
*/
|
||||
public function testThrowsExceptionForBrokenPipes($tpl, $data)
|
||||
|
||||
@@ -42,7 +42,7 @@ class Mustache_Test_Loader_ArrayLoaderTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException Mustache_Exception_UnknownTemplateException
|
||||
*/
|
||||
public function testMissingTemplatesThrowExceptions()
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException RuntimeException
|
||||
* @expectedException Mustache_Exception_RuntimeException
|
||||
*/
|
||||
public function testMissingBaseDirThrowsException()
|
||||
{
|
||||
@@ -52,7 +52,7 @@ class Mustache_Test_Loader_FilesystemLoaderTest extends PHPUnit_Framework_TestCa
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException Mustache_Exception_UnknownTemplateException
|
||||
*/
|
||||
public function testMissingTemplateThrowsException()
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException LogicException
|
||||
* @expectedException Mustache_Exception_LogicException
|
||||
*/
|
||||
public function testPrematurelyClosedStreamThrowsException()
|
||||
{
|
||||
@@ -187,7 +187,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException Mustache_Exception_InvalidArgumentException
|
||||
*/
|
||||
public function testThrowsInvalidArgumentExceptionWhenSettingUnknownLevels()
|
||||
{
|
||||
@@ -196,7 +196,7 @@ class Mustache_Test_Logger_StreamLoggerTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
* @expectedException Mustache_Exception_InvalidArgumentException
|
||||
*/
|
||||
public function testThrowsInvalidArgumentExceptionWhenLoggingUnknownLevels()
|
||||
{
|
||||
|
||||
@@ -108,7 +108,7 @@ class Mustache_Test_ParserTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider getBadParseTrees
|
||||
* @expectedException LogicException
|
||||
* @expectedException Mustache_Exception_SyntaxException
|
||||
*/
|
||||
public function testParserThrowsExceptions($tokens)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user