Annotation of embedaddon/php/ext/snmp/tests/snmp-object-properties.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: OO API: SNMP object properties
3: --CREDITS--
4: Boris Lytochkin
5: --SKIPIF--
6: <?php
7: require_once(dirname(__FILE__).'/skipif.inc');
8: ?>
9: --FILE--
10: <?php
11: require_once(dirname(__FILE__).'/snmp_include.inc');
12:
13: //EXPECTF format is quickprint OFF
14: snmp_set_enum_print(false);
15: snmp_set_quick_print(false);
16: snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
17: snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL);
18:
19: echo "Check working\n";
20:
21: $session = new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, $retries);
22: var_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:
31: var_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:
40: var_dump($session);
41:
42: var_dump(property_exists($session, "enum_print"));
43: var_dump(isset($session->enum_print));
44: var_dump(empty($session->enum_print));
45:
46: $param=123;
47: $session->$param = "param_value";
48: var_dump($session);
49: var_dump($session->$param);
50: var_dump(property_exists($session, $param));
51:
52: echo "Error handling\n";
53: $param = 'there is no such parameter';
54: var_dump($session->$param);
55: var_dump(property_exists($session, $param));
56:
57: $session->valueretrieval = 67;
58: var_dump($session->valueretrieval);
59: $session->oid_output_format = 78;
60: var_dump($session->oid_output_format);
61:
62: $session->info = array("blah" => 2);
63: var_dump($session->info);
64:
65: $session->max_oids = NULL;
66: var_dump($session->max_oids);
67: ?>
68: --EXPECTF--
69: Check working
70: object(SNMP)#%d (%d) {
71: ["info"]=>
72: array(4) {
73: ["hostname"]=>
74: %string|unicode%(%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: }
97: object(SNMP)#%d (%d) {
98: ["info"]=>
99: array(4) {
100: ["hostname"]=>
101: %string|unicode%(%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: }
124: object(SNMP)#%d (%d) {
125: ["info"]=>
126: array(4) {
127: ["hostname"]=>
128: %string|unicode%(%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: }
151: bool(true)
152: bool(true)
153: bool(false)
154: object(SNMP)#%d (%d) {
155: ["info"]=>
156: array(4) {
157: ["hostname"]=>
158: %string|unicode%(%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: }
183: string(11) "param_value"
184: bool(true)
185: Error handling
186:
187: Notice: Undefined property: SNMP::$there is no such parameter in %s on line %d
188: NULL
189: bool(false)
190:
191: Warning: main(): Unknown SNMP value retrieval method '67' in %s on line %d
192: int(1)
193:
194: Warning: main(): Unknown SNMP output print format '78' in %s on line %d
195: int(3)
196:
197: Warning: main(): info property is read-only in %s on line %d
198: array(4) {
199: ["hostname"]=>
200: %string|unicode%(%d) "%s"
201: ["port"]=>
202: int(%d)
203: ["timeout"]=>
204: int(%i)
205: ["retries"]=>
206: int(%d)
207: }
208: NULL
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>