public function testTraverse()
 {
     $function = new \PHPParser_Node_Stmt_Function('foo', array('stmts' => $functionBlock = new BlockNode(array($try = new \PHPParser_Node_Stmt_TryCatch(array(), array($catch1 = new \PHPParser_Node_Stmt_Catch(new \PHPParser_Node_Name(array('Foo')), 'ex'), $catch2 = new \PHPParser_Node_Stmt_Catch(new \PHPParser_Node_Name(array('Bar')), 'ex'))), $echo = new \PHPParser_Node_Stmt_Echo(array(new \PHPParser_Node_Scalar_String('foo')))))));
     $tryBlock = $try->stmts = new BlockNode(array($throw = new \PHPParser_Node_Stmt_Throw(new \PHPParser_Node_Expr_Variable('foo'))));
     $catch1Block = $catch1->stmts = new BlockNode(array());
     $catch2Block = $catch2->stmts = new BlockNode(array());
     $callback = $this->getMock('Scrutinizer\\PhpAnalyzer\\PhpParser\\Traversal\\CallbackInterface');
     $t = new NodeTraversal($callback);
     $callback->expects($this->at(0))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $function, null)->will($this->returnValue(true));
     $callback->expects($this->at(1))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $functionBlock, $function)->will($this->returnValue(true));
     $callback->expects($this->at(2))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $try, $functionBlock)->will($this->returnValue(true));
     $callback->expects($this->at(3))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $tryBlock, $try)->will($this->returnValue(true));
     $callback->expects($this->at(4))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $throw, $tryBlock)->will($this->returnValue(false));
     $callback->expects($this->at(5))->method('visit')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $tryBlock, $try);
     $callback->expects($this->at(6))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $catch1, $try)->will($this->returnValue(true));
     $callback->expects($this->at(7))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $this->isInstanceOf('PHPParser_Node_Name'), $catch1)->will($this->returnValue(false));
     $callback->expects($this->at(8))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $catch1Block, $catch1)->will($this->returnValue(true));
     $callback->expects($this->at(9))->method('visit')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $catch1Block, $catch1);
     $callback->expects($this->at(10))->method('visit')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $catch1, $try);
     $callback->expects($this->at(11))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $catch2, $try)->will($this->returnValue(false));
     $callback->expects($this->at(12))->method('visit')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $try, $functionBlock);
     $callback->expects($this->at(13))->method('shouldTraverse')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $echo, $functionBlock)->will($this->returnValue(false));
     $callback->expects($this->at(14))->method('visit')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $functionBlock, $function);
     $callback->expects($this->at(15))->method('visit')->with($this->isInstanceOf('Scrutinizer\\PhpAnalyzer\\PhpParser\\NodeTraversal'), $function, null);
     $t->traverse($function);
 }