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