Adding getter for timeout to SSH2

This commit is contained in:
Robert 2023-02-28 12:52:01 -06:00
parent 6d7f0def17
commit d012d6cd03
2 changed files with 20 additions and 0 deletions

View File

@ -2374,6 +2374,16 @@ class SSH2
throw new ConnectionClosedException('Unexpected response to publickey authentication pt 2');
}
/**
* Return the currently configured timeout
*
* @return int
*/
public function getTimeout(): int
{
return $this->timeout;
}
/**
* Set Timeout
*

View File

@ -143,6 +143,16 @@ class SSH2UnitTest extends PhpseclibTestCase
$this->assertSame('{' . spl_object_hash($ssh) . '}', $ssh->getResourceId());
}
public function testGetTimeout(): void
{
$ssh = new SSH2('localhost');
$this->assertEquals(10, $ssh->getTimeout());
$ssh->setTimeout(0);
$this->assertEquals(0, $ssh->getTimeout());
$ssh->setTimeout(20);
$this->assertEquals(20, $ssh->getTimeout());
}
/**
*/
protected function createSSHMock(): SSH2