Skip to content

Commit

Permalink
CLI-1263: [ide:share] remove unnecessary API call
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Feb 21, 2024
1 parent 6bc2749 commit cf09797
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
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

0 comments on commit cf09797

Please sign in to comment.