Skip to content

Commit

Permalink
Adding new assertion for absolute path
Browse files Browse the repository at this point in the history
  • Loading branch information
joshirohit100 committed Aug 3, 2022
1 parent d2610ea commit 5d9e259
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Command/App/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('<info>Creating project. This may take a few minutes.</info>');

if ($project === 'acquia_next_acms') {
$success_message = "<info>New Next JS project created in $dir. 🎉";
$success_message = "<info>New Next JS project created in $dir. 🎉</info>";
$this->localMachineHelper->checkRequiredBinariesExist(['node']);
$this->createNextJsProject($dir);
}
else {
$success_message = "<info>New 💧 Drupal project created in $dir. 🎉";
$success_message = "<info>New 💧 Drupal project created in $dir. 🎉</info>";
$this->localMachineHelper->checkRequiredBinariesExist(['composer']);
$this->createDrupalProject($distros[$project], $dir);
}
Expand All @@ -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',
Expand Down
9 changes: 6 additions & 3 deletions tests/phpunit/src/Commands/NewCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);

}

/**
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down

0 comments on commit 5d9e259

Please sign in to comment.