2011-07-13 23:07:05 +02:00
|
|
|
<?php
|
|
|
|
|
2011-08-10 11:13:37 +02:00
|
|
|
class PHPParser_Tests_NodeDumperTest extends PHPUnit_Framework_TestCase
|
2011-07-13 23:07:05 +02:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @dataProvider provideTestDump
|
|
|
|
*/
|
|
|
|
public function testDump($node, $dump) {
|
|
|
|
$nodeDumper = new PHPParser_NodeDumper;
|
|
|
|
|
|
|
|
$this->assertEquals($dump, $nodeDumper->dump($node));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function provideTestDump() {
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
array(),
|
|
|
|
'array(
|
|
|
|
)'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
array('Foo', 'Bar', 'Key' => 'FooBar'),
|
|
|
|
'array(
|
|
|
|
0: Foo
|
|
|
|
1: Bar
|
|
|
|
Key: FooBar
|
|
|
|
)'
|
|
|
|
),
|
|
|
|
array(
|
2011-08-09 14:55:45 +02:00
|
|
|
new PHPParser_Node_Name(array('Hallo', 'World')),
|
2011-07-13 23:07:05 +02:00
|
|
|
'Name(
|
|
|
|
parts: array(
|
|
|
|
0: Hallo
|
|
|
|
1: World
|
|
|
|
)
|
2011-08-09 14:55:45 +02:00
|
|
|
type: 0
|
2011-07-13 23:07:05 +02:00
|
|
|
)'
|
|
|
|
),
|
|
|
|
array(
|
2011-08-11 08:13:01 +02:00
|
|
|
new PHPParser_Node_Expr_Array(array(
|
|
|
|
new PHPParser_Node_Expr_ArrayItem(null, new PHPParser_Node_Scalar_String('Foo'))
|
|
|
|
)),
|
2011-07-13 23:07:05 +02:00
|
|
|
'Expr_Array(
|
|
|
|
items: array(
|
|
|
|
0: Expr_ArrayItem(
|
2011-08-11 08:13:01 +02:00
|
|
|
key: null
|
|
|
|
value: Scalar_String(
|
|
|
|
value: Foo
|
|
|
|
)
|
2011-07-13 23:07:05 +02:00
|
|
|
byRef: false
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)'
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|