Permalink
Browse files

refactored some unit tests

  • Loading branch information...
1 parent 7dd2f17 commit 5d7baaf767ec3b8f6599738e7c98bde6c25cf7c1 @fabpot committed Oct 6, 2012
Showing with 13 additions and 10 deletions.
  1. +13 −10 test/Twig/Tests/Node/Expression/FilterTest.php
@@ -33,16 +33,19 @@ public function testConstructor()
public function testCompile($node, $source, $environment = null)
{
parent::testCompile($node, $source, $environment);
+ }
+ /**
+ * @covers Twig_Node_Expression_Filter::compile
+ * @expectedException Twig_Error_Syntax
+ * @expectedExceptionMessage The filter "lowe" does not exist. Did you mean "lower" at line 0
+ */
+ public function testCompileUnknownFilter()
+ {
$expr = new Twig_Node_Expression_Constant('foo', 0);
- $node = $this->createFilter($expr, 'foobar', array(new Twig_Node_Expression_Constant('bar', 0), new Twig_Node_Expression_Constant('foobar', 0)));
+ $node = $this->createFilter($expr, 'lowe', array(new Twig_Node_Expression_Constant('bar', 0), new Twig_Node_Expression_Constant('foobar', 0)));
- try {
- $node->compile($this->getCompiler());
- $this->fail();
- } catch (Exception $e) {
- $this->assertEquals('Twig_Error_Syntax', get_class($e));
- }
+ $node->compile($this->getCompiler());
}
public function getTests()
@@ -51,12 +54,12 @@ public function getTests()
$expr = new Twig_Node_Expression_Constant('foo', 0);
$node = $this->createFilter($expr, 'upper');
- $node = $this->createFilter($node, 'lower', array(new Twig_Node_Expression_Constant('bar', 0), new Twig_Node_Expression_Constant('foobar', 0)));
+ $node = $this->createFilter($node, 'number_format', array(new Twig_Node_Expression_Constant(2, 0), new Twig_Node_Expression_Constant('.', 0), new Twig_Node_Expression_Constant(',', 0)));
if (function_exists('mb_get_info')) {
- $tests[] = array($node, 'twig_lower_filter($this->env, twig_upper_filter($this->env, "foo"), "bar", "foobar")');
+ $tests[] = array($node, 'twig_number_format_filter($this->env, twig_upper_filter($this->env, "foo"), 2, ".", ",")');
} else {
- $tests[] = array($node, 'strtolower(strtoupper("foo"), "bar", "foobar")');
+ $tests[] = array($node, 'twig_number_format_filter($this->env, strtoupper("foo"), 2, ".", ",")');
}
return $tests;

0 comments on commit 5d7baaf

Please sign in to comment.