2019-09-17 10:09:51 +00:00
|
|
|
<?php
|
|
|
|
|
2019-11-07 05:41:40 +00:00
|
|
|
use phpseclib3\Exception\UnableToConnectException;
|
2022-01-30 15:34:42 +00:00
|
|
|
use phpseclib3\Net\SFTP;
|
2019-09-17 10:09:51 +00:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class SFTPWrongServerTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testLoginToInvalidServer()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
(new SFTP('dummy-server'))->login('username', 'password');
|
|
|
|
static::fail('The connection to the non-existent server must not succeed.');
|
|
|
|
} catch (UnableToConnectException $e) {
|
2020-07-28 07:49:37 +00:00
|
|
|
// getaddrinfo message seems not to return stable text
|
|
|
|
static::assertSame(
|
2021-11-29 13:23:49 +00:00
|
|
|
'Cannot connect to dummy-server:22. Error 0. php_network_getaddresses: getaddrinfo',
|
|
|
|
substr($e->getMessage(),0,81)
|
2020-07-28 07:49:37 +00:00
|
|
|
);
|
2019-09-17 10:09:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|