From 71b9b64203efd58dd0236701672c4a1cb0f50210 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Sat, 4 Mar 2023 20:47:49 -0600 Subject: [PATCH] CS adjustments --- phpseclib/Net/SSH2.php | 10 ++++++++++ tests/Unit/Net/SSH2UnitTest.php | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index e0e06374..9a0133fd 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -2664,6 +2664,16 @@ class SSH2 throw new ConnectionClosedException('Unexpected response to publickey authentication pt 2'); } + /** + * Return the currently configured timeout + * + * @return int + */ + public function getTimeout() + { + return $this->timeout; + } + /** * Set Timeout * diff --git a/tests/Unit/Net/SSH2UnitTest.php b/tests/Unit/Net/SSH2UnitTest.php index 7d3e154e..d41358a8 100644 --- a/tests/Unit/Net/SSH2UnitTest.php +++ b/tests/Unit/Net/SSH2UnitTest.php @@ -8,6 +8,7 @@ namespace phpseclib3\Tests\Unit\Net; +use phpseclib3\Net\SSH2; use phpseclib3\Tests\PhpseclibTestCase; class SSH2UnitTest extends PhpseclibTestCase @@ -135,16 +136,26 @@ class SSH2UnitTest extends PhpseclibTestCase public function testGetConnectionByResourceId() { - $ssh = new \phpseclib3\Net\SSH2('localhost'); + $ssh = new SSH2('localhost'); $this->assertSame($ssh, \phpseclib3\Net\SSH2::getConnectionByResourceId($ssh->getResourceId())); } public function testGetResourceId() { - $ssh = new \phpseclib3\Net\SSH2('localhost'); + $ssh = new SSH2('localhost'); $this->assertSame('{' . spl_object_hash($ssh) . '}', $ssh->getResourceId()); } + public function testGetTimeout() + { + $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()); + } + /** * @return \phpseclib3\Net\SSH2 */