1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-04 02:07:59 +01:00
PHP-Parser/test/PhpParser/NodeDumperTest.php

68 lines
1.4 KiB
PHP
Raw Normal View History

2011-07-13 23:07:05 +02:00
<?php
namespace PhpParser;
class NodeDumperTest extends \PHPUnit_Framework_TestCase
2011-07-13 23:07:05 +02:00
{
/**
* @dataProvider provideTestDump
* @covers NodeDumper::dump
2011-07-13 23:07:05 +02:00
*/
public function testDump($node, $dump) {
$dumper = new 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 Node\Name(array('Hallo', 'World')),
2011-07-13 23:07:05 +02:00
'Name(
parts: array(
0: Hallo
1: World
)
)'
),
array(
new Node\Expr\Array_(array(
new Node\Expr\ArrayItem(new 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
2011-11-27 21:43:27 +01:00
* @expectedExceptionMessage Can only dump nodes and arrays.
*/
public function testError() {
$dumper = new NodeDumper;
$dumper->dump(new \stdClass);
2011-11-27 21:43:27 +01:00
}
2011-07-13 23:07:05 +02:00
}