xref: /PHP-7.4/ext/snmp/tests/snmpset-nomib.phpt (revision 26dfce7f)
1--TEST--
2Function snmpset (without MIBs loading)
3--CREDITS--
4Boris Lytochkin
5--SKIPIF--
6<?php
7require_once(__DIR__.'/skipif.inc');
8?>
9--ENV--
10MIBS=
11--FILE--
12<?php
13require_once(__DIR__.'/snmp_include.inc');
14
15//EXPECTF format is quickprint OFF
16snmp_set_quick_print(false);
17snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
18
19echo "Check error handing\n";
20echo "Nonexisting OID\n";
21$z = snmpset($hostname, $communityWrite, '.1.3.6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
22var_dump($z);
23
24echo "Bogus OID\n";
25$z = snmpset($hostname, $communityWrite, '.1.3...6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
26var_dump($z);
27
28
29echo "Checking working\n";
30$oid1 = '.1.3.6.1.2.1.1.4.0';
31$oldvalue1 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
32$newvalue1 = $oldvalue1 . '0';
33
34echo "Single OID\n";
35$z = snmpset($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries);
36var_dump($z);
37var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
38$z = snmpset($hostname, $communityWrite, $oid1, 's', $oldvalue1, $timeout, $retries);
39var_dump($z);
40var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
41
42?>
43--EXPECTF--
44Check error handing
45Nonexisting OID
46
47Warning: snmpset(): Error in packet at '%s': (noSuchName) There is no such variable name in this MIB. in %s on line %d
48bool(false)
49Bogus OID
50
51Warning: snmpset(): Invalid object identifier: %s in %s on line %d
52bool(false)
53Checking working
54Single OID
55bool(true)
56bool(true)
57bool(true)
58bool(true)
59