File tree Expand file tree Collapse file tree 4 files changed +17
-4
lines changed
Expand file tree Collapse file tree 4 files changed +17
-4
lines changed Original file line number Diff line number Diff line change 99use PhpParser \Node \Name \FullyQualified ;
1010use PhpParser \Node \Stmt \Class_ ;
1111use Rector \PhpSpecToPHPUnit \Naming \PhpSpecRenaming ;
12+ use Rector \PHPUnit \Enum \PHPUnitClassName ;
1213use Rector \Privatization \NodeManipulator \VisibilityManipulator ;
1314use Rector \Rector \AbstractRector ;
1415use Symplify \RuleDocGenerator \ValueObject \CodeSample \CodeSample ;
@@ -52,7 +53,7 @@ public function refactor(Node $node): ?Node
5253 // rename class and parent class
5354 $ phpunitTestClassName = $ this ->phpSpecRenaming ->createPHPUnitTestClassName ($ node );
5455 $ node ->name = new Identifier ($ phpunitTestClassName );
55- $ node ->extends = new FullyQualified (' PHPUnit\Framework\TestCase ' );
56+ $ node ->extends = new FullyQualified (PHPUnitClassName:: TEST_CASE );
5657
5758 $ this ->visibilityManipulator ->makeFinal ($ node );
5859
Original file line number Diff line number Diff line change 55namespace Rector \PhpSpecToPHPUnit ;
66
77use PhpParser \Comment \Doc ;
8+ use Rector \PhpSpecToPHPUnit \Enum \PHPUnitClassName ;
89use Rector \PhpSpecToPHPUnit \ValueObject \ServiceMock ;
910
1011final class DocFactory
@@ -14,7 +15,7 @@ public static function createForMockAssign(ServiceMock $serviceMock): Doc
1415 $ comment = sprintf (
1516 "/** @var \%s|\%s $%s */ " ,
1617 $ serviceMock ->getMockClassName (),
17- ' PHPUnit\Framework\MockObject\MockObject ' ,
18+ PHPUnitClassName:: MOCK_OBJECT ,
1819 $ serviceMock ->getVariableName () . 'Mock '
1920 );
2021
@@ -27,7 +28,7 @@ public static function createForMockProperty(ServiceMock $serviceMock): Doc
2728 "/**%s * @var \%s|\%s%s */ " ,
2829 PHP_EOL ,
2930 $ serviceMock ->getMockClassName (),
30- ' PHPUnit\Framework\MockObject\MockObject ' ,
31+ PHPUnitClassName:: MOCK_OBJECT ,
3132 PHP_EOL
3233 );
3334
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Rector \PhpSpecToPHPUnit \Enum ;
6+
7+ final class PHPUnitClassName
8+ {
9+ public const MOCK_OBJECT = 'PHPUnit\Framework\MockObject\MockObject ' ;
10+ }
Original file line number Diff line number Diff line change 1818use Rector \NodeNameResolver \NodeNameResolver ;
1919use Rector \PhpParser \Node \NodeFactory ;
2020use Rector \PhpSpecToPHPUnit \DocFactory ;
21+ use Rector \PhpSpecToPHPUnit \Enum \PHPUnitClassName ;
2122use Rector \PhpSpecToPHPUnit \Exception \ShouldNotHappenException ;
2223use Rector \PhpSpecToPHPUnit \ValueObject \ServiceMock ;
2324
@@ -87,7 +88,7 @@ public function createMockPropertyAssignExpressions(array $params): array
8788
8889 private function crateMockProperty (string $ parameterName ): Property
8990 {
90- $ objectType = new ObjectType (' PHPUnit\Framework\MockObject\MockObject ' );
91+ $ objectType = new ObjectType (PHPUnitClassName:: MOCK_OBJECT );
9192 return $ this ->nodeFactory ->createPrivatePropertyFromNameAndType ($ parameterName , $ objectType );
9293 }
9394
You can’t perform that action at this time.
0 commit comments