remove SplitLine value object

This commit is contained in:
TomasVotruba 2020-07-30 16:35:32 +02:00
parent 2291d5540a
commit ce480d3983
4 changed files with 9 additions and 21 deletions

View File

@ -12,7 +12,6 @@ use Rector\Core\Contract\Rector\PhpRectorInterface;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Testing\Contract\RunnableInterface;
use Rector\Core\Testing\PHPUnit\DataProvider\StaticFixtureUpdater;
use Rector\Core\Testing\ValueObject\SplitLine;
use Rector\Core\ValueObject\StaticNonPhpFileSuffixes;
use Symplify\EasyTesting\StaticFixtureSplitter;
use Symplify\SmartFileSystem\SmartFileInfo;

View File

@ -13,8 +13,11 @@ use Symplify\SmartFileSystem\SmartFileSystem;
*/
final class StaticFixtureUpdater
{
public static function updateFixtureContent(SmartFileInfo $originalFileInfo, string $changedContent, SmartFileInfo $fixtureFileInfo): void
{
public static function updateFixtureContent(
SmartFileInfo $originalFileInfo,
string $changedContent,
SmartFileInfo $fixtureFileInfo
): void {
if (! getenv('UPDATE_TESTS') && ! getenv('UT')) {
return;
}
@ -37,5 +40,4 @@ final class StaticFixtureUpdater
{
return new SmartFileSystem();
}
}

View File

@ -1,13 +0,0 @@
<?php
declare(strict_types=1);
namespace Rector\Core\Testing\ValueObject;
final class SplitLine
{
/**
* @var string
*/
public const REGEX = "#-----\r?\n#";
}

View File

@ -5,12 +5,13 @@ declare(strict_types=1);
namespace Rector\Utils\ProjectValidator\Command;
use Nette\Utils\Strings;
use Rector\Core\Testing\ValueObject\SplitLine;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Finder\Finder;
use Symplify\EasyTesting\StaticFixtureSplitter;
use Symplify\EasyTesting\ValueObject\SplitLine;
use Symplify\PackageBuilder\Console\Command\CommandNaming;
use Symplify\PackageBuilder\Console\ShellCode;
use Symplify\SmartFileSystem\Finder\FinderSanitizer;
@ -87,13 +88,12 @@ final class ValidateFixtureContentCommand extends Command
private function hasFileIdenticalCodeBeforeAndAfter(SmartFileInfo $smartFileInfo): bool
{
$contents = $smartFileInfo->getContents();
if (! Strings::match($contents, SplitLine::REGEX)) {
if (! Strings::match($smartFileInfo->getContents(), SplitLine::SPLIT_LINE)) {
return false;
}
// original → expected
[$originalContent, $expectedContent] = Strings::split($contents, SplitLine::REGEX);
[$originalContent, $expectedContent] = StaticFixtureSplitter::splitFileInfoToInputAndExpected($smartFileInfo);
return $originalContent === $expectedContent;
}