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
47e7ecca57
commit
575a408963
@ -10,51 +10,33 @@ use Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\AbstractNodeTypeResolverTe
|
|||||||
*/
|
*/
|
||||||
final class VariableTypeResolverTest extends AbstractNodeTypeResolverTest
|
final class VariableTypeResolverTest extends AbstractNodeTypeResolverTest
|
||||||
{
|
{
|
||||||
public function testThis(): void
|
/**
|
||||||
|
* @dataProvider provideTypeForNodesAndFilesData()
|
||||||
|
* @param string[]
|
||||||
|
*/
|
||||||
|
public function testCallbackArgumentTypehint(string $file, int $position, array $expectedTypes): void
|
||||||
{
|
{
|
||||||
$variableNodes = $this->getNodesForFileOfType(__DIR__ . '/Source/This.php.inc', Variable::class);
|
$variableNodes = $this->getNodesForFileOfType($file, Variable::class);
|
||||||
|
|
||||||
$this->assertSame(
|
$this->assertSame($expectedTypes, $this->nodeTypeResolver->resolve($variableNodes[$position]));
|
||||||
['SomeNamespace\SomeClass', 'SomeNamespace\AnotherClass'],
|
|
||||||
$this->nodeTypeResolver->resolve($variableNodes[0])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNew(): void
|
/**
|
||||||
|
* @return mixed[][]
|
||||||
|
*/
|
||||||
|
public function provideTypeForNodesAndFilesData(): array
|
||||||
{
|
{
|
||||||
$variableNodes = $this->getNodesForFileOfType(__DIR__ . '/Source/SomeClass.php.inc', Variable::class);
|
return [
|
||||||
|
# this
|
||||||
$this->assertSame(
|
[__DIR__ . '/Source/This.php.inc', 0, ['SomeNamespace\SomeClass', 'SomeNamespace\AnotherClass']],
|
||||||
['SomeNamespace\AnotherType'],
|
# new
|
||||||
$this->nodeTypeResolver->resolve($variableNodes[0])
|
[__DIR__ . '/Source/SomeClass.php.inc', 0, ['SomeNamespace\AnotherType']],
|
||||||
);
|
[__DIR__ . '/Source/SomeClass.php.inc', 2, ['SomeNamespace\AnotherType']],
|
||||||
$this->assertSame(
|
# assignment
|
||||||
['SomeNamespace\AnotherType'],
|
[__DIR__ . '/Source/SomeClass.php.inc', 1, ['SomeNamespace\AnotherType']],
|
||||||
$this->nodeTypeResolver->resolve($variableNodes[2])
|
# callback arguments
|
||||||
);
|
[__DIR__ . '/Source/ArgumentTypehint.php.inc', 0, ['SomeNamespace\UseUse']],
|
||||||
}
|
[__DIR__ . '/Source/ArgumentTypehint.php.inc', 1, ['SomeNamespace\UseUse']],
|
||||||
|
];
|
||||||
public function testAssign(): void
|
|
||||||
{
|
|
||||||
$variableNodes = $this->getNodesForFileOfType(__DIR__ . '/Source/SomeClass.php.inc', Variable::class);
|
|
||||||
|
|
||||||
$this->assertSame(
|
|
||||||
['SomeNamespace\AnotherType'],
|
|
||||||
$this->nodeTypeResolver->resolve($variableNodes[1])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCallbackArgumentTypehint(): void
|
|
||||||
{
|
|
||||||
$variableNodes = $this->getNodesForFileOfType(__DIR__ . '/Source/ArgumentTypehint.php.inc', Variable::class);
|
|
||||||
|
|
||||||
$this->assertSame(
|
|
||||||
['SomeNamespace\UseUse'],
|
|
||||||
$this->nodeTypeResolver->resolve($variableNodes[0])
|
|
||||||
);
|
|
||||||
$this->assertSame(
|
|
||||||
['SomeNamespace\UseUse'],
|
|
||||||
$this->nodeTypeResolver->resolve($variableNodes[1])
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user