Skip to content

Commit

Permalink
GL-2039: Tried adding testcase to kill mutant.
Browse files Browse the repository at this point in the history
  • Loading branch information
akashkska committed Feb 27, 2024
1 parent f50c6e7 commit 3f0507d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
16 changes: 12 additions & 4 deletions src/Command/CodeStudio/CodeStudioWizardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->reAuthenticate($cloudKey, $cloudSecret, $this->cloudCredentials->getBaseUri(), $this->cloudCredentials->getAccountsUri());
$phpVersion = NULL;
$nodeVersion = NULL;
$projectType = [
'Drupal_project',
'Node_project',
];
$projectType = $this->getListOfProjectType();
$projectSelected = $this->io->choice('Select a project type', $projectType, $projectType[0]);

Check warning on line 48 in src/Command/CodeStudio/CodeStudioWizardCommand.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ $phpVersion = NULL; $nodeVersion = NULL; $projectType = $this->getListOfProjectType(); - $projectSelected = $this->io->choice('Select a project type', $projectType, $projectType[0]); + $projectSelected = $this->io->choice('Select a project type', $projectType, $projectType[1]); switch ($projectSelected) { case "Drupal_project": $phpVersions = ['PHP_version_8.1' => "8.1", 'PHP_version_8.2' => "8.2"];

switch ($projectSelected) {
Expand Down Expand Up @@ -168,6 +165,17 @@ private function getGitLabProjectAccessTokenByName(array $project, string $name)
return NULL;
}

/**
* @return array<mixed>|null ?
*/
private function getListOfProjectType(): ?array {
$array = [

Check warning on line 172 in src/Command/CodeStudio/CodeStudioWizardCommand.php

View workflow job for this annotation

GitHub Actions / Mutation Testing

Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ */ private function getListOfProjectType() : ?array { - $array = ['Drupal_project', 'Node_project']; + $array = ['Node_project']; return $array; } private function createProjectAccessToken(array $project, string $projectAccessTokenName) : string
'Drupal_project',
'Node_project',
];
return $array;
}

private function createProjectAccessToken(array $project, string $projectAccessTokenName): string {
$this->io->writeln("Creating project access token...");

Expand Down
10 changes: 10 additions & 0 deletions tests/phpunit/src/CommandTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,16 @@ protected function getMockGitLabVariables(): array {
];
}

/**
* @return array<mixed>
*/
protected function getMockProjectTypeValue(): array {
return [
'Drupal_project',
'Node_project',
];
}

/**
* Normalize strings for Windows tests.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public function testCommand(array $mockedGitlabProjects, array $inputs, array $a

/** @var Filesystem|ObjectProphecy $fileSystem */
$fileSystem = $this->prophet->prophesize(Filesystem::class);

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

Expand Down Expand Up @@ -462,6 +462,11 @@ protected function mockGitLabNamespaces(ObjectProphecy $gitlabClient): void {
$gitlabClient->namespaces()->willReturn($namespaces->reveal());
}

protected function mockGitlabProjectType(int $gitlabProjectId): void {
$projectType = $this->getMockProjectTypeValue();
$this->assertCount(2, $projectType);
}

protected function mockGitLabVariables(int $gitlabProjectId, ObjectProphecy $projects): void {
$variables = $this->getMockGitLabVariables();
$projects->variables($gitlabProjectId)->willReturn($variables);
Expand Down

0 comments on commit 3f0507d

Please sign in to comment.