mirror of
https://github.com/danog/PHP-Parser.git
synced 2025-01-20 12:46:47 +01:00
Cover both DONT_TRAVERSE_CHILDREN cases
This commit is contained in:
parent
1a63a915f2
commit
9689763e20
@ -131,9 +131,10 @@ class NodeTraverserTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testDontTraverseChildren() {
|
public function testDontTraverseChildren() {
|
||||||
$strNode = new String('str');
|
$strNode = new String('str');
|
||||||
$printNode = new Expr\Print_($strNode);
|
$printNode = new Expr\Print_($strNode);
|
||||||
$argNode = new Node\Arg($strNode);
|
$varNode = new Expr\Variable('foo');
|
||||||
$callNode = new Expr\FuncCall(new Node\Name('test'), array($argNode));
|
$mulNode = new Expr\BinaryOp\Mul($varNode, $varNode);
|
||||||
$stmts = array($printNode, $callNode);
|
$negNode = new Expr\UnaryMinus($mulNode);
|
||||||
|
$stmts = array($printNode, $negNode);
|
||||||
|
|
||||||
$visitor1 = $this->getMock('PhpParser\NodeVisitor');
|
$visitor1 = $this->getMock('PhpParser\NodeVisitor');
|
||||||
$visitor2 = $this->getMock('PhpParser\NodeVisitor');
|
$visitor2 = $this->getMock('PhpParser\NodeVisitor');
|
||||||
@ -145,18 +146,18 @@ class NodeTraverserTest extends \PHPUnit_Framework_TestCase
|
|||||||
$visitor1->expects($this->at(2))->method('leaveNode')->with($printNode);
|
$visitor1->expects($this->at(2))->method('leaveNode')->with($printNode);
|
||||||
$visitor2->expects($this->at(2))->method('leaveNode')->with($printNode);
|
$visitor2->expects($this->at(2))->method('leaveNode')->with($printNode);
|
||||||
|
|
||||||
$visitor1->expects($this->at(3))->method('enterNode')->with($callNode);
|
$visitor1->expects($this->at(3))->method('enterNode')->with($negNode);
|
||||||
$visitor2->expects($this->at(3))->method('enterNode')->with($callNode);
|
$visitor2->expects($this->at(3))->method('enterNode')->with($negNode);
|
||||||
|
|
||||||
$visitor1->expects($this->at(6))->method('enterNode')->with($argNode);
|
$visitor1->expects($this->at(4))->method('enterNode')->with($mulNode);
|
||||||
$visitor2->expects($this->at(6))->method('enterNode')->with($argNode)
|
$visitor2->expects($this->at(4))->method('enterNode')->with($mulNode)
|
||||||
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CHILDREN));
|
->will($this->returnValue(NodeTraverser::DONT_TRAVERSE_CHILDREN));
|
||||||
|
|
||||||
$visitor1->expects($this->at(7))->method('leaveNode')->with($argNode);
|
$visitor1->expects($this->at(5))->method('leaveNode')->with($mulNode);
|
||||||
$visitor2->expects($this->at(7))->method('leaveNode')->with($argNode);
|
$visitor2->expects($this->at(5))->method('leaveNode')->with($mulNode);
|
||||||
|
|
||||||
$visitor1->expects($this->at(8))->method('leaveNode')->with($callNode);
|
$visitor1->expects($this->at(6))->method('leaveNode')->with($negNode);
|
||||||
$visitor2->expects($this->at(8))->method('leaveNode')->with($callNode);
|
$visitor2->expects($this->at(6))->method('leaveNode')->with($negNode);
|
||||||
|
|
||||||
$traverser = new NodeTraverser;
|
$traverser = new NodeTraverser;
|
||||||
$traverser->addVisitor($visitor1);
|
$traverser->addVisitor($visitor1);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user