php-parser/test/PHPParser/Tests/NodeDumperTest.php

66 lines
1.4 KiB
PHP
Raw Normal View History

2011-07-13 23:07:05 +02:00
<?php
class PHPParser_Tests_NodeDumperTest extends PHPUnit_Framework_TestCase
2011-07-13 23:07:05 +02:00
{
/**
* @dataProvider provideTestDump
* @covers PHPParser_NodeDumper::dump
2011-07-13 23:07:05 +02:00
*/
public function testDump($node, $dump) {
2011-11-27 21:43:27 +01:00
$dumper = new PHPParser_NodeDumper;
2011-07-13 23:07:05 +02:00
2011-11-27 21:43:27 +01:00
$this->assertEquals($dump, $dumper->dump($node));
2011-07-13 23:07:05 +02:00
}
public function provideTestDump() {
return array(
array(
array(),
'array(
)'
),
array(
array('Foo', 'Bar', 'Key' => 'FooBar'),
'array(
0: Foo
1: Bar
Key: FooBar
)'
),
array(
new PHPParser_Node_Name(array('Hallo', 'World')),
2011-07-13 23:07:05 +02:00
'Name(
parts: array(
0: Hallo
1: World
)
)'
),
array(
new PHPParser_Node_Expr_Array(array(
2011-09-02 19:49:46 +02:00
new PHPParser_Node_Expr_ArrayItem(new PHPParser_Node_Scalar_String('Foo'))
)),
2011-07-13 23:07:05 +02:00
'Expr_Array(
items: array(
0: Expr_ArrayItem(
key: null
value: Scalar_String(
value: Foo
)
2011-07-13 23:07:05 +02:00
byRef: false
)
)
)'
),
);
}
2011-11-27 21:43:27 +01:00
/**
* @expectedException InvalidArgumentException
* @expectedExceptionMessage Can only dump nodes and arrays.
*/
public function testError() {
$dumper = new PHPParser_NodeDumper;
$dumper->dump(new stdClass);
}
2011-07-13 23:07:05 +02:00
}