test_msghandler.phpt 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. --TEST--
  2. Sybase-CT server message handler
  3. --SKIPIF--
  4. <?php require('skipif.inc'); ?>
  5. --FILE--
  6. <?php
  7. /* This file is part of PHP test framework for ext/sybase_ct
  8. *
  9. * $Id$
  10. */
  11. require('test.inc');
  12. $db= sybase_connect_ex();
  13. echo 'Nonexistent: '; sybase_set_messagehandler_ex('function_does_not_exist');
  14. echo 'Static method: '; sybase_set_messagehandler_ex(array('sybase', 'static_handler'));
  15. echo 'Instance method: '; sybase_set_messagehandler_ex(array(new sybase(), 'handler'));
  16. echo 'Lambda function: '; sybase_set_messagehandler_ex(create_function('', 'return FALSE;'));
  17. echo 'Unset: '; sybase_set_messagehandler_ex(NULL);
  18. echo 'Incorrect type: '; sybase_set_messagehandler_ex(1);
  19. echo 'Function: '; sybase_set_messagehandler_ex('sybase_msg_handler');
  20. var_dump(sybase_select_ex($db, 'select getdate(NULL)'));
  21. sybase_close($db);
  22. ?>
  23. --EXPECTF--
  24. Nonexistent:
  25. Warning: sybase_set_message_handler() expects parameter 1 to be a valid callback, function 'function_does_not_exist' not found or invalid function name in %stest.inc on line %d
  26. NULL
  27. Static method: bool(true)
  28. Instance method: bool(true)
  29. Lambda function: bool(true)
  30. Unset: bool(true)
  31. Incorrect type:
  32. Warning: sybase_set_message_handler() expects parameter 1 to be a valid callback, no array or string given in %stest.inc on line %d
  33. NULL
  34. Function: bool(true)
  35. >>> Query: select getdate(NULL)
  36. *** Caught Sybase Server Message #%d [Severity %d, state %d] at line %d
  37. %s
  38. <<< Return: boolean
  39. bool(false)