1--TEST--
2OO API: SNMP object properties
3--CREDITS--
4Boris Lytochkin
5--SKIPIF--
6<?php
7require_once(__DIR__.'/skipif.inc');
8?>
9--FILE--
10<?php
11require_once(__DIR__.'/snmp_include.inc');
12
13//EXPECTF format is quickprint OFF
14snmp_set_enum_print(false);
15snmp_set_quick_print(false);
16snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
17snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL);
18
19echo "Check working\n";
20
21$session = new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, $retries);
22var_dump($session);
23
24$session->max_oids = 40;
25$session->enum_print = TRUE;
26$session->quick_print = TRUE;
27$session->valueretrieval = SNMP_VALUE_LIBRARY;
28$session->oid_output_format = SNMP_OID_OUTPUT_NUMERIC;
29$session->oid_increasing_check = FALSE;
30
31var_dump($session);
32
33$session->max_oids = "40";
34$session->enum_print = "1";
35$session->quick_print = "1";
36$session->valueretrieval = "1";
37$session->oid_output_format = "3";
38$session->oid_increasing_check = "45";
39
40var_dump($session);
41
42var_dump(property_exists($session, "enum_print"));
43var_dump(isset($session->enum_print));
44var_dump(empty($session->enum_print));
45
46$param=123;
47$session->$param = "param_value";
48var_dump($session);
49var_dump($session->$param);
50var_dump(property_exists($session, $param));
51
52echo "Error handling\n";
53$param = 'there is no such parameter';
54var_dump($session->$param);
55var_dump(property_exists($session, $param));
56
57$session->valueretrieval = 67;
58var_dump($session->valueretrieval);
59$session->oid_output_format = 78;
60var_dump($session->oid_output_format);
61
62$session->info = array("blah" => 2);
63var_dump($session->info);
64
65$session->max_oids = NULL;
66var_dump($session->max_oids);
67?>
68--EXPECTF--
69Check working
70object(SNMP)#%d (%d) {
71  ["info"]=>
72  array(4) {
73    ["hostname"]=>
74    string(%d) "%s"
75    ["port"]=>
76    int(%d)
77    ["timeout"]=>
78    int(%i)
79    ["retries"]=>
80    int(%d)
81  }
82  ["max_oids"]=>
83  NULL
84  ["valueretrieval"]=>
85  int(1)
86  ["quick_print"]=>
87  bool(false)
88  ["enum_print"]=>
89  bool(false)
90  ["oid_output_format"]=>
91  int(3)
92  ["oid_increasing_check"]=>
93  bool(true)
94  ["exceptions_enabled"]=>
95  int(0)
96}
97object(SNMP)#%d (%d) {
98  ["info"]=>
99  array(4) {
100    ["hostname"]=>
101    string(%d) "%s"
102    ["port"]=>
103    int(%d)
104    ["timeout"]=>
105    int(%i)
106    ["retries"]=>
107    int(%d)
108  }
109  ["max_oids"]=>
110  int(40)
111  ["valueretrieval"]=>
112  int(0)
113  ["quick_print"]=>
114  bool(true)
115  ["enum_print"]=>
116  bool(true)
117  ["oid_output_format"]=>
118  int(4)
119  ["oid_increasing_check"]=>
120  bool(false)
121  ["exceptions_enabled"]=>
122  int(0)
123}
124object(SNMP)#%d (%d) {
125  ["info"]=>
126  array(4) {
127    ["hostname"]=>
128    string(%d) "%s"
129    ["port"]=>
130    int(%d)
131    ["timeout"]=>
132    int(%i)
133    ["retries"]=>
134    int(%d)
135  }
136  ["max_oids"]=>
137  int(40)
138  ["valueretrieval"]=>
139  int(1)
140  ["quick_print"]=>
141  bool(true)
142  ["enum_print"]=>
143  bool(true)
144  ["oid_output_format"]=>
145  int(3)
146  ["oid_increasing_check"]=>
147  bool(true)
148  ["exceptions_enabled"]=>
149  int(0)
150}
151bool(true)
152bool(true)
153bool(false)
154object(SNMP)#%d (%d) {
155  ["info"]=>
156  array(4) {
157    ["hostname"]=>
158    string(%d) "%s"
159    ["port"]=>
160    int(%d)
161    ["timeout"]=>
162    int(%i)
163    ["retries"]=>
164    int(%d)
165  }
166  ["max_oids"]=>
167  int(40)
168  ["valueretrieval"]=>
169  int(1)
170  ["quick_print"]=>
171  bool(true)
172  ["enum_print"]=>
173  bool(true)
174  ["oid_output_format"]=>
175  int(3)
176  ["oid_increasing_check"]=>
177  bool(true)
178  ["exceptions_enabled"]=>
179  int(0)
180  ["123"]=>
181  string(11) "param_value"
182}
183string(11) "param_value"
184bool(true)
185Error handling
186
187Notice: Undefined property: SNMP::$there is no such parameter in %s on line %d
188NULL
189bool(false)
190
191Warning: main(): Unknown SNMP value retrieval method '67' in %s on line %d
192int(1)
193
194Warning: main(): Unknown SNMP output print format '78' in %s on line %d
195int(3)
196
197Warning: main(): info property is read-only in %s on line %d
198array(4) {
199  ["hostname"]=>
200  string(%d) "%s"
201  ["port"]=>
202  int(%d)
203  ["timeout"]=>
204  int(%i)
205  ["retries"]=>
206  int(%d)
207}
208NULL
209