summaryrefslogtreecommitdiff
path: root/ext/snmp/tests/snmp-object-properties.phpt
blob: 6b368d6fec8ea073f836c91d10d1df0d86e2b395 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
--TEST--                                 
OO API: SNMP object properties
--CREDITS--
Boris Lytochkin
--SKIPIF--
<?php
require_once(dirname(__FILE__).'/skipif.inc');
?>
--FILE--
<?php
require_once(dirname(__FILE__).'/snmp_include.inc');

//EXPECTF format is quickprint OFF
snmp_set_enum_print(false);
snmp_set_quick_print(false);
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
snmp_set_oid_output_format(SNMP_OID_OUTPUT_FULL);

echo "Check working\n";

$session = new SNMP(SNMP_VERSION_1, $hostname, $community, $timeout, $retries);
var_dump($session);

$session->enum_print = TRUE;
$session->quick_print = TRUE;
$session->valueretrieval = SNMP_VALUE_LIBRARY;
$session->oid_output_format = SNMP_OID_OUTPUT_NUMERIC;

var_dump($session);

$session->enum_print = "1";
$session->quick_print = "1";
$session->valueretrieval = "1";
$session->oid_output_format = "3";

var_dump($session);

var_dump(property_exists($session, "enum_print"));
var_dump(isset($session->enum_print));
var_dump(empty($session->enum_print));

$param=123;
$session->$param = "param_value";
var_dump($session);
var_dump($session->$param);
var_dump(property_exists($session, $param));

echo "Error handling\n";
$param = 'there is no such parameter';
var_dump($session->$param);
var_dump(property_exists($session, $param));

$session->valueretrieval = 67;
var_dump($session->valueretrieval);
$session->oid_output_format = 78;
var_dump($session->oid_output_format);

?>
--EXPECTF--
Check working
object(SNMP)#%d (%d) {
  ["valueretrieval"]=>
  int(1)
  ["quick_print"]=>
  bool(false)
  ["enum_print"]=>
  bool(false)
  ["oid_output_format"]=>
  int(3)
}
object(SNMP)#%d (%d) {
  ["valueretrieval"]=>
  int(0)
  ["quick_print"]=>
  bool(true)
  ["enum_print"]=>
  bool(true)
  ["oid_output_format"]=>
  int(4)
}
object(SNMP)#%d (%d) {
  ["valueretrieval"]=>
  int(1)
  ["quick_print"]=>
  bool(true)
  ["enum_print"]=>
  bool(true)
  ["oid_output_format"]=>
  int(3)
}
bool(true)
bool(true)
bool(false)
object(SNMP)#%d (%d) {
  ["valueretrieval"]=>
  int(1)
  ["quick_print"]=>
  bool(true)
  ["enum_print"]=>
  bool(true)
  ["oid_output_format"]=>
  int(3)
  ["123"]=>
  string(11) "param_value"
}
string(11) "param_value"
bool(true)
Error handling

Notice: Undefined property: SNMP::$there is no such parameter in %s on line %d
NULL
bool(false)

Warning: main(): Unknown SNMP value retrieval method '67' in %s on line %d
int(1)

Warning: main(): Unknown SNMP output print format '78' in %s on line %d
int(3)