xref: /PHP-7.4/ext/snmp/tests/snmp2_set-nomib.phpt (revision 26dfce7f)
1--TEST--
2Function snmp2_set (without MIBs loading)
3--CREDITS--
4Boris Lytockin
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 = snmp2_set($hostname, $communityWrite, '.1.3.6.777.888.999.444.0', 's', 'bbb', $timeout, $retries);
22var_dump($z);
23
24echo "Bogus OID\n";
25$z = snmp2_set($hostname, $communityWrite, '.1.3.6...777.888.999.444.0', 's', 'bbb', $timeout, $retries);
26var_dump($z);
27
28echo "Checking working\n";
29$oid1 = '.1.3.6.1.2.1.1.4.0';
30$oldvalue1 = snmpget($hostname, $communityWrite, $oid1, $timeout, $retries);
31$newvalue1 = $oldvalue1 . '0';
32
33echo "Single OID\n";
34$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $newvalue1, $timeout, $retries);
35var_dump($z);
36var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $newvalue1));
37$z = snmp2_set($hostname, $communityWrite, $oid1, 's', $oldvalue1, $timeout, $retries);
38var_dump($z);
39var_dump((snmpget($hostname, $communityWrite, $oid1, $timeout, $retries) === $oldvalue1));
40
41?>
42--EXPECTF--
43Check error handing
44Nonexisting OID
45
46Warning: snmp2_set(): Error in packet at '%s': notWritable (That object does not support modification) in %s on line %d
47bool(false)
48Bogus OID
49
50Warning: snmp2_set(): Invalid object identifier: %s in %s on line %d
51bool(false)
52Checking working
53Single OID
54bool(true)
55bool(true)
56bool(true)
57bool(true)
58