snmp-object-properties-error.phpt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. --TEST--
  2. Test SNMP object property errors
  3. --EXTENSIONS--
  4. snmp
  5. --SKIPIF--
  6. <?php
  7. require_once(__DIR__.'/skipif.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. require_once(__DIR__.'/snmp_include.inc');
  12. $session = new SNMP(SNMP::VERSION_1, $hostname, $community, $timeout, $retries);
  13. try {
  14. $session->info = [];
  15. } catch (Error $exception) {
  16. echo $exception->getMessage() . "\n";
  17. }
  18. try {
  19. $session->info += [];
  20. } catch (Error $exception) {
  21. echo $exception->getMessage() . "\n";
  22. }
  23. try {
  24. $session->max_oids = [];
  25. } catch (TypeError $exception) {
  26. echo $exception->getMessage() . "\n";
  27. }
  28. try {
  29. $session->max_oids = -1;
  30. } catch (ValueError $exception) {
  31. echo $exception->getMessage() . "\n";
  32. }
  33. try {
  34. $session->valueretrieval = [];
  35. } catch (TypeError $exception) {
  36. echo $exception->getMessage() . "\n";
  37. }
  38. try {
  39. $session->quick_print = [];
  40. } catch (TypeError $exception) {
  41. echo $exception->getMessage() . "\n";
  42. }
  43. try {
  44. $session->enum_print = [];
  45. } catch (TypeError $exception) {
  46. echo $exception->getMessage() . "\n";
  47. }
  48. try {
  49. $session->oid_output_format = [];
  50. } catch (TypeError $exception) {
  51. echo $exception->getMessage() . "\n";
  52. }
  53. try {
  54. $session->oid_increasing_check = [];
  55. } catch (TypeError $exception) {
  56. echo $exception->getMessage() . "\n";
  57. }
  58. try {
  59. $session->exceptions_enabled = [];
  60. } catch (TypeError $exception) {
  61. echo $exception->getMessage() . "\n";
  62. }
  63. ?>
  64. --EXPECT--
  65. Cannot write read-only property SNMP::$info
  66. Cannot write read-only property SNMP::$info
  67. Cannot assign array to property SNMP::$max_oids of type ?int
  68. SNMP::$max_oids must be greater than 0 or null
  69. Cannot assign array to property SNMP::$valueretrieval of type int
  70. Cannot assign array to property SNMP::$quick_print of type bool
  71. Cannot assign array to property SNMP::$enum_print of type bool
  72. Cannot assign array to property SNMP::$oid_output_format of type int
  73. Cannot assign array to property SNMP::$oid_increasing_check of type bool
  74. Cannot assign array to property SNMP::$exceptions_enabled of type int