fix 3rd party testing without config (#2140)

fix 3rd party testing without config
This commit is contained in:
Tomáš Votruba 2019-10-10 22:31:24 +01:00 committed by GitHub
commit 3612620637
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -76,7 +76,9 @@ abstract class AbstractRectorTestCase extends AbstractGenericRectorTestCase
self::$container = self::$allRectorContainer;
}
} else {
$this->bootKernelWithConfigs(RectorKernel::class, [$this->provideConfig()]);
// 3rd party
$configFileTempPath = $this->getConfigFor3rdPartyTest();
$this->bootKernelWithConfigs(RectorKernel::class, [$configFileTempPath]);
}
$enabledRectorsProvider = self::$container->get(EnabledRectorsProvider::class);
@ -234,4 +236,21 @@ abstract class AbstractRectorTestCase extends AbstractGenericRectorTestCase
$this->setParameter(Option::PHP_VERSION_FEATURES, $this->getPhpVersion());
}
private function getConfigFor3rdPartyTest(): string
{
if ($this->provideConfig() !== '') {
return $this->provideConfig();
}
$rectorClassWithConfiguration = $this->getCurrentTestRectorClassesWithConfiguration();
$yamlContent = Yaml::dump([
'services' => $rectorClassWithConfiguration,
], Yaml::DUMP_OBJECT_AS_MAP);
$configFileTempPath = sprintf(sys_get_temp_dir() . '/rector_temp_tests/current_test.yaml');
FileSystem::write($configFileTempPath, $yamlContent);
return $configFileTempPath;
}
}