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