Skip to content

Commit

Permalink
Fixed unit test for debug extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabien Pennequin authored and fabpot committed Dec 12, 2010
1 parent c69e73a commit 404950e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/Twig/Extensions/Node/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function compile($compiler)
->indent()
;

if (null === $this->expr) {
if (null === $this->getNode('expr')) {
// remove embedded templates (macros) from the context
$compiler
->write("\$vars = array();\n")
Expand All @@ -56,7 +56,7 @@ public function compile($compiler)
} else {
$compiler
->write("print_r(")
->subcompile($this->expr)
->subcompile($this->getNode('expr'))
->raw(");\n")
;
}
Expand Down
14 changes: 7 additions & 7 deletions test/Twig/Tests/Node/DebugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* file that was distributed with this source code.
*/

require_once dirname(__FILE__).'/TestCase.php';
require_once TWIG_LIBRARY_PATH.'/../test/Twig/Tests/Node/TestCase.php';

class Twig_Tests_Node_DebugTest extends Twig_Tests_Node_TestCase
{
Expand All @@ -19,11 +19,11 @@ class Twig_Tests_Node_DebugTest extends Twig_Tests_Node_TestCase
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_Extensions_Node_Debug($expr, 0);
$this->assertEquals($expr, $node->getNode('expr'));

$node = new Twig_Node_Debug(null, 0);
$this->assertEquals(null, $node->expr);
$node = new Twig_Extensions_Node_Debug(null, 0);
$this->assertEquals(null, $node->getNode('expr'));
}

/**
Expand All @@ -39,7 +39,7 @@ public function getTests()
{
$tests = array();

$tests[] = array(new Twig_Node_Debug(null, 0), <<<EOF
$tests[] = array(new Twig_Extensions_Node_Debug(null, 0), <<<EOF
if (\$this->env->isDebug()) {
\$vars = array();
foreach (\$context as \$key => \$value) {
Expand All @@ -53,7 +53,7 @@ public function getTests()
);

$expr = new Twig_Node_Expression_Name('foo', 0);
$node = new Twig_Node_Debug($expr, 0);
$node = new Twig_Extensions_Node_Debug($expr, 0);

$tests[] = array($node, <<<EOF
if (\$this->env->isDebug()) {
Expand Down

0 comments on commit 404950e

Please sign in to comment.