xref: /PHP-5.6/ext/snmp/tests/snmpset-nomib.phpt (revision 14eaa5ac)
1--TEST--
2Function snmpset (without MIBs loading)
3--CREDITS--
4Boris Lytochkin
5--SKIPIF--
6<?php
7require_once(dirname(__FILE__).'/skipif.inc');
8?>
9--ENV--
10return <<<END
11MIBS=
12END;
13--FILE--
14<?php
15require_once(dirname(__FILE__).'/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