[Testing] Fixing MultipleFilesChangedTrait under macOs (#605)

* [Testing] Fixing mMultipleFilesChangedTrait under macOs

* final touch

* [ci-review] Rector Rectify

* [ci-review] Rector Rectify

* use relative path as key

Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
Abdul Malik Ikhsan 2021-08-07 03:02:18 +07:00 committed by GitHub
parent bb384013c3
commit d4d2e7a4d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 3 deletions

View File

@ -76,12 +76,21 @@ trait MultipleFilesChangedTrait
$addedFilesWithContent = $this->removedAndAddedFilesCollector->getAddedFilesWithContent();
$addedFiles = [];
foreach ($addedFilesWithContent as $addedFileWithContent) {
$addedFiles[$addedFileWithContent->getFilePath()] = $addedFileWithContent;
[, $addedFilePathWithContentFilePath] = explode(
'_temp_fixture_easy_testing',
$addedFileWithContent->getFilePath()
);
$addedFiles[$addedFilePathWithContentFilePath] = $addedFileWithContent;
}
foreach ($expectedFileChanges as $path => $expectedFileChange) {
$addedFile = $addedFiles[$path] ?? null;
$this->assertSame($path, $addedFile ? $addedFile->getFilePath() : null);
[, $relativePath] = explode('_temp_fixture_easy_testing', $path);
$addedFile = $addedFiles[$relativePath] ?? null;
[, $addedFilePathWithContentFilePath] = $addedFile
? explode('_temp_fixture_easy_testing', $addedFile->getFilePath())
: null;
$this->assertSame($relativePath, $addedFilePathWithContentFilePath);
$realFileContent = $addedFile ? trim($addedFile->getFileContent()) : null;
$this->assertSame($expectedFileChange, $realFileContent);
if (file_exists($path)) {