Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Oct 31, 2023
1 parent 4857e84 commit 01a88da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tests/phpunit/src/Commands/Acsf/AcsfApiCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function testAcsfCommandExecutionForHttpGetMultiple(mixed $method, mixed
$contents = json_decode($output, TRUE);
}

protected function setClientProphecies(mixed $clientServiceClass = ClientService::class): void {
protected function setClientProphecies(?string $clientServiceClass = ClientService::class): void {
$this->clientProphecy = $this->prophet->prophesize(AcsfClient::class);
$this->clientProphecy->addOption('headers', ['User-Agent' => 'acli/UNKNOWN']);
$this->clientProphecy->addOption('debug', Argument::type(OutputInterface::class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Acquia\Cli\Tests\Commands\Ide\IdeRequiredTestTrait;
use Acquia\Cli\Tests\Commands\WizardTestBase;
use Acquia\Cli\Tests\TestBase;
use AcquiaCloudApi\Connector\Connector;
use DateTime;
use Gitlab\Api\Groups;
use Gitlab\Api\ProjectNamespaces;
Expand Down Expand Up @@ -190,8 +191,7 @@ public function providerTestCommand(): array {
* @dataProvider providerTestCommand
*/
public function testCommand(array $mockedGitlabProjects, array $inputs, array $args): void {
$environmentsResponse = $this->getMockEnvironmentsResponse();
$this->clientProphecy->request('get', "/applications/{$this::$applicationUuid}/environments")->willReturn($environmentsResponse->_embedded->items)->shouldBeCalled();
$this->clientServiceProphecy->setConnector(Argument::type(Connector::class))->shouldBeCalled();
$this->mockRequest('getAccount');
$this->mockGitLabPermissionsRequest($this::$applicationUuid);

Expand All @@ -214,7 +214,11 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a
'description' => 'Source repository for Acquia Cloud Platform application <comment>a47ac10b-58cc-4372-a567-0e02b2c3d470</comment>',
'topics' => 'Acquia Cloud Application',
];
$projects->update($this->gitLabProjectId, $parameters);
$projects->update($this->gitLabProjectId, $parameters)->shouldBeCalled();
$projects->uploadAvatar(
33,
Argument::type('string'),
)->shouldBeCalled();
$this->mockGitLabVariables($this->gitLabProjectId, $projects);
$schedules = $this->prophet->prophesize(Schedules::class);
$schedules->showAll($this->gitLabProjectId)->willReturn([]);
Expand All @@ -229,7 +233,11 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a
$schedules->addVariable($this->gitLabProjectId, $pipeline['id'], [
'key' => 'ACQUIA_JOBS_DEPRECATED_UPDATE',
'value' => 'true',
]);
])->shouldBeCalled();
$schedules->addVariable($this->gitLabProjectId, $pipeline['id'], [
'key' => 'ACQUIA_JOBS_COMPOSER_UPDATE',
'value' => 'true',
])->shouldBeCalled();
$gitlabClient->schedules()->willReturn($schedules->reveal());
$gitlabClient->projects()->willReturn($projects);

Expand All @@ -248,14 +256,13 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a

/** @var Filesystem|ObjectProphecy $fileSystem */
$fileSystem = $this->prophet->prophesize(Filesystem::class);
$localMachineHelper->getFilesystem()->willReturn($fileSystem->reveal())->shouldBeCalled();
$this->command->localMachineHelper = $localMachineHelper->reveal();

// Set properties and execute.
$this->executeCommand($args, $inputs);

// Assertions.
//$this->prophet->checkPredictions();
$this->prophet->checkPredictions();
$this->assertEquals(0, $this->getStatusCode());
}

Expand Down Expand Up @@ -305,7 +312,7 @@ protected function mockGitLabProjectsTokens(ObjectProphecy $projects): void {
],
];
$projects->projectAccessTokens($this->gitLabProjectId)->willReturn($tokens)->shouldBeCalled();
$projects->deleteProjectAccessToken($this->gitLabProjectId, $this->gitLabTokenId);
$projects->deleteProjectAccessToken($this->gitLabProjectId, $this->gitLabTokenId)->shouldBeCalled();
$token = $tokens[0];
$token['token'] = 'token';
$projects->createProjectAccessToken($this->gitLabProjectId, Argument::type('array'))->willReturn($token);
Expand Down Expand Up @@ -404,9 +411,10 @@ protected function mockGitLabNamespaces(ObjectProphecy $gitlabClient): void {
$gitlabClient->namespaces()->willReturn($namespaces->reveal());
}

protected function mockGitLabVariables(mixed $gitlabProjectId, ObjectProphecy $projects): void {
protected function mockGitLabVariables(int $gitlabProjectId, ObjectProphecy $projects): void {
$projects->variables($gitlabProjectId)->willReturn($this->getMockGitLabVariables());
$projects->addVariable($gitlabProjectId, Argument::type('string'), Argument::type('string'), Argument::type('bool'), NULL, Argument::type('array'));
$projects->addVariable($gitlabProjectId, Argument::type('string'), Argument::type('string'), Argument::type('bool'), NULL, Argument::type('array'))->shouldBeCalled();
$projects->updateVariable($this->gitLabProjectId, Argument::type('string'), Argument::type('string'), FALSE, NULL, ["masked" => TRUE, "variable_type" => "env_var"])->shouldBeCalled();
}

}
2 changes: 1 addition & 1 deletion tests/phpunit/src/TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public function mockGuzzleClientForUpdate(array $releases): ObjectProphecy {
return $guzzleClient;
}

protected function setClientProphecies(mixed $clientServiceClass = ClientService::class): void {
protected function setClientProphecies(?string $clientServiceClass = ClientService::class): void {
$this->clientProphecy = $this->prophet->prophesize(Client::class);
$this->clientProphecy->addOption('headers', ['User-Agent' => 'acli/UNKNOWN']);
$this->clientProphecy->addOption('debug', Argument::type(OutputInterface::class));
Expand Down

0 comments on commit 01a88da

Please sign in to comment.