2019-09-17 12:09:51 +02:00
|
|
|
<?php
|
|
|
|
|
2022-06-04 17:31:21 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2022-02-23 03:48:51 +01:00
|
|
|
namespace phpseclib3\Tests\Functional\Net;
|
|
|
|
|
2019-11-07 06:41:40 +01:00
|
|
|
use phpseclib3\Exception\UnableToConnectException;
|
2022-01-30 16:34:42 +01:00
|
|
|
use phpseclib3\Net\SFTP;
|
2019-09-17 12:09:51 +02:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
|
|
class SFTPWrongServerTest extends TestCase
|
|
|
|
{
|
2022-06-04 17:31:21 +02:00
|
|
|
public function testLoginToInvalidServer(): void
|
2019-09-17 12:09:51 +02:00
|
|
|
{
|
|
|
|
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 09:49:37 +02:00
|
|
|
// getaddrinfo message seems not to return stable text
|
|
|
|
static::assertSame(
|
2022-02-17 03:25:59 +01:00
|
|
|
'Cannot connect to dummy-server:22. Error 0. php_network_getaddresses: getaddrinfo',
|
|
|
|
substr($e->getMessage(), 0, 81)
|
2020-07-28 09:49:37 +02:00
|
|
|
);
|
2019-09-17 12:09:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|