1
0
mirror of https://github.com/danog/PHP-Parser.git synced 2024-11-27 04:14:44 +01:00
PHP-Parser/test/PhpParser/PrettyPrinterTest.php

44 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace PhpParser;
require_once __DIR__ . '/CodeTestAbstract.php';
class PrettyPrinterTest extends CodeTestAbstract
{
2013-04-15 20:53:23 +02:00
protected function doTestPrettyPrintMethod($method, $name, $code, $dump) {
$parser = new Parser(new Lexer\Emulative);
$prettyPrinter = new PrettyPrinter\Standard;
$stmts = $parser->parse($code);
2014-09-30 20:38:09 +02:00
$this->assertSame(
$this->canonicalize($dump),
2013-04-15 20:53:23 +02:00
$this->canonicalize($prettyPrinter->$method($stmts)),
$name
);
}
2013-04-15 20:53:23 +02:00
/**
* @dataProvider provideTestPrettyPrint
2014-09-28 12:48:55 +02:00
* @covers PhpParser\PrettyPrinter\Standard<extended>
2013-04-15 20:53:23 +02:00
*/
public function testPrettyPrint($name, $code, $dump) {
$this->doTestPrettyPrintMethod('prettyPrint', $name, $code, $dump);
}
/**
* @dataProvider provideTestPrettyPrintFile
2014-09-28 12:48:55 +02:00
* @covers PhpParser\PrettyPrinter\Standard<extended>
2013-04-15 20:53:23 +02:00
*/
public function testPrettyPrintFile($name, $code, $dump) {
$this->doTestPrettyPrintMethod('prettyPrintFile', $name, $code, $dump);
}
public function provideTestPrettyPrint() {
return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'test');
}
2013-04-15 20:53:23 +02:00
public function provideTestPrettyPrintFile() {
return $this->getTests(__DIR__ . '/../code/prettyPrinter', 'file-test');
2013-04-15 20:53:23 +02:00
}
}