Test PhpFileCleaner
continuous-integration/drone/push Build is passing Details

Hugo Thunnissen 2 years ago
parent 50e452dea9
commit 3df2939896

@ -0,0 +1,57 @@
<?php declare(strict_types=1);
namespace Composer\Test\Autoload;
use Composer\Autoload\PhpFileCleaner;
use Composer\Test\TestCase;
class PhpFileCleanerTest extends TestCase
{
public function cleanProvider(): array
{
return [
[
'<html> baanaan <?php class hey implements ha {'.PHP_EOL.
'function heoei() {'.PHP_EOL.'//kaas'.PHP_EOL.'/*geenkaas*/}'.PHP_EOL.'}?> '.PHP_EOL.'<body>appeltaart</body></html>',
'<?php class hey implements ha {'.PHP_EOL.'function heoei() {'.PHP_EOL.
PHP_EOL.'}'.PHP_EOL.'}?><?'
],
[
'<? function () {'.PHP_EOL.'// looperino '.PHP_EOL.'foreach($things as $thing) {'
.PHP_EOL.'/** '.PHP_EOL.'multi-line comments '.PHP_EOL.'*/'.PHP_EOL.'} '.PHP_EOL.'}',
'<? function () {'.PHP_EOL.PHP_EOL.'foreach($things as $thing) {'
.PHP_EOL.PHP_EOL.'} '.PHP_EOL.'}',
],
[
'<? function () {'.PHP_EOL.'return "double-quote string"; }',
'<? function () {'.PHP_EOL.'return null; }'
],
[
'<? function () {'.PHP_EOL.'return "double-quote with \\" escaped quote"; }',
'<? function () {'.PHP_EOL.'return null; }'
],
[
'<? function () {'.PHP_EOL.'return \'single-quote string\'; }',
'<? function () {'.PHP_EOL.'return null; }'
],
[
'<? function () {'.PHP_EOL.'return \'single-quote with \\\' escaped quote\'; }',
'<? function () {'.PHP_EOL.'return null; }'
]
];
}
/**
* @dataProvider cleanProvider
*/
public function testClean(string $input, string $expected): void
{
$cleaner = new PhpFileCleaner($input, 0);
$result = $cleaner->clean($expected);
$this->assertEquals($expected, $result);
}
}
Loading…
Cancel
Save