1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-12-12 01:19:47 +01:00
PHP-Parser/test/PhpParser/PrettyPrinterTest.php

44 lines
1.3 KiB
PHP

<?php
namespace PhpParser;
require_once __DIR__ . '/CodeTestAbstract.php';
class PrettyPrinterTest extends CodeTestAbstract
{
protected function doTestPrettyPrintMethod($method, $name, $code, $dump) {
$parser = new Parser(new Lexer\Emulative);
$prettyPrinter = new PrettyPrinter\Standard;
$stmts = $parser->parse($code);
$this->assertEquals(
$this->canonicalize($dump),
$this->canonicalize($prettyPrinter->$method($stmts)),
$name
);
}
/**
* @dataProvider provideTestPrettyPrint
* @covers PrettyPrinter\Standard<extended>
*/
public function testPrettyPrint($name, $code, $dump) {
$this->doTestPrettyPrintMethod('prettyPrint', $name, $code, $dump);
}
/**
* @dataProvider provideTestPrettyPrintFile
* @covers PrettyPrinter\Standard<extended>
*/
public function testPrettyPrintFile($name, $code, $dump) {
$this->doTestPrettyPrintMethod('prettyPrintFile', $name, $code, $dump);
}
public function provideTestPrettyPrint() {
return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'test');
}
public function provideTestPrettyPrintFile() {
return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'file-test');
}
}