Skip to content

Commit

Permalink
Adds other simple application commmand tests
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 21, 2020
1 parent 3527e8d commit 0b7b9d8
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ acquiacli.yml
robo.yml
vendor
.idea
tests/logs
7 changes: 7 additions & 0 deletions src/CloudApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use AcquiaCloudApi\Connector\Client;
use AcquiaCloudApi\Connector\Connector;
use AcquiaCloudApi\Endpoints\Applications;
use AcquiaCloudApi\Endpoints\Environments;

/**
* Class CloudApi
Expand Down Expand Up @@ -44,4 +46,9 @@ public function setCloudApi($cloudapi)
{
$this->cloudapi = $cloudapi;
}

public function getExtraConfig()
{
return $this->extraConfig;
}
}
5 changes: 3 additions & 2 deletions src/Commands/AcquiaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ protected function getUuidFromHostingName($name)
protected function waitForNotification($response)
{
if ($this->input()->getOption('no-wait')) {
$this->say('Skipping wait for notification.');
// @TODO put this back in later.
// $this->say('Skipping wait for notification.');
return true;
}

Expand Down Expand Up @@ -343,7 +344,7 @@ protected function backupDb($uuid, EnvironmentResponse $environment, DatabaseRes
*/
protected function copyFiles($uuid, $environmentFrom, $environmentTo)
{
$environmentsAdapter = $this->getEnvironments();
$environmentsAdapter = new Environments($this->cloudapi);
$this->say(sprintf('Copying files from %s to %s', $environmentFrom->label, $environmentTo->label));
$response = $environmentsAdapter->copyFiles($environmentFrom->uuid, $environmentTo->uuid);
$this->waitForNotification($response);
Expand Down
64 changes: 64 additions & 0 deletions tests/Commands/ApplicationCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace AcquiaCli\Tests\Commands;

use AcquiaCli\Tests\AcquiaCliTestCase;

class ApplicationCommandTest extends AcquiaCliTestCase
{

/**
* @dataProvider applicationProvider
*/
public function testApplicationCommands($command, $fixture, $expected)
{
$psr7Response = $this->getPsr7JsonResponseForFixture($fixture);
$client = $this->getMockClient($psr7Response);

$actualResponse = $this->execute($client, $command);

$this->assertSame($expected, $actualResponse);
}

public function applicationProvider()
{
$getAllApplications = '+----------------------+--------------------------------------+--------------------+
| Name | UUID | Hosting ID |
+----------------------+--------------------------------------+--------------------+
| Sample application 1 | a47ac10b-58cc-4372-a567-0e02b2c3d470 | devcloud:devcloud2 |
| Sample application 2 | a47ac10b-58cc-4372-a567-0e02b2c3d471 | devcloud:devcloud2 |
+----------------------+--------------------------------------+--------------------+
';

$getTags = '+------+--------+
| Name | Color |
+------+--------+
| Dev | orange |
+------+--------+
';

return [
[
['application:list'],
'Applications/getAllApplications.json',
$getAllApplications

],
[
['application:tags', 'uuid'],
'Applications/getAllTags.json',
$getTags
],
[
['application:tag:create', 'uuid', 'name', 'color'],
'Applications/createTag.json',
'> Creating application tag name:color' . PHP_EOL
],
[
['application:tag:delete', 'uuid', 'name'],
'Applications/deleteTag.json',
'> Deleting application tag name' . PHP_EOL
]
];
}
}
Empty file removed tests/logs/clover.xml
Empty file.

0 comments on commit 0b7b9d8

Please sign in to comment.