mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-25 20:23:49 +01:00
use dataProvider
This commit is contained in:
parent
23cf8c65ea
commit
ce3dcd0251
@ -10,44 +10,46 @@ use Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\AbstractNodeTypeResolverTe
|
||||
*/
|
||||
final class AssignTypeResolverTest extends AbstractNodeTypeResolverTest
|
||||
{
|
||||
public function testNew(): void
|
||||
/**
|
||||
* @dataProvider provideTypeForNodesAndFilesData()
|
||||
* @param string[]
|
||||
*/
|
||||
public function test(string $file, int $nodePosition, array $expectedTypes): void
|
||||
{
|
||||
$variableNodes = $this->getNodesForFileOfType(__DIR__ . '/Source/MethodCall.php.inc', Variable::class);
|
||||
$variableNodes = $this->getNodesForFileOfType($file, Variable::class);
|
||||
|
||||
$this->assertSame(
|
||||
['Nette\Config\Configurator', 'Nette\Object'],
|
||||
$this->nodeTypeResolver->resolve($variableNodes[0])
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
['Nette\Config\Configurator', 'Nette\Object'],
|
||||
$this->nodeTypeResolver->resolve($variableNodes[2])
|
||||
);
|
||||
$this->assertSame($expectedTypes, $this->nodeTypeResolver->resolve($variableNodes[$nodePosition]));
|
||||
}
|
||||
|
||||
public function testNewTwo(): void
|
||||
/**
|
||||
* @return mixed[][]
|
||||
*/
|
||||
public function provideTypeForNodesAndFilesData(): array
|
||||
{
|
||||
$variableNodes = $this->getNodesForFileOfType(__DIR__ . '/Source/New.php.inc', Variable::class);
|
||||
|
||||
$this->assertSame(
|
||||
return [
|
||||
# assign of "new <name>"
|
||||
[__DIR__ . '/Source/MethodCall.php.inc', 0, ['Nette\Config\Configurator', 'Nette\Object']],
|
||||
[__DIR__ . '/Source/MethodCall.php.inc', 2, ['Nette\Config\Configurator', 'Nette\Object']],
|
||||
[__DIR__ . '/Source/New.php.inc', 0, [
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
$this->nodeTypeResolver->resolve($variableNodes[0])[0]
|
||||
);
|
||||
|
||||
$this->assertSame(
|
||||
'Symfony\Component\DependencyInjection\ResettableContainerInterface',
|
||||
'Symfony\Component\DependencyInjection\ContainerInterface',
|
||||
'Psr\Container\ContainerInterface',
|
||||
'Symfony\Component\DependencyInjection\TaggedContainerInterface',
|
||||
'Symfony\Component\DependencyInjection\Container',
|
||||
]],
|
||||
[__DIR__ . '/Source/New.php.inc', 1, [
|
||||
'Symfony\Component\DependencyInjection\ContainerBuilder',
|
||||
$this->nodeTypeResolver->resolve($variableNodes[1])[0]
|
||||
);
|
||||
}
|
||||
'Symfony\Component\DependencyInjection\ResettableContainerInterface',
|
||||
'Symfony\Component\DependencyInjection\ContainerInterface',
|
||||
'Psr\Container\ContainerInterface',
|
||||
'Symfony\Component\DependencyInjection\TaggedContainerInterface',
|
||||
'Symfony\Component\DependencyInjection\Container',
|
||||
]],
|
||||
# method call
|
||||
[__DIR__ . '/Source/MethodCall.php.inc', 1, ['Nette\DI\Container']],
|
||||
|
||||
public function testMethodCall(): void
|
||||
{
|
||||
$variableNodes = $this->getNodesForFileOfType(__DIR__ . '/Source/MethodCall.php.inc', Variable::class);
|
||||
|
||||
$this->assertSame(
|
||||
['Nette\DI\Container'],
|
||||
$this->nodeTypeResolver->resolve($variableNodes[1])
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
public function testMethodCallOnClassConstant(): void
|
||||
|
Loading…
x
Reference in New Issue
Block a user