mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-10 21:22:21 +00:00
fix tests by making paramter provider aware of source
This commit is contained in:
parent
aa1d9c0f6c
commit
bb7225c625
|
@ -4,14 +4,15 @@ namespace Rector\Testing\PHPUnit;
|
|||
|
||||
use Rector\Application\FileProcessor;
|
||||
use Rector\DependencyInjection\ContainerFactory;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
|
||||
abstract class AbstractConfigurableRectorTestCase extends AbstractRectorTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->container = (new ContainerFactory())->createWithConfig($this->provideConfig());
|
||||
|
||||
$this->fileProcessor = $this->container->get(FileProcessor::class);
|
||||
$this->parameterProvider = $this->container->get(ParameterProvider::class);
|
||||
}
|
||||
|
||||
abstract protected function provideConfig(): string;
|
||||
|
|
|
@ -8,6 +8,7 @@ use Rector\Application\FileProcessor;
|
|||
use Rector\DependencyInjection\ContainerFactory;
|
||||
use Rector\FileSystem\FileGuard;
|
||||
use SplFileInfo;
|
||||
use Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
|
||||
abstract class AbstractRectorTestCase extends TestCase
|
||||
{
|
||||
|
@ -21,11 +22,16 @@ abstract class AbstractRectorTestCase extends TestCase
|
|||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @var ParameterProvider
|
||||
*/
|
||||
protected $parameterProvider;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->container = (new ContainerFactory())->createWithConfig(__DIR__ . '/../../config/levels.yml');
|
||||
|
||||
$this->fileProcessor = $this->container->get(FileProcessor::class);
|
||||
$this->parameterProvider = $this->container->get(ParameterProvider::class);
|
||||
}
|
||||
|
||||
protected function doTestFileMatchesExpectedContent(string $file, string $reconstructedFile): void
|
||||
|
@ -33,6 +39,8 @@ abstract class AbstractRectorTestCase extends TestCase
|
|||
FileGuard::ensureFileExists($file, get_called_class());
|
||||
FileGuard::ensureFileExists($reconstructedFile, get_called_class());
|
||||
|
||||
$this->parameterProvider->changeParameter('source', [$file]);
|
||||
|
||||
$reconstructedFileContent = $this->fileProcessor->processFileWithRectorsToString(
|
||||
new SplFileInfo($file),
|
||||
$this->getRectorClasses()
|
||||
|
|
|
@ -2,7 +2,7 @@ rectors:
|
|||
Rector\Rector\Contrib\Nette\Environment\GetServiceToConstructorInjectionRector: ~
|
||||
|
||||
services:
|
||||
Rector\Tests\Rector\Contrib\Nette\Environment\GetServiceToConstructorInjectionRector\Source\DummyProvider:
|
||||
Rector\Tests\Rector\Contrib\Nette\Environment\GetServiceToConstructorInjectionRector\Source\DummyProvider: ~
|
||||
|
||||
# require for interface autowiring
|
||||
Rector\Contract\Bridge\ServiceTypeForNameProviderInterface:
|
||||
|
|
Loading…
Reference in New Issue
Block a user