2012-05-11 16:18:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once dirname(__FILE__) . '/CodeTestAbstract.php';
|
|
|
|
|
|
|
|
class PHPParser_Tests_PrettyPrinterTest extends PHPParser_Tests_CodeTestAbstract
|
|
|
|
{
|
2013-04-15 20:53:23 +02:00
|
|
|
protected function doTestPrettyPrintMethod($method, $name, $code, $dump) {
|
2012-05-11 16:18:14 +02:00
|
|
|
$parser = new PHPParser_Parser(new PHPParser_Lexer_Emulative);
|
2013-01-15 17:43:36 +01:00
|
|
|
$prettyPrinter = new PHPParser_PrettyPrinter_Default;
|
2012-05-11 16:18:14 +02:00
|
|
|
|
|
|
|
$stmts = $parser->parse($code);
|
|
|
|
$this->assertEquals(
|
|
|
|
$this->canonicalize($dump),
|
2013-04-15 20:53:23 +02:00
|
|
|
$this->canonicalize($prettyPrinter->$method($stmts)),
|
2012-05-11 16:18:14 +02:00
|
|
|
$name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-04-15 20:53:23 +02:00
|
|
|
/**
|
|
|
|
* @dataProvider provideTestPrettyPrint
|
|
|
|
* @covers PHPParser_PrettyPrinter_Default<extended>
|
|
|
|
*/
|
|
|
|
public function testPrettyPrint($name, $code, $dump) {
|
|
|
|
$this->doTestPrettyPrintMethod('prettyPrint', $name, $code, $dump);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider provideTestPrettyPrintFile
|
|
|
|
* @covers PHPParser_PrettyPrinter_Default<extended>
|
|
|
|
*/
|
|
|
|
public function testPrettyPrintFile($name, $code, $dump) {
|
|
|
|
$this->doTestPrettyPrintMethod('prettyPrintFile', $name, $code, $dump);
|
|
|
|
}
|
|
|
|
|
2012-05-11 16:18:14 +02:00
|
|
|
public function provideTestPrettyPrint() {
|
|
|
|
return $this->getTests(dirname(__FILE__) . '/../../code/prettyPrinter', 'test');
|
|
|
|
}
|
2013-04-15 20:53:23 +02:00
|
|
|
|
|
|
|
public function provideTestPrettyPrintFile() {
|
|
|
|
return $this->getTests(dirname(__FILE__) . '/../../code/prettyPrinter', 'file-test');
|
|
|
|
}
|
2012-05-11 16:18:14 +02:00
|
|
|
}
|