diff --git a/tests/Issues/MozartIssue124Test.php b/tests/Issues/MozartIssue124Test.php new file mode 100644 index 00000000..b2afbfc1 --- /dev/null +++ b/tests/Issues/MozartIssue124Test.php @@ -0,0 +1,124 @@ +testsWorkingDir . '/composer.json', $composerJsonString); + + chdir($this->testsWorkingDir); + + exec('composer install'); + + $inputInterfaceMock = $this->createMock(InputInterface::class); + $outputInterfaceMock = $this->createMock(OutputInterface::class); + + $mozartCompose = new Compose(); + + $mozartCompose->run($inputInterfaceMock, $outputInterfaceMock); + + $mpdf_php = file_get_contents($this->testsWorkingDir .'strauss/mpdf/mpdf/src/Mpdf.php'); + + // Confirm problem is gone. + $this->assertStringNotContainsString('class BrianHenryIE\Strauss\Mpdf implements', $mpdf_php); + + // Confirm solution is correct. + $this->assertStringContainsString('class Mpdf implements', $mpdf_php); + } + + + /** + * Another Mpdf problem, presumably down to the classname matching the namespace. + * + * Typed function properties whose class type (name) match the namespace being replaced are + * unintentionally prefixed, causing PHP to crash. + * + * Occurring at dev-master#3b1243ca8505fa6436569800dc34269178930f39 + * + * @see https://github.com/coenjacobs/mozart/issues/124 + */ + public function test_it_does_not_prefix_function_argument_types_whose_classname_matches_the_namespace() + { + + + $composerJsonString = <<<'EOD' +{ + "name": "brianhenryie/mozart-issue-124", + "require": { + "mpdf/mpdf": "8.0.10" + }, + "extra": { + "strauss": { + "namespace_prefix": "BrianHenryIE\\Strauss\\", + "classmap_prefix": "BrianHenryIE_Strauss_" + } + } +} +EOD; + + file_put_contents($this->testsWorkingDir . '/composer.json', $composerJsonString); + + chdir($this->testsWorkingDir); + + exec('composer install'); + + $inputInterfaceMock = $this->createMock(InputInterface::class); + $outputInterfaceMock = $this->createMock(OutputInterface::class); + + $mozartCompose = new Compose(); + + $mozartCompose->run($inputInterfaceMock, $outputInterfaceMock); + + $mpdf_php = file_get_contents($this->testsWorkingDir .'/strauss/mpdf/mpdf/src/Conversion/DecToOther.php'); + + // Confirm problem is gone. + $this->assertStringNotContainsString('public function __construct(BrianHenryIE\Strauss\Mpdf $mpdf)', $mpdf_php); + + // Confirm solution is correct. + $this->assertStringContainsString('public function __construct(Mpdf $mpdf)', $mpdf_php); + } +}