Skip to content

Commit

Permalink
Removes AcquiaCliTest and adds in some application tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 21, 2020
1 parent 1c8510e commit e5836dc
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 50 deletions.
3 changes: 0 additions & 3 deletions src/Cli/AcquiaCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ public function __construct(
InputInterface $input = null,
OutputInterface $output = null
) {
if (!file_exists(dirname(dirname(__DIR__)) . '/VERSION')) {
throw new \Exception('No blah file');
}
if ($file = file_get_contents(dirname(dirname(__DIR__)) . '/VERSION')) {
$version = trim($file);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/CloudApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getEnvironment($uuid, $environment)
}
}

throw new \Exception('Unable to find ID for environment');
throw new \Exception('Unable to find environment from environment name');
}

/**
Expand All @@ -103,7 +103,7 @@ public function getOrganization($organizationName)
}
}

throw new \Exception('Unable to find ID for organization');
throw new \Exception('Unable to find organization from organization name');
}

public function getClient()
Expand Down
39 changes: 39 additions & 0 deletions tests/AcquiaCliApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use AcquiaCli\Tests\AcquiaCliTestCase;
use AcquiaCli\Cli\Config;
use AcquiaCli\Cli\CloudApi;

class AcquiaCliApplicationTest extends AcquiaCliTestCase
{
Expand Down Expand Up @@ -45,4 +46,42 @@ public function testVersion()

$this->assertSame('AcquiaCli 2.0.0-dev' . PHP_EOL, $actualValue);
}

public function testCloudApi()
{

$config = new Config($this->root);
$cloudApi = new CloudApi($config, $this->client);

$applicationUuid = $cloudApi->getApplicationUuid('devcloud:devcloud2');
$this->assertSame('a47ac10b-58cc-4372-a567-0e02b2c3d470', $applicationUuid);

try {
$applicationError = $cloudApi->getApplicationUuid('devcloud:foobar');
} catch (\Exception $e) {
$this->assertSame('Unable to find UUID for application', $e->getMessage());
}

$environment = $cloudApi->getEnvironment('uuid', 'dev');
$this->assertInstanceOf('\AcquiaCloudApi\Response\EnvironmentResponse', $environment);
$this->assertSame('24-a47ac10b-58cc-4372-a567-0e02b2c3d470', $environment->uuid);
$this->assertSame('dev', $environment->name);
$this->assertSame('Dev', $environment->label);
$this->assertSame('us-east-1', $environment->region);
$this->assertSame('normal', $environment->status);

try {
$environmentError = $cloudApi->getEnvironment('uuid', 'foobar');
} catch (\Exception $e) {
$this->assertSame('Unable to find environment from environment name', $e->getMessage());
}


$command = ['organization:members', 'foobar'];
$organizationError = $this->execute($command);
$this->assertSame(
' [error] Unable to find organization from organization name ' . PHP_EOL,
$organizationError
);
}
}
45 changes: 0 additions & 45 deletions tests/Cli/AcquiaCliTest.php

This file was deleted.

8 changes: 8 additions & 0 deletions tests/Commands/DeployCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ public function deployProvider()
> Copying files from Production to Stage
INFO;

$deployResponseProd = <<<INFO
[error] Cannot use deploy:prepare on the production environment
INFO;

return [
[
['deploy:prepare', 'uuid', 'dev', 'prod'],
Expand All @@ -43,6 +47,10 @@ public function deployProvider()
[
['deploy:prepare', 'uuid', 'test'],
$deployResponseTest . PHP_EOL
],
[
['deploy:prepare', 'uuid', 'prod'],
$deployResponseProd . PHP_EOL
]
];
}
Expand Down

0 comments on commit e5836dc

Please sign in to comment.