improve RectorFactory test and DeprecationDetector

This commit is contained in:
TomasVotruba 2017-09-07 15:57:20 +02:00
parent 6d2d12b9b7
commit 60e92328ca
2 changed files with 28 additions and 1 deletions

View File

@ -8,6 +8,7 @@ use PhpParser\Node\Expr\ConstFetch;
use PhpParser\Node\Expr\FuncCall;
use PhpParser\Node\Name;
use PhpParser\NodeVisitorAbstract;
use Rector\Node\Attribute;
use Rector\TriggerExtractor\Deprecation\DeprecationCollector;
use Rector\TriggerExtractor\Deprecation\DeprecationFactory;
@ -39,6 +40,10 @@ final class DeprecationDetector extends NodeVisitorAbstract
return;
}
// current scopde would be great
dump($node->getAttribute(Attribute::PARENT_NODE)->getParent);
die;
/** @var FuncCall $node */
$deprecation = $this->deprecationFactory->createFromNode($node->args[0]->value);

View File

@ -2,7 +2,9 @@
namespace Rector\TriggerExtractor\Tests\Rector;
use PHPUnit\Framework\Assert;
use Rector\Tests\AbstractContainerAwareTestCase;
use Rector\TriggerExtractor\Rector\ConfigurableChangeMethodNameRector;
use Rector\TriggerExtractor\Rector\RectorFactory;
use Rector\TriggerExtractor\TriggerExtractor;
@ -24,6 +26,26 @@ final class RectorFactoryTest extends AbstractContainerAwareTestCase
public function test(): void
{
$rectors = $this->rectorFactory->createRectors();
$this->assertCount(1, $rectors);
$this->assertCount(2, $rectors);
/** @var ConfigurableChangeMethodNameRector $firstRector */
$firstRector = $rectors[0];
$this->assertInstanceOf(ConfigurableChangeMethodNameRector::class, $firstRector);
$this->assertSame([
'Nette\DI\Definition' => [
'setClass' => 'setFactory'
]
], Assert::getObjectAttribute($firstRector, 'perClassOldToNewMethod'));
/** @var ConfigurableChangeMethodNameRector $secondRector */
$secondRector = $rectors[1];
$this->assertInstanceOf(ConfigurableChangeMethodNameRector::class, $secondRector);
$this->assertSame([
'Nette\DI\Definition' => [
'setInject' => 'addTag'
]
], Assert::getObjectAttribute($secondRector, 'perClassOldToNewMethod'));
}
}