mock-socket.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * This file is used by tests to overload and mock various socket/stream calls.
  4. */
  5. namespace WebSocket;
  6. function stream_socket_server($local_socket, &$errno, &$errstr)
  7. {
  8. $args = [$local_socket, $errno, $errstr];
  9. return MockSocket::handle('stream_socket_server', $args);
  10. }
  11. function stream_socket_accept()
  12. {
  13. $args = func_get_args();
  14. return MockSocket::handle('stream_socket_accept', $args);
  15. }
  16. function stream_set_timeout()
  17. {
  18. $args = func_get_args();
  19. return MockSocket::handle('stream_set_timeout', $args);
  20. }
  21. function stream_get_line()
  22. {
  23. $args = func_get_args();
  24. return MockSocket::handle('stream_get_line', $args);
  25. }
  26. function stream_get_meta_data()
  27. {
  28. $args = func_get_args();
  29. return MockSocket::handle('stream_get_meta_data', $args);
  30. }
  31. function feof()
  32. {
  33. $args = func_get_args();
  34. return MockSocket::handle('feof', $args);
  35. }
  36. function fclose()
  37. {
  38. $args = func_get_args();
  39. return MockSocket::handle('fclose', $args);
  40. }
  41. function fwrite()
  42. {
  43. $args = func_get_args();
  44. return MockSocket::handle('fwrite', $args);
  45. }
  46. function fread()
  47. {
  48. $args = func_get_args();
  49. return MockSocket::handle('fread', $args);
  50. }
  51. function stream_context_create()
  52. {
  53. $args = func_get_args();
  54. return MockSocket::handle('stream_context_create', $args);
  55. }
  56. function stream_socket_client($remote_socket, &$errno, &$errstr, $timeout, $flags, $context)
  57. {
  58. $args = [$remote_socket, $errno, $errstr, $timeout, $flags, $context];
  59. return MockSocket::handle('stream_socket_client', $args);
  60. }
  61. function get_resource_type()
  62. {
  63. $args = func_get_args();
  64. return MockSocket::handle('get_resource_type', $args);
  65. }