mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-23 11:14:38 +01:00
The change of permissions is not explicitely requested by the user and is not shown in the dry-run. It makes Rector harder to use when the sources of a project has some executable scripts.
43 lines
1.2 KiB
PHP
43 lines
1.2 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace Rector\Tests\PhpParser\Printer;
|
|
|
|
use Nette\Utils\FileSystem;
|
|
use Rector\HttpKernel\RectorKernel;
|
|
use Rector\PhpParser\Printer\FormatPerservingPrinter;
|
|
use Symplify\PackageBuilder\FileSystem\SmartFileInfo;
|
|
use Symplify\PackageBuilder\Tests\AbstractKernelTestCase;
|
|
|
|
final class FormatPerservingPrinterTest extends AbstractKernelTestCase
|
|
{
|
|
/**
|
|
* @var FormatPerservingPrinter
|
|
*/
|
|
private $formatPerservingPrinter;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->bootKernel(RectorKernel::class);
|
|
$this->formatPerservingPrinter = self::$container->get(FormatPerservingPrinter::class);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
FileSystem::delete(__DIR__ . '/Fixture');
|
|
}
|
|
|
|
public function testFileModeIsPreserved(): void
|
|
{
|
|
mkdir(__DIR__ . '/Fixture');
|
|
touch(__DIR__ . '/Fixture/file.php');
|
|
$expectedFilemod = 0755;
|
|
chmod(__DIR__ . '/Fixture/file.php', $expectedFilemod);
|
|
|
|
$fileInfo = new SmartFileInfo(__DIR__ . '/Fixture/file.php');
|
|
|
|
$this->formatPerservingPrinter->printToFile($fileInfo, [], [], []);
|
|
|
|
$this->assertSame($expectedFilemod, fileperms(__DIR__ . '/Fixture/file.php') & 0777);
|
|
}
|
|
}
|