Skip to content

Commit 395e40c

Browse files
committed
Add tests for rsync_rsh helper and improve argument type handling
1 parent ac03ff6 commit 395e40c

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/Support/helpers.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ function rsync_rsh(array $args): string
256256
{
257257
$parts = ['ssh'];
258258
foreach ($args as $option) {
259+
if (is_integer($option)) {
260+
$option = (string) $option;
261+
}
259262
if (str_contains($option, "\0")) {
260263
throw new \InvalidArgumentException('rsync_rsh: NUL byte not allowed in ssh option');
261264
}

tests/issues/PortIntTest.php

Whitespace-only changes.

tests/src/Support/HelpersTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,11 @@ public function testParseHomeDir()
5959
$this->assertStringStartsWith('~', parse_home_dir('~path'));
6060
$this->assertStringEndsWith('~', parse_home_dir('path~'));
6161
}
62+
63+
public function testRsyncRsh()
64+
{
65+
$this->assertEquals("ssh -p 22", rsync_rsh(['-p', 22]));
66+
$this->assertEquals("ssh 'argument with spaces'", rsync_rsh(['argument with spaces']));
67+
$this->assertEquals("ssh 'argument with '' quote'", rsync_rsh(['argument with \' quote']));
68+
}
6269
}

0 commit comments

Comments
 (0)