toBeInstanceOf(DiskName::class) ->and($vo->value)->toBe('local') ->and($vo->driver)->toBe($driver); })->with([ 'local driver' => 'local', 'ftp driver' => 'ftp', 'sftp driver' => 'sftp', 's3 driver' => 's3', ]); it('can instantiate with a BackedEnum value', function (): void { // GIVEN $enumValue = TestDiskBackedEnum::Local; $driver = 'local'; // WHEN $vo = new DiskName($enumValue, $driver); // THEN expect($vo)->toBeInstanceOf(DiskName::class) ->and($vo->value)->toBe('local') ->and($vo->driver)->toBe('local'); }); it('can instantiate with a UnitEnum value', function (): void { // GIVEN $enumValue = TestDiskUnitEnum::local; $driver = 'local'; // WHEN $vo = new DiskName($enumValue, $driver); // THEN expect($vo)->toBeInstanceOf(DiskName::class) ->and($vo->value)->toBe('local') ->and($vo->driver)->toBe('local'); }); }); describe('DiskName validation', function (): void { it('throws exception if disk does not exist', function (): void { // GIVEN $nonExistentDisk = 'non_existent_disk'; $driver = 'local'; // WHEN $action = fn () => new DiskName($nonExistentDisk, $driver); // THEN expect($action)->toThrow( UnexpectedStorageException::class, "Disk 'non_existent_disk' does not exist." ); }); it('throws exception if disk driver is not allowed', function (string $invalidDriver): void { // GIVEN $diskName = 'local'; // WHEN $action = fn () => new DiskName($diskName, $invalidDriver); // THEN expect($action)->toThrow( UnexpectedStorageException::class, "Disk driver '{$invalidDriver}' is not allowed." ); })->with([ 'unsupported driver dropbox' => 'dropbox', 'unsupported driver gcs' => 'gcs', 'empty driver' => '', ]); }); describe('DiskName string representation', function (): void { it('can be cast to string', function (): void { // GIVEN $vo = new DiskName('local', 'local'); // WHEN $str = (string) $vo; // THEN expect($str)->toBe('local') ->and($vo->__toString())->toBe('local'); }); });