xref: /PHP-8.2/ext/snmp/tests/bug60749.phpt (revision c289f524)
1--TEST--
2Bug #60749: SNMP module should not strip non-standard SNMP port from hostname
3--CREDITS--
4Boris Lytochkin
5--EXTENSIONS--
6snmp
7--SKIPIF--
8<?php
9require_once(__DIR__.'/skipif.inc');
10?>
11--FILE--
12<?php
13require_once(__DIR__.'/snmp_include.inc');
14
15$hostname = "php.net";
16$ip = gethostbyname($hostname);
17if (ip2long($ip) === FALSE) {
18    echo "Could not resolve $hostname properly!\n";
19    exit(1);
20}
21$port = 1161;
22$session = new SNMP(SNMP::VERSION_1, "$hostname:$port", $community, $timeout, $retries);
23$info = $session->info;
24if (!str_ends_with($info["hostname"], ":$port")) {
25    echo "'" . $info["hostname"] . "' != '$ip:$port'\n";
26}
27var_dump($session->close());
28?>
29--EXPECT--
30bool(true)
31