diff --git a/src/Command/CodeStudio/CodeStudioWizardCommand.php b/src/Command/CodeStudio/CodeStudioWizardCommand.php index 0d967204b..152679d4f 100644 --- a/src/Command/CodeStudio/CodeStudioWizardCommand.php +++ b/src/Command/CodeStudio/CodeStudioWizardCommand.php @@ -7,6 +7,7 @@ use Acquia\Cli\Command\WizardCommandBase; use Acquia\Cli\Output\Checklist; use AcquiaCloudApi\Endpoints\Account; +use DateTime; use Gitlab\Exception\ValidationFailedException; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -161,10 +162,9 @@ private function createProjectAccessToken(array $project, string $projectAccessT $this->checklist->completePreviousItem(); } $this->checklist->addItem("Creating access token named $projectAccessTokenName"); - $dateTime = new \DateTime('tomorrow'); $projectAccessToken = $this->gitLabClient->projects() ->createProjectAccessToken($project['id'], [ - 'expires_at' => $dateTime, + 'expires_at' => new DateTime('+365 days'), 'name' => $projectAccessTokenName, 'scopes' => ['api', 'write_repository'], ]); diff --git a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php index ede91ff72..b75319466 100644 --- a/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php +++ b/tests/phpunit/src/Commands/CodeStudio/CodeStudioWizardCommandTest.php @@ -9,6 +9,7 @@ use Acquia\Cli\Tests\Commands\Ide\IdeRequiredTestTrait; use Acquia\Cli\Tests\Commands\WizardTestBase; use Acquia\Cli\Tests\TestBase; +use DateTime; use Gitlab\Api\Groups; use Gitlab\Api\ProjectNamespaces; use Gitlab\Api\Schedules; @@ -270,13 +271,12 @@ public function testMissingGitLabCredentials(): void { } protected function mockGitLabProjectsTokens(ObjectProphecy $projects): void { - $dateTime = new \DateTime('tomorrow'); $tokens = [ 0 => [ 'access_level' => 40, 'active' => TRUE, 'created_at' => '2021-12-28T20:08:21.629Z', - 'expires_at' => $dateTime, + 'expires_at' => new DateTime('+365 days'), 'id' => $this->gitLabTokenId, 'name' => 'acquia-codestudio', 'revoked' => FALSE, @@ -287,7 +287,7 @@ protected function mockGitLabProjectsTokens(ObjectProphecy $projects): void { 'user_id' => 154, ], ]; - $projects->projectAccessTokens($this->gitLabProjectId)->willReturn($tokens); + $projects->projectAccessTokens($this->gitLabProjectId)->willReturn($tokens)->shouldBeCalled(); $projects->deleteProjectAccessToken($this->gitLabProjectId, $this->gitLabTokenId); $token = $tokens[0]; $token['token'] = 'token';