mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-01 08:50:50 +00:00
7ba32aac1f
e12c73eb33
[psr-4] Move tests to main namespace, as part of /src and /packages merge - step 2 (#5407)
28 lines
864 B
PHP
28 lines
864 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Testing\Fixture;
|
|
|
|
use RectorPrefix202401\Nette\Utils\FileSystem;
|
|
final class FixtureFileUpdater
|
|
{
|
|
/**
|
|
* @api
|
|
*/
|
|
public static function updateFixtureContent(string $originalContent, string $changedContent, string $fixtureFilePath) : void
|
|
{
|
|
if (!\getenv('UPDATE_TESTS') && !\getenv('UT')) {
|
|
return;
|
|
}
|
|
$newOriginalContent = self::resolveNewFixtureContent($originalContent, $changedContent);
|
|
FileSystem::write($fixtureFilePath, $newOriginalContent);
|
|
}
|
|
private static function resolveNewFixtureContent(string $originalContent, string $changedContent) : string
|
|
{
|
|
if ($originalContent === $changedContent) {
|
|
return $originalContent;
|
|
}
|
|
return $originalContent . '-----' . \PHP_EOL . $changedContent;
|
|
}
|
|
}
|