[Architecture] Add failing test for #700

This commit is contained in:
Tomas Votruba 2018-10-16 20:53:22 +08:00
parent dbdf0b82cf
commit 86614bba3a
4 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,17 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeInterface;
use JMS\DiExtraBundle\Annotation as DI;
class ClassWithInjects7
{
/**
* @var SomeInterface
*/
private $session;
public function __construct(SomeInterface $session)
{
$this->session = $session;
}
}

View File

@ -0,0 +1,30 @@
<?php declare(strict_types=1);
namespace Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector;
use Iterator;
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
/**
* @covers \Rector\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector
*/
final class JmsRectorTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideWrongToFixedFiles()
*/
public function test(string $wrong, string $fixed): void
{
$this->doTestFileMatchesExpectedContent($wrong, $fixed);
}
public function provideWrongToFixedFiles(): Iterator
{
yield [__DIR__ . '/Wrong/wrong7.php.inc', __DIR__ . '/Correct/correct7.php.inc'];
}
protected function provideConfig(): string
{
return __DIR__ . '/jms-config.yml';
}
}

View File

@ -0,0 +1,13 @@
<?php declare(strict_types=1);
use Rector\Tests\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector\Source\SomeInterface;
use JMS\DiExtraBundle\Annotation as DI;
class ClassWithInjects7
{
/**
* @var SomeInterface
* @DI\Inject("irelevant")
*/
private $session;
}

View File

@ -0,0 +1,3 @@
services:
Rector\Rector\Architecture\DependencyInjection\AnnotatedPropertyInjectToConstructorInjectionRector:
$annotation: 'JMS\DiExtraBundle\Annotation\Inject'