mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-02 09:20:52 +00:00
cleanup and move
This commit is contained in:
parent
c1b4084d3b
commit
74789aee46
|
@ -1,51 +0,0 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Rector\Contrib\PHPUnit;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\Rector\AbstractPHPUnitRector;
|
||||
use Rector\ReflectionDocBlock\NodeAnalyzer\DocBlockAnalyzer;
|
||||
|
||||
/**
|
||||
* Before:
|
||||
* - @scenario
|
||||
*
|
||||
* After:
|
||||
* - @test
|
||||
*/
|
||||
final class ScenarioToTestAnnotationRector extends AbstractPHPUnitRector
|
||||
{
|
||||
/**
|
||||
* @var DocBlockAnalyzer
|
||||
*/
|
||||
private $docBlockAnalyzer;
|
||||
|
||||
public function __construct(DocBlockAnalyzer $docBlockAnalyzer)
|
||||
{
|
||||
$this->docBlockAnalyzer = $docBlockAnalyzer;
|
||||
}
|
||||
|
||||
public function isCandidate(Node $node): bool
|
||||
{
|
||||
if (! $this->isInTestClass($node)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (! $node instanceof ClassMethod) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->docBlockAnalyzer->hasAnnotation($node, 'scenario');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ClassMethod $classMethodNode
|
||||
*/
|
||||
public function refactor(Node $classMethodNode): ?Node
|
||||
{
|
||||
$this->docBlockAnalyzer->replaceAnnotationInNode($classMethodNode, 'scenario', 'test');
|
||||
|
||||
return $classMethodNode;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Rector\Tests\Rector\Contrib\PHPUnit\ScenarioToTestAnnotationRector;
|
||||
namespace Rector\Tests\Rector\Dynamic\AnnotationReplacerRector;
|
||||
|
||||
use Rector\Rector\Dynamic\AnnotationReplacerRector;
|
||||
use Rector\Testing\PHPUnit\AbstractConfigurableRectorTestCase;
|
Loading…
Reference in New Issue
Block a user