diff --git a/composer.json b/composer.json index e02eaf63de5..d55e49e0cf1 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,6 @@ "symplify/easy-parallel": "^11.1", "symplify/package-builder": "dev-main", "symplify/rule-doc-generator-contracts": "^11.1", - "symplify/smart-file-system": "^11.1", "webmozart/assert": "^1.11" }, "require-dev": { diff --git a/packages/Testing/Fixture/FixtureTempFileDumper.php b/packages/Testing/Fixture/FixtureTempFileDumper.php index ae37cf216a3..0a6b8b9acd6 100644 --- a/packages/Testing/Fixture/FixtureTempFileDumper.php +++ b/packages/Testing/Fixture/FixtureTempFileDumper.php @@ -15,9 +15,14 @@ final class FixtureTempFileDumper public static function dump(string $fileContents, string $suffix = 'php'): string { // the "php" suffix is important, because that will hook into \Rector\Core\Application\FileProcessor\PhpFileProcessor - $temporaryFileName = sys_get_temp_dir() . self::TEMP_FIXTURE_DIRECTORY . '/' . md5($fileContents) . '.' . $suffix; + $temporaryFileName = self::getTempDirectory() . '/' . md5($fileContents) . '.' . $suffix; FileSystem::write($temporaryFileName, $fileContents); return $temporaryFileName; } + + public static function getTempDirectory(): string + { + return sys_get_temp_dir() . self::TEMP_FIXTURE_DIRECTORY; + } } diff --git a/packages/Testing/PHPUnit/AbstractRectorTestCase.php b/packages/Testing/PHPUnit/AbstractRectorTestCase.php index 7a8394be5a6..2e6f76870e2 100644 --- a/packages/Testing/PHPUnit/AbstractRectorTestCase.php +++ b/packages/Testing/PHPUnit/AbstractRectorTestCase.php @@ -139,7 +139,7 @@ protected function doTestFileInfo(SmartFileInfo $fixtureFileInfo): void protected function getFixtureTempDirectory(): string { - return sys_get_temp_dir() . FixtureTempFileDumper::TEMP_FIXTURE_DIRECTORY; + return FixtureTempFileDumper::getTempDirectory(); } private function resolveExpectedContents(string $filePath): string @@ -147,7 +147,7 @@ private function resolveExpectedContents(string $filePath): string $contents = FileSystem::read($filePath); // make sure we don't get a diff in which every line is different (because of differences in EOL) - return $this->normalizeNewlines($contents); + return str_replace("\r\n", "\n", $contents); } private function resolveOriginalFixtureFileSuffix(string $filePath): string @@ -205,11 +205,6 @@ private function doTestFileMatchesExpectedContent( } } - private function normalizeNewlines(string $string): string - { - return str_replace("\r\n", "\n", $string); - } - private function processFilePath(string $filePath): string { $this->dynamicSourceLocatorProvider->setFilePath($filePath); diff --git a/packages/Testing/PHPUnit/AbstractTestCase.php b/packages/Testing/PHPUnit/AbstractTestCase.php index b9bc793d478..2fc9666c31a 100644 --- a/packages/Testing/PHPUnit/AbstractTestCase.php +++ b/packages/Testing/PHPUnit/AbstractTestCase.php @@ -53,7 +53,7 @@ protected function bootFromConfigFiles(array $configFiles): void protected function getService(string $type): object { if (self::$currentContainer === null) { - throw new ShouldNotHappenException('First, create container with "bootWithConfigFileInfos([...])"'); + throw new ShouldNotHappenException('First, create container with "boot()" or "bootWithConfigFileInfos([...])"'); } $object = self::$currentContainer->get($type);