From 0fb5761a90f5fdce4481b24b04a43349e45c92a4 Mon Sep 17 00:00:00 2001 From: Brian Henry Date: Thu, 7 Mar 2024 18:40:55 -0800 Subject: [PATCH] Create StraussIssue88Test.php --- tests/Issues/StraussIssue88Test.php | 67 +++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/Issues/StraussIssue88Test.php diff --git a/tests/Issues/StraussIssue88Test.php b/tests/Issues/StraussIssue88Test.php new file mode 100644 index 00000000..2b8bc64b --- /dev/null +++ b/tests/Issues/StraussIssue88Test.php @@ -0,0 +1,67 @@ +getUri();` not prefixed properly. + * + * @see https://github.com/BrianHenryIE/strauss/issues/88 + */ + +namespace BrianHenryIE\Strauss\Tests\Issues; + +use BrianHenryIE\Strauss\Console\Commands\Compose; +use BrianHenryIE\Strauss\Tests\Integration\Util\IntegrationTestCase; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +/** + * @package BrianHenryIE\Strauss\Tests\Issues + * @coversNothing + */ +class StraussIssue88Test extends IntegrationTestCase +{ + public function test_returned_casted_function_call() + { + + $composerJsonString = <<<'EOD' +{ + "name": "issue/83", + "require": { + "aws/aws-sdk-php": "3.293.8" + }, + "extra": { + "strauss": { + "namespace_prefix": "Company\\Project\\", + "exclude_from_copy": { + "file_patterns": [ + "/^((?!aws\\/aws-sdk-php).)*$/" + ] + } + }, + "aws/aws-sdk-php": [ + "S3" + ] + }, + "scripts": { + "pre-autoload-dump": "Aws\\Script\\Composer\\Composer::removeUnusedServices" + } +} +EOD; + + chdir($this->testsWorkingDir); + + file_put_contents($this->testsWorkingDir . '/composer.json', $composerJsonString); + + exec('composer install'); + + $inputInterfaceMock = $this->createMock(InputInterface::class); + $outputInterfaceMock = $this->createMock(OutputInterface::class); + + $strauss = new Compose(); + + $result = $strauss->run($inputInterfaceMock, $outputInterfaceMock); + + $php_string = file_get_contents($this->testsWorkingDir . '/vendor-prefixed/aws/aws-sdk-php/src/S3/S3Client.php'); + + self::assertStringNotContainsString('return (string) \Aws\serialize($command)->getUri();', $php_string); + self::assertStringContainsString('return (string) \Company\Project\Aws\serialize($command)->getUri();', $php_string); + } +}