phpseclib/tests/Functional/Net/SFTPWrongServerTest.php
Jack Worman ef66d9f7dd php-cs-fixer ci
php-cs-fixer ci
2022-02-01 20:29:48 -06:00

23 lines
711 B
PHP

<?php
use phpseclib3\Exception\UnableToConnectException;
use phpseclib3\Net\SFTP;
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',
substr($e->getMessage(),0,81)
);
}
}
}