Annotation of embedaddon/php/ext/snmp/tests/snmp-object-error.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--                                 
                      2: OO API: Generic errors
                      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_quick_print(false);
                     15: snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
                     16: 
                     17: try {
                     18: var_dump(new SNMP(SNMP::VERSION_1, $hostname));
                     19: } catch (Exception $e) {
                     20:        print $e->getMessage() . "\n";
                     21: }
                     22: try {
                     23: var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, ''));
                     24: } catch (Exception $e) {
                     25:        print $e->getMessage() . "\n";
                     26: }
                     27: try {
                     28: var_dump(new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, ''));
                     29: } catch (Exception $e) {
                     30:        print $e->getMessage() . "\n";
                     31: }
                     32: try {
                     33: var_dump(new SNMP(7, $hostname, $community));
                     34: } catch (Exception $e) {
                     35:        print $e->getMessage() . "\n";
                     36: }
                     37: 
                     38: echo "Exception handling\n";
                     39: $session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries);
                     40: try {
                     41:        var_dump($session->get('.1.3.6.1.2.1.1.1..0'));
                     42: } catch (SNMPException $e) {
                     43:        var_dump($e->getCode());
                     44:        var_dump($e->getMessage());
                     45: }
                     46: $session->exceptions_enabled = SNMP::ERRNO_ANY;
                     47: try {
                     48:        var_dump($session->get('.1.3.6.1.2.1.1.1..0'));
                     49: } catch (SNMPException $e) {
                     50:        var_dump($e->getCode());
                     51:        var_dump($e->getMessage());
                     52: }
                     53: var_dump($session->close());
                     54: 
                     55: echo "Open normal session\n";
                     56: $session = new SNMP(SNMP::VERSION_3, $hostname, $user_noauth, $timeout, $retries);
                     57: $session->valueretrieval = 67;
                     58: var_dump($session->valueretrieval);
                     59: echo "Closing session\n";
                     60: var_dump($session->close(''));
                     61: var_dump($session->close());
                     62: var_dump($session->get('.1.3.6.1.2.1.1.1.0'));
                     63: var_dump($session->close());
                     64: 
                     65: $session = new SNMP(SNMP::VERSION_2c, $hostname, $community, $timeout, $retries);
                     66: var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, ''));
                     67: var_dump($session->walk('.1.3.6.1.2.1.1', FALSE, 30, ''));
                     68: var_dump($session->get());
                     69: var_dump($session->getnext());
                     70: var_dump($session->set());
                     71: 
                     72: var_dump($session->max_oids);
                     73: $session->max_oids = "ttt";
                     74: $session->max_oids = 0;
                     75: var_dump($session->max_oids);
                     76: ?>
                     77: --EXPECTF--
                     78: SNMP::__construct() expects at least 3 parameters, 2 given
                     79: SNMP::__construct() expects parameter 4 to be long, string given
                     80: SNMP::__construct() expects parameter 5 to be long, string given
                     81: Unknown SNMP protocol version
                     82: Exception handling
                     83: 
                     84: Warning: SNMP::get(): Invalid object identifier: .1.3.6.1.2.1.1.1..0 in %s on line %d
                     85: bool(false)
                     86: int(32)
                     87: string(46) "Invalid object identifier: .1.3.6.1.2.1.1.1..0"
                     88: bool(true)
                     89: Open normal session
                     90: 
                     91: Warning: main(): Unknown SNMP value retrieval method '67' in %s on line %d
                     92: int(%d)
                     93: Closing session
                     94: 
                     95: Warning: SNMP::close() expects exactly 0 parameters, 1 given in %s on line %d
                     96: bool(false)
                     97: bool(true)
                     98: 
                     99: Warning: SNMP::get(): Invalid or uninitialized SNMP object in %s on line %d
                    100: bool(false)
                    101: bool(true)
                    102: 
                    103: Warning: SNMP::walk() expects parameter 3 to be long, string given in %s on line %d
                    104: bool(false)
                    105: 
                    106: Warning: SNMP::walk() expects parameter 4 to be long, string given in %s on line %d
                    107: bool(false)
                    108: 
                    109: Warning: SNMP::get() expects at least 1 parameter, 0 given in %s on line %d
                    110: bool(false)
                    111: 
                    112: Warning: SNMP::getnext() expects exactly 1 parameter, 0 given in %s on line %d
                    113: bool(false)
                    114: 
                    115: Warning: SNMP::set() expects exactly 3 parameters, 0 given in %s on line %d
                    116: bool(false)
                    117: NULL
                    118: 
                    119: Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d
                    120: 
                    121: Warning: main(): max_oids should be positive integer or NULL, got 0 in %s on line %d
                    122: NULL

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>