1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-13 01:27:40 +01:00
phpseclib/tests/Functional/Net/SFTPWrongServerTest.php

23 lines
719 B
PHP
Raw Normal View History

2019-09-17 12:09:51 +02:00
<?php
use phpseclib3\Net\SFTP;
use phpseclib3\Exception\UnableToConnectException;
2019-09-17 12:09:51 +02: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) {
// getaddrinfo message seems not to return stable text
static::assertSame(
'Cannot connect to dummy-server:22. Error 0. php_network_getaddresses: getaddrinfo failed:',
substr($e->getMessage(),0,89)
);
2019-09-17 12:09:51 +02:00
}
}
}