Skip to content

Commit

Permalink
fix: php stan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ga-devfront committed Feb 7, 2025
1 parent 05a34cf commit fa3757c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions classes/Parameters/RestoreConfigurationValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ public function validate(array $array = []): array

$backupNameErrors = $this->validateBackupName($array);
if ($backupNameErrors) {
$errors[] = $backupNameErrors;
$errors[] = [
'message' => $backupNameErrors,
'target' => RestoreConfiguration::BACKUP_NAME
];

return $errors;
}

$backupNameExistErrors = $this->validateBackupExist($array[RestoreConfiguration::BACKUP_NAME]);
if ($backupNameExistErrors) {
$errors[] = $backupNameExistErrors;
$errors[] = [
'message' => $backupNameExistErrors,
'target' => RestoreConfiguration::BACKUP_NAME
];;
}

return $errors;
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Parameters/RestoreConfigurationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function testValidateReturnsErrorWhenBackupNameIsMissing(): void
$errors = $this->validator->validate([]);

$this->assertCount(1, $errors);
$this->assertSame('Backup name is missing', $errors[0]);
$this->assertSame(['message' => 'Backup name is missing', 'target' => RestoreConfiguration::BACKUP_NAME], $errors[0]);
}

public function testValidateReturnsErrorWhenBackupDoesNotExist(): void
Expand All @@ -46,7 +46,7 @@ public function testValidateReturnsErrorWhenBackupDoesNotExist(): void
$errors = $this->validator->validate([RestoreConfiguration::BACKUP_NAME => $backupName]);

$this->assertCount(1, $errors);
$this->assertSame('Backup non_existing_backup.zip does not exist', $errors[0]);
$this->assertSame(['message' => 'Backup non_existing_backup.zip does not exist', 'target' => RestoreConfiguration::BACKUP_NAME], $errors[0]);
}

public function testValidateReturnsNoErrorsWhenBackupIsValid(): void
Expand Down

0 comments on commit fa3757c

Please sign in to comment.