GetToConstructorInjectionRector - add test case for parent class with trait

This commit is contained in:
Tomas Votruba 2018-08-09 11:26:03 +02:00
parent f3348c84d8
commit 6e931c857c
11 changed files with 26 additions and 69 deletions

View File

@ -31,20 +31,24 @@ final class ClassAndInterfaceTypeResolverTest extends AbstractNodeTypeResolverTe
public function dataProvider(): Iterator public function dataProvider(): Iterator
{ {
// yield [__DIR__ . '/Source/ClassWithParentInterface.php', 0, [ yield [__DIR__ . '/Source/ClassWithParentInterface.php', 0, [
// ClassWithParentInterface::class, ClassWithParentInterface::class,
// SomeInterface::class, SomeInterface::class,
// ]]; ]];
//
// yield [__DIR__ . '/Source/ClassWithParentClass.php', 0, [
// ClassWithParentClass::class,
// ParentClass::class,
// ]];
// yield [__DIR__ . '/Source/ClassWithTrait.php', 0, [ClassWithTrait::class, AnotherTrait::class]]; yield [__DIR__ . '/Source/ClassWithParentClass.php', 0, [
ClassWithParentClass::class,
ParentClass::class,
]];
yield [__DIR__ . '/Source/ClassWithParentTrait.php', 0, [ClassWithParentTrait::class, ClassWithTrait::class, AnotherTrait::class]]; yield [__DIR__ . '/Source/ClassWithTrait.php', 0, [ClassWithTrait::class, AnotherTrait::class]];
// yield [__DIR__ . '/Source/AnonymousClass.php', 0, [ParentClass::class, SomeInterface::class]]; yield [
__DIR__ . '/Source/ClassWithParentTrait.php',
0,
[ClassWithParentTrait::class, ClassWithTrait::class, AnotherTrait::class],
];
yield [__DIR__ . '/Source/AnonymousClass.php', 0, [ParentClass::class, SomeInterface::class]];
} }
} }

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\ClassTypeResolver\Source;
new class extends ParentClass implements SomeInterface
{
use AnotherTrait;
};

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\ClassTypeResolver\Source;
trait AnotherTrait
{
}

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\ClassTypeResolver\Source;
final class ClassWithParentClass extends ParentClass
{
}

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\ClassTypeResolver\Source;
final class ClassWithParentInterface implements SomeInterface
{
}

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\ClassTypeResolver\Source;
final class ClassWithTrait
{
use AnotherTrait;
}

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\ClassTypeResolver\Source;
class ParentClass
{
}

View File

@ -1,8 +0,0 @@
<?php declare(strict_types=1);
namespace Rector\NodeTypeResolver\Tests\PerNodeTypeResolver\ClassTypeResolver\Source;
interface SomeInterface
{
}

View File

@ -12,7 +12,6 @@ class ClassWithNamedServiceAndParentTrait extends ParentClassWithGetTrait
{ {
$this->someTranslator = $someTranslator; $this->someTranslator = $someTranslator;
} }
public function render() public function render()
{ {
$this->someTranslator; $this->someTranslator;

View File

@ -30,6 +30,7 @@ final class GetToConstructorInjectionRectorTest extends AbstractRectorTestCase
yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc']; yield [__DIR__ . '/Wrong/wrong.php.inc', __DIR__ . '/Correct/correct.php.inc'];
yield [__DIR__ . '/Wrong/wrong2.php.inc', __DIR__ . '/Correct/correct2.php.inc']; yield [__DIR__ . '/Wrong/wrong2.php.inc', __DIR__ . '/Correct/correct2.php.inc'];
yield [__DIR__ . '/Wrong/wrong3.php.inc', __DIR__ . '/Correct/correct3.php.inc']; yield [__DIR__ . '/Wrong/wrong3.php.inc', __DIR__ . '/Correct/correct3.php.inc'];
yield [__DIR__ . '/Wrong/wrong4.php.inc', __DIR__ . '/Correct/correct4.php.inc'];
} }
protected function provideConfig(): string protected function provideConfig(): string

View File

@ -0,0 +1,9 @@
<?php declare(strict_types=1);
namespace Rector\Symfony\Tests\Rector\FrameworkBundle\GetToConstructorInjectionRector\Source;
class ParentClassWithGetTrait
{
use GetTrait;
}