Skip to content

Commit

Permalink
backupId can be null
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrajodas committed Jan 22, 2025
1 parent b55506d commit 36ff501
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Config/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ class Config extends BaseConfig

public const STORAGE_BACKEND_GCS = 'gcs';

public function getBackupId(): string
public function getBackupId(): ?string
{
return $this->getStringValue(['parameters', 'backupId'], '');
/** @var ?string $val */
$val = $this->getValue(['parameters', 'backupId'], '');
return $val;
}

public function getStorageBackendType(): string
Expand Down
27 changes: 27 additions & 0 deletions tests/phpunit/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,33 @@ public function testValidConfig(
Assert::assertEquals($expectedStorageBackendType, $config->getStorageBackendType());
}

public function testBackupId(): void
{
$config = new Config([
'action' => 'run',
'parameters' => [
'backupId' => '123456',
],
'image_parameters' => [
'storageBackendType' => Config::STORAGE_BACKEND_S3,
],
], new ConfigDefinition());

Assert::assertEquals('123456', $config->getBackupId());

$config = new Config([
'action' => 'run',
'parameters' => [
'backupId' => null,
],
'image_parameters' => [
'storageBackendType' => Config::STORAGE_BACKEND_S3,
],
], new ConfigDefinition());

Assert::assertEquals('', $config->getBackupId());
}

/** @dataProvider invalidConfigDataProvider */
public function testInvalidConfig(array $configArray, string $expectedExceptionMessage): void
{
Expand Down

0 comments on commit 36ff501

Please sign in to comment.