Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI-1263: [ide:share] remove unnecessary API call #1689

Merged
merged 1 commit into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,10 @@ protected static function getThisCloudIdeLabel(): false|string {
return getenv('REMOTEIDE_LABEL');
}

protected static function getThisCloudIdeWebUrl(): false|string {
return getenv('REMOTEIDE_WEB_HOST');
}

protected function getCloudApplication(string $applicationUuid): ApplicationResponse {
$applicationsResource = new Applications($this->cloudApiClientService->getClient());
return $applicationsResource->get($applicationUuid);
Expand Down
7 changes: 2 additions & 5 deletions src/Command/Ide/IdeShareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use Acquia\Cli\Command\CommandBase;
use Acquia\DrupalEnvironmentDetector\AcquiaDrupalEnvironmentDetector;
use AcquiaCloudApi\Endpoints\Ides;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -36,12 +35,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

$shareUuid = $this->localMachineHelper->readFile($this->getShareCodeFilepaths()[0]);
$acquiaCloudClient = $this->cloudApiClientService->getClient();
$idesResource = new Ides($acquiaCloudClient);
$ide = $idesResource->get($this::getThisCloudIdeUuid());
$webUrl = self::getThisCloudIdeWebUrl();

$this->output->writeln('');
$this->output->writeln("<comment>Your IDE Share URL:</comment> <href={$ide->links->web->href}>{$ide->links->web->href}?share=$shareUuid</>");
$this->output->writeln("<comment>Your IDE Share URL:</comment> <href=https://$webUrl>https://$webUrl?share=$shareUuid</>");

return Command::SUCCESS;
}
Expand Down
13 changes: 1 addition & 12 deletions tests/phpunit/src/Commands/Ide/IdeShareCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Acquia\Cli\Command\CommandBase;
use Acquia\Cli\Command\Ide\IdeShareCommand;
use Acquia\Cli\Tests\CommandTestBase;
use AcquiaCloudApi\Response\IdeResponse;
use Symfony\Component\Console\Output\OutputInterface;

/**
Expand Down Expand Up @@ -41,24 +40,14 @@ protected function createCommand(): CommandBase {
}

public function testIdeShareCommand(): void {
$ideGetResponse = $this->mockRequest('getIde', IdeHelper::$remoteIdeUuid);
$ide = new IdeResponse((object) $ideGetResponse);
$this->executeCommand();

// Assert.

$output = $this->getDisplay();
$this->assertStringContainsString('Your IDE Share URL: ', $output);
$this->assertStringContainsString($this->shareCode, $output);
}

public function testIdeShareRegenerateCommand(): void {
$ideGetResponse = $this->mockRequest('getIde', IdeHelper::$remoteIdeUuid);
$ide = new IdeResponse((object) $ideGetResponse);
$this->executeCommand(['--regenerate' => TRUE], []);

// Assert.

$this->executeCommand(['--regenerate' => TRUE]);
$output = $this->getDisplay();
$this->assertStringContainsString('Your IDE Share URL: ', $output);
$this->assertStringNotContainsString($this->shareCode, $output);
Expand Down