mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit b107a16f98aecf2a5ff969e30ff48595daadc06d
b107a16f98
[Performance] Reduce repetitive FileSystem::read() on AbstractRectorTestCase (#5511)
This commit is contained in:
parent
6752d80c19
commit
e47a59adcc
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '63fbf41cc9a6cc66c720926beec4603892eb21d0';
|
||||
public const PACKAGE_VERSION = 'b107a16f98aecf2a5ff969e30ff48595daadc06d';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-01-28 00:52:19';
|
||||
public const RELEASE_DATE = '2024-01-28 10:48:07';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -134,7 +134,7 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractLa
|
||||
}
|
||||
// write temp file
|
||||
FileSystem::write($inputFilePath, $inputFileContents);
|
||||
$this->doTestFileMatchesExpectedContent($inputFilePath, $expectedFileContents, $fixtureFilePath);
|
||||
$this->doTestFileMatchesExpectedContent($inputFilePath, $inputFileContents, $expectedFileContents, $fixtureFilePath);
|
||||
}
|
||||
protected function forgetRectorsRulesAndCollectors() : void
|
||||
{
|
||||
@ -169,11 +169,9 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractLa
|
||||
require_once __DIR__ . '/../../../vendor/scoper-autoload.php';
|
||||
}
|
||||
}
|
||||
private function doTestFileMatchesExpectedContent(string $originalFilePath, string $expectedFileContents, string $fixtureFilePath) : void
|
||||
private function doTestFileMatchesExpectedContent(string $originalFilePath, string $inputFileContents, string $expectedFileContents, string $fixtureFilePath) : void
|
||||
{
|
||||
SimpleParameterProvider::setParameter(Option::SOURCE, [$originalFilePath]);
|
||||
// the original file content must be loaded first
|
||||
$originalFileContent = FileSystem::read($originalFilePath);
|
||||
// the file is now changed (if any rule matches)
|
||||
$rectorTestResult = $this->processFilePath($originalFilePath);
|
||||
$changedContents = $rectorTestResult->getChangedContents();
|
||||
@ -190,7 +188,7 @@ abstract class AbstractRectorTestCase extends \Rector\Testing\PHPUnit\AbstractLa
|
||||
try {
|
||||
$this->assertSame($expectedFileContents, $changedContents, $failureMessage);
|
||||
} catch (ExpectationFailedException $exception) {
|
||||
FixtureFileUpdater::updateFixtureContent($originalFileContent, $changedContents, $fixtureFilePath);
|
||||
FixtureFileUpdater::updateFixtureContent($inputFileContents, $changedContents, $fixtureFilePath);
|
||||
// if not exact match, check the regex version (useful for generated hashes/uuids in the code)
|
||||
$this->assertStringMatchesFormat($expectedFileContents, $changedContents, $failureMessage);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user