mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-13 12:33:52 +01:00
fix 3rd party testing without config (#2140)
fix 3rd party testing without config
This commit is contained in:
commit
3612620637
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user