diff --git a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php index 76efca482..79460ae1d 100644 --- a/tests/phpunit/src/Commands/App/AppVcsInfoTest.php +++ b/tests/phpunit/src/Commands/App/AppVcsInfoTest.php @@ -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.'); diff --git a/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php b/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php index 11364050b..e32e076d3 100644 --- a/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php +++ b/tests/phpunit/src/Commands/Env/EnvDeleteCommandTest.php @@ -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)