Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] Reduce IO on AbstractRectorTestCase take 2 #3671

Merged
merged 2 commits into from
Apr 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/Testing/PHPUnit/AbstractRectorTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected function doTestFile(string $fixtureFilePath): void
// write temp file
FileSystem::write($inputFilePath, $inputFileContents);

$this->doTestFileMatchesExpectedContent($inputFilePath, $expectedFileContents, $fixtureFilePath);
$this->doTestFileMatchesExpectedContent($inputFilePath, $inputFileContents, $expectedFileContents, $fixtureFilePath);
}

private function includePreloadFilesAndScoperAutoload(): void
Expand All @@ -146,12 +146,13 @@ private function includePreloadFilesAndScoperAutoload(): void

private function doTestFileMatchesExpectedContent(
string $originalFilePath,
string $inputFileContents,
string $expectedFileContents,
string $fixtureFilePath
): void {
$this->parameterProvider->changeParameter(Option::SOURCE, [$originalFilePath]);

$changedContent = $this->processFilePath($originalFilePath);
$changedContent = $this->processFilePath($originalFilePath, $inputFileContents);

// file is removed, we cannot compare it
if ($this->removedAndAddedFilesCollector->isFileRemoved($originalFilePath)) {
Expand All @@ -171,7 +172,7 @@ private function doTestFileMatchesExpectedContent(
}
}

private function processFilePath(string $filePath): string
private function processFilePath(string $filePath, string $inputFileContents): string
{
$this->dynamicSourceLocatorProvider->setFilePath($filePath);

Expand All @@ -184,7 +185,7 @@ private function processFilePath(string $filePath): string
$configurationFactory = $this->getService(ConfigurationFactory::class);
$configuration = $configurationFactory->createForTests([$filePath]);

$file = new File($filePath, FileSystem::read($filePath));
$file = new File($filePath, $inputFileContents);
$this->applicationFileProcessor->processFiles([$file], $configuration);

return $file->getFileContent();
Expand Down