Skip to content

Commit

Permalink
test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Oct 27, 2023
1 parent 753710e commit 6d5651e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
17 changes: 8 additions & 9 deletions tests/phpunit/src/Commands/App/AppVcsInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,19 @@ public function testShowVcsListCommand(): void {
* Test the list of deployed VCS but no deployed VCS available.
*/
public function testNoDeployedVcs(): void {
$applicationsResponse = $this->mockApplicationsRequest();
$this->mockApplicationRequest();
$response = $this->getMockEnvironmentsResponse();
foreach ($response->_embedded->items as $key => $item) {
$applications = $this->mockRequest('getApplications');
$application = $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid);
$environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid);
foreach ($environments as $environment) {
// Empty the VCS
$item->vcs = new \stdClass();
$response->_embedded->items[$key] = $item;
$environment->vcs = new \stdClass();
}

$this->clientProphecy->request('get',
"/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments")
->willReturn($response->_embedded->items)
"/applications/{$application->uuid}/environments")
->willReturn($environments)
->shouldBeCalled();
$this->mockRequest('getCodeByApplicationUuid', $applicationsResponse->{'_embedded'}->items[0]->uuid);
$this->mockRequest('getCodeByApplicationUuid', $application->uuid);

$this->expectException(AcquiaCliException::class);
$this->expectExceptionMessage('No branch or tag is deployed on any of the environment of this application.');
Expand Down
17 changes: 8 additions & 9 deletions tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,18 @@ public function testNoExistingCDEEnvironment(): void {
* Tests the case when multiple CDE available for application.
*/
public function testNoEnvironmentArgumentPassed(): void {
$applicationsResponse = $this->mockApplicationsRequest();
$this->mockApplicationRequest();
$response = $this->getMockEnvironmentsResponse();
foreach ($response->{'_embedded'}->items as $key => $env) {
$env->flags->cde = TRUE;
$response->{'_embedded'}->items[$key] = $env;
$applications = $this->mockRequest('getApplications');
$application = $this->mockRequest('getApplicationByUuid', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid);
$environments = $this->mockRequest('getApplicationEnvironments', $applications[self::$INPUT_DEFAULT_CHOICE]->uuid);
foreach ($environments as $environment) {
$environment->flags->cde = TRUE;
}
$this->clientProphecy->request('get',
"/applications/{$applicationsResponse->{'_embedded'}->items[0]->uuid}/environments")
->willReturn($response->_embedded->items)
"/applications/{$application->uuid}/environments")
->willReturn($environments)
->shouldBeCalled();

$cde = $response->_embedded->items[0];
$cde = $environments[0];
$environmentsResponse = $this->getMockResponseFromSpec('/environments/{environmentId}',
'delete', 202);
$this->clientProphecy->request('delete', "/environments/" . $cde->id)
Expand Down

0 comments on commit 6d5651e

Please sign in to comment.