From fa3757c9201f209c2979f9794e33a2538eacb422 Mon Sep 17 00:00:00 2001 From: Alexis Guyomar Date: Mon, 3 Feb 2025 09:03:02 +0100 Subject: [PATCH] fix: php stan errors --- classes/Parameters/RestoreConfigurationValidator.php | 10 ++++++++-- .../Parameters/RestoreConfigurationValidatorTest.php | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/classes/Parameters/RestoreConfigurationValidator.php b/classes/Parameters/RestoreConfigurationValidator.php index 23fe20bb2..b4305324f 100644 --- a/classes/Parameters/RestoreConfigurationValidator.php +++ b/classes/Parameters/RestoreConfigurationValidator.php @@ -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; diff --git a/tests/unit/Parameters/RestoreConfigurationValidatorTest.php b/tests/unit/Parameters/RestoreConfigurationValidatorTest.php index 8c19f6015..6b3093e31 100644 --- a/tests/unit/Parameters/RestoreConfigurationValidatorTest.php +++ b/tests/unit/Parameters/RestoreConfigurationValidatorTest.php @@ -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 @@ -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