fixed unit tests

This commit is contained in:
Fabien Potencier
2010-08-13 18:37:33 +02:00
parent 5d6e7e2e01
commit 13738f0082
5 changed files with 20 additions and 86 deletions
@@ -1,9 +0,0 @@
--TEST--
"even" filter
--TEMPLATE--
{{ 1|even }}
{{ 2|even }}
--DATA--
return array()
--EXPECT--
1
-10
View File
@@ -1,10 +0,0 @@
--TEST--
"odd" filter
--TEMPLATE--
{{ 1|odd }}
{{ 2|odd }}
--DATA--
return array()
--EXPECT--
1
+10
View File
@@ -0,0 +1,10 @@
--TEST--
"even" test
--TEMPLATE--
{{ 1 is even ? 'ko' : 'ok' }}
{{ 2 is even ? 'ok' : 'ko' }}
--DATA--
return array()
--EXPECT--
ok
ok
+10
View File
@@ -0,0 +1,10 @@
--TEST--
"odd" test
--TEMPLATE--
{{ 1 is odd ? 'ok' : 'ko' }}
{{ 2 is odd ? 'ko' : 'ok' }}
--DATA--
return array()
--EXPECT--
ok
ok
-67
View File
@@ -1,67 +0,0 @@
<?php
/*
* This file is part of Twig.
*
* (c) Fabien Potencier
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once dirname(__FILE__).'/TestCase.php';
class Twig_Tests_Node_DebugTest extends Twig_Tests_Node_TestCase
{
/**
* @covers Twig_Node_Debug::__construct
*/
public function testConstructor()
{
$expr = new Twig_Node_Expression_Name('foo', 0);
$node = new Twig_Node_Debug($expr, 0);
$this->assertEquals($expr, $node->expr);
$node = new Twig_Node_Debug(null, 0);
$this->assertEquals(null, $node->expr);
}
/**
* @covers Twig_Node_Debug::compile
* @dataProvider getTests
*/
public function testCompile($node, $source, $environment = null)
{
parent::testCompile($node, $source, $environment);
}
public function getTests()
{
$tests = array();
$tests[] = array(new Twig_Node_Debug(null, 0), <<<EOF
if (\$this->env->isDebug()) {
\$vars = array();
foreach (\$context as \$key => \$value) {
if (!\$value instanceof Twig_Template) {
\$vars[\$key] = \$value;
}
}
print_r(\$vars);
}
EOF
);
$expr = new Twig_Node_Expression_Name('foo', 0);
$node = new Twig_Node_Debug($expr, 0);
$tests[] = array($node, <<<EOF
if (\$this->env->isDebug()) {
print_r((isset(\$context['foo']) ? \$context['foo'] : null));
}
EOF
);
return $tests;
}
}