From 8996fc9d2debfd22fb5d1efe878c39bf007989df Mon Sep 17 00:00:00 2001 From: joshirohit100 Date: Tue, 2 Aug 2022 20:04:03 +0530 Subject: [PATCH] Adding new assertion for absolute path --- src/Command/App/NewCommand.php | 6 +++--- tests/phpunit/src/Commands/NewCommandTest.php | 9 ++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Command/App/NewCommand.php b/src/Command/App/NewCommand.php index 791b1c45e..3ac5ca26c 100644 --- a/src/Command/App/NewCommand.php +++ b/src/Command/App/NewCommand.php @@ -57,12 +57,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Creating project. This may take a few minutes.'); if ($project === 'acquia_next_acms') { - $success_message = "New Next JS project created in $dir. 🎉"; + $success_message = "New Next JS project created in $dir. 🎉"; $this->localMachineHelper->checkRequiredBinariesExist(['node']); $this->createNextJsProject($dir); } else { - $success_message = "New 💧 Drupal project created in $dir. 🎉"; + $success_message = "New 💧 Drupal project created in $dir. 🎉"; $this->localMachineHelper->checkRequiredBinariesExist(['composer']); $this->createDrupalProject($distros[$project], $dir); } @@ -89,7 +89,7 @@ protected function commandRequiresAuthentication(InputInterface $input): bool { * * @throws \Exception */ - protected function createNextJsProject(string $dir): void { + private function createNextJsProject(string $dir): void { $process = $this->localMachineHelper->execute([ 'npx', 'create-next-app', diff --git a/tests/phpunit/src/Commands/NewCommandTest.php b/tests/phpunit/src/Commands/NewCommandTest.php index bd9fed17f..35511d22c 100644 --- a/tests/phpunit/src/Commands/NewCommandTest.php +++ b/tests/phpunit/src/Commands/NewCommandTest.php @@ -61,7 +61,7 @@ public function testNewDrupalCommand(array $package, string $directory = 'drupal $local_machine_helper = $this->mockLocalMachineHelper(); - $this->mockGetFilesystem($local_machine_helper); + $mock_file_system = $this->mockGetFilesystem($local_machine_helper); $local_machine_helper->checkRequiredBinariesExist(["composer"])->shouldBeCalled(); $this->mockExecuteComposerCreate($this->newProjectDir, $local_machine_helper, $process, $project); $local_machine_helper->checkRequiredBinariesExist(["git"])->shouldBeCalled(); @@ -79,10 +79,11 @@ public function testNewDrupalCommand(array $package, string $directory = 'drupal ], $inputs); $this->prophet->checkPredictions(); $output = $this->getDisplay(); + $this->assertStringContainsString('Acquia recommends most customers use acquia/drupal-recommended-project to setup a Drupal project', $output); $this->assertStringContainsString('Choose a starting project', $output); $this->assertStringContainsString($project, $output); + $this->assertTrue($mock_file_system->isAbsolutePath($this->newProjectDir), 'Directory path is not absolute'); $this->assertStringContainsString('New 💧 Drupal project created in ' . $this->newProjectDir, $output); - } /** @@ -106,7 +107,7 @@ public function testNewNextJSAppCommand(array $package, string $directory = 'nex $local_machine_helper = $this->mockLocalMachineHelper(); - $this->mockGetFilesystem($local_machine_helper); + $mock_file_system = $this->mockGetFilesystem($local_machine_helper); $local_machine_helper->checkRequiredBinariesExist(["node"])->shouldBeCalled(); $this->mockExecuteNpxCreate($this->newProjectDir, $local_machine_helper, $process); @@ -125,8 +126,10 @@ public function testNewNextJSAppCommand(array $package, string $directory = 'nex ], $inputs); $this->prophet->checkPredictions(); $output = $this->getDisplay(); + $this->assertStringContainsString('acquia/next-acms is a starter template for building a headless site', $output); $this->assertStringContainsString('Choose a starting project', $output); $this->assertStringContainsString($project, $output); + $this->assertTrue($mock_file_system->isAbsolutePath($this->newProjectDir), 'Directory path is not absolute'); $this->assertStringContainsString('New Next JS project created in ' . $this->newProjectDir, $output); }