diff --git a/tests/Issues/MozartIssue129Test.php b/tests/Issues/MozartIssue129Test.php new file mode 100644 index 00000000..505a4b6c --- /dev/null +++ b/tests/Issues/MozartIssue129Test.php @@ -0,0 +1,112 @@ +createMock(StraussConfig::class); + + $original = 'Example\Sdk\Endpoints'; + $replacement = 'Strauss\Example\Sdk\Endpoints'; + + $replacer = new Prefixer($config, __DIR__); + + $result = $replacer->replaceNamespace($phpString, $original, $replacement); + + $this->assertEquals($expected, $result); + } + + public function pairTestDataProvider() + { + + $fromTo = []; + + $contents = <<<'EOD' +$baseNamespace = "\Example\Sdk\Endpoints"; +EOD; + $expected = <<<'EOD' +$baseNamespace = "\Strauss\Example\Sdk\Endpoints"; +EOD; + $fromTo[] = [ $contents, $expected]; + + $contents = <<<'EOD' +$baseNamespace = "Example\\Sdk\\Endpoints"; +EOD; + $expected = <<<'EOD' +$baseNamespace = "Strauss\\Example\\Sdk\\Endpoints"; +EOD; + $fromTo[] = [ $contents, $expected]; + + $contents = <<<'EOD' +$baseNamespace = "Example\Sdk\Endpoints"; +EOD; + $expected = <<<'EOD' +$baseNamespace = "Strauss\Example\Sdk\Endpoints"; +EOD; + $fromTo[] = [ $contents, $expected]; + + $contents = <<<'EOD' +$baseNamespace = '\\Example\\Sdk\\Endpoints'; +EOD; + $expected = <<<'EOD' +$baseNamespace = '\\Strauss\\Example\\Sdk\\Endpoints'; +EOD; + $fromTo[] = [ $contents, $expected]; + + $contents = <<<'EOD' +$baseNamespace = '\Example\Sdk\Endpoints'; +EOD; + $expected = <<<'EOD' +$baseNamespace = '\Strauss\Example\Sdk\Endpoints'; +EOD; + $fromTo[] = [ $contents, $expected]; + + $contents = <<<'EOD' +$baseNamespace = 'Example\\Sdk\\Endpoints'; +EOD; + $expected = <<<'EOD' +$baseNamespace = 'Strauss\\Example\\Sdk\\Endpoints'; +EOD; + $fromTo[] = [ $contents, $expected]; + + $contents = <<<'EOD' +$baseNamespace = 'Example\Sdk\Endpoints'; +EOD; + $expected = <<<'EOD' +$baseNamespace = 'Strauss\Example\Sdk\Endpoints'; +EOD; + $fromTo[] = [ $contents, $expected]; + + return $fromTo; + } +}