@@ -76,6 +76,15 @@ public function run()
7676
7777 public function refactor(): void
7878 {
79+ $sample = <<<'CODE_SAMPLE'
80+ <?php
81+
82+ namespace RectorPrefix202607;
83+
84+ \RectorPrefix202607\ShouldStayPrefixed::run();
85+ \class_alias('SomeClass', 'SomeClass', \false);
86+ CODE_SAMPLE;
87+
7988 \RectorPrefix202607\SomeVendor\Runtime::class;
8089 }
8190}
@@ -89,7 +98,14 @@ public function refactor(): void
8998 );
9099 }
91100
92- preg_match_all ("#<<<'CODE_SAMPLE'\R(.*?)\RCODE_SAMPLE#s " , (string ) $ content , $ matches );
101+ preg_match (
102+ '#public function getRuleDefinition\(\): RuleDefinition\s+\{\R(.*?)\R \}\R\R public function refactor\(\): void#s ' ,
103+ (string ) $ content ,
104+ $ getRuleDefinitionMatches
105+ );
106+ $ this ->assertNotSame ([], $ getRuleDefinitionMatches );
107+
108+ preg_match_all ("#<<<'CODE_SAMPLE'\R(.*?)\RCODE_SAMPLE#s " , $ getRuleDefinitionMatches [1 ], $ matches );
93109 $ codeSampleContent = implode ("\n" , $ matches [1 ]);
94110
95111 $ this ->assertStringContainsString ('use RectorPrefix202607\Webmozart\Assert\Assert; ' , (string ) $ content );
@@ -101,6 +117,7 @@ public function refactor(): void
101117 $ this ->assertStringNotContainsString ('namespace RectorPrefix202607; ' , $ codeSampleContent );
102118 $ this ->assertStringNotContainsString ('use RectorPrefix202607\Webmozart\Assert\Assert; ' , $ codeSampleContent );
103119 $ this ->assertStringNotContainsString ('\class_alias ' , $ codeSampleContent );
120+ $ this ->assertStringContainsString ('\RectorPrefix202607\ShouldStayPrefixed::run(); ' , (string ) $ content );
104121 }
105122
106123 public function testRemovesPrefixedNamespaceInGetRuleDefinitionWithWindowsLineEndings (): void
0 commit comments