Skip to content
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
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!-- phpunit.xml.dist -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" failOnDeprecation="true" displayDetailsOnTestsThatTriggerDeprecations="true" failOnWarning="true" failOnRisky="true" cacheDirectory="var">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" failOnDeprecation="true" displayDetailsOnTestsThatTriggerDeprecations="true" displayDetailsOnTestsThatTriggerWarnings="true" failOnWarning="true" failOnRisky="true" cacheDirectory="var">
<php>
<env name="AMPLITUDE_KEY" value=""/>
<env name="BUGSNAG_KEY" value=""/>
Expand Down
3 changes: 3 additions & 0 deletions src/Command/CommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,9 @@ private function promptChooseAcsfSite(EnvironmentResponse $cloudEnvironment): mi
foreach ($acsfSites['sites'] as $domain => $acsfSite) {
$choices[] = "{$acsfSite['name']} ($domain)";
}
if (!count($choices)) {
throw new AcquiaCliException('No sites found in this environment');
}
$choice = $this->io->choice('Choose a site', $choices, $choices[0]);
$key = array_search($choice, $choices, true);
$sites = array_values($acsfSites['sites']);
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/no-multisite-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"cloud":{"site":"profserv2","env":"01dev"},"memcache_inc":"profiles\/gardens\/modules\/acquia\/memcache\/memcache.inc",
"sites": {
}}
9 changes: 7 additions & 2 deletions tests/phpunit/src/CommandTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,16 @@ public function mockAcsfEnvironmentsRequest(

/**
* @return array<mixed>
* @throws \Acquia\Cli\Exception\AcquiaCliException
*/
protected function mockGetAcsfSites(mixed $sshHelper): array
protected function mockGetAcsfSites(SshHelper|ObjectProphecy $sshHelper, bool $existAcsfSites = true): array
{
$acsfMultisiteFetchProcess = $this->mockProcess();
$multisiteConfig = file_get_contents(Path::join($this->realFixtureDir, '/multisite-config.json'));
if ($existAcsfSites) {
$multisiteConfig = file_get_contents(Path::join($this->realFixtureDir, '/multisite-config.json'));
} else {
$multisiteConfig = file_get_contents(Path::join($this->realFixtureDir, '/no-multisite-config.json'));
}
$acsfMultisiteFetchProcess->getOutput()
->willReturn($multisiteConfig)
->shouldBeCalled();
Expand Down
44 changes: 42 additions & 2 deletions tests/phpunit/src/Commands/Pull/PullFilesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ protected function createCommand(): CommandBase
);
}

public function testRefreshAcsfFiles(): void
/**
* @throws \Exception
*/
public function testPullFilesAcsf(): void
{
$applicationsResponse = $this->mockApplicationsRequest();
$this->mockApplicationRequest();
Expand Down Expand Up @@ -69,7 +72,41 @@ public function testRefreshAcsfFiles(): void
$this->assertStringContainsString('[0] Dev, dev (vcs: master)', $output);
}

public function testRefreshCloudFiles(): void
/**
* @throws \Exception
*/
public function testPullFilesAcsfNoSites(): void
{
$applicationsResponse = $this->mockApplicationsRequest();
$this->mockApplicationRequest();
$this->mockAcsfEnvironmentsRequest($applicationsResponse);
$sshHelper = $this->mockSshHelper();
$this->mockGetAcsfSites($sshHelper, false);
$this->command->sshHelper = $sshHelper->reveal();

$inputs = [
// Would you like Acquia CLI to search for a Cloud application that matches your local git config?
'n',
// Select a Cloud Platform application:
0,
// Would you like to link the project at ... ?
'n',
// Choose an Acquia environment:
0,
// Choose site from which to copy files:
0,
];


$this->expectException(AcquiaCliException::class);
$this->expectExceptionMessage('No sites found in this environment');
$this->executeCommand([], $inputs);
}

/**
* @throws \Exception
*/
public function testPullFilesCloud(): void
{
$applicationsResponse = $this->mockApplicationsRequest();
$this->mockApplicationRequest();
Expand Down Expand Up @@ -108,6 +145,9 @@ public function testRefreshCloudFiles(): void
$this->assertStringContainsString('[0] Dev, dev (vcs: master)', $output);
}

/**
* @throws \Exception
*/
public function testInvalidCwd(): void
{
IdeHelper::setCloudIdeEnvVars();
Expand Down
Loading