gearman_client_020.phpt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. --TEST--
  2. GearmanClient::clearCallbacks(), gearman_client_clear_callbacks()
  3. --SKIPIF--
  4. <?php if (!extension_loaded("gearman")) print "skip";
  5. require_once('skipifconnect.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. $client = new GearmanClient();
  10. $client->addServer('localhost', 4730);
  11. print "GearmanClient::clearCallbacks (OO) (No callbacks set): " . ($client->clearCallbacks() ? 'Success' : 'Failure') . PHP_EOL;
  12. $client->setWorkloadCallback(function($task, $context){});
  13. $client->setCreatedCallback(function($task, $context){});
  14. $client->setDataCallback(function($task, $context){});
  15. $client->setWarningCallback(function($task, $context){});
  16. $client->setStatusCallback(function($task, $context){});
  17. $client->setCompleteCallback(function($task, $context){});
  18. $client->setExceptionCallback(function($task, $context){});
  19. $client->setFailCallback(function($task, $context){});
  20. print "GearmanClient::clearCallbacks (OO) (Callbacks set): " . ($client->clearCallbacks() ? 'Success' : 'Failure') . PHP_EOL;
  21. $client2 = gearman_client_create();
  22. gearman_client_add_server($client2, 'localhost', 4730);
  23. print "gearman_client_clear_callbacks (Procedural) (No callbacks set: "
  24. . (gearman_client_clear_callbacks($client2) ? 'Success' : 'Failure') . PHP_EOL;
  25. gearman_client_set_workload_callback($client2, function($task, $context){});
  26. gearman_client_set_created_callback($client2, function($task, $context){});
  27. gearman_client_set_data_callback($client2, function($task, $context){});
  28. gearman_client_set_warning_callback($client2, function($task, $context){});
  29. gearman_client_set_status_callback($client2, function($task, $context){});
  30. gearman_client_set_complete_callback($client2, function($task, $context){});
  31. gearman_client_set_exception_callback($client2, function($task, $context){});
  32. gearman_client_set_fail_callback($client2, function($task, $context){});
  33. print "gearman_client_clear_callbacks (Procedural) (Callbacks set: "
  34. . (gearman_client_clear_callbacks($client2) ? 'Success' : 'Failure') . PHP_EOL;
  35. print "OK";
  36. ?>
  37. --EXPECT--
  38. GearmanClient::clearCallbacks (OO) (No callbacks set): Success
  39. GearmanClient::clearCallbacks (OO) (Callbacks set): Success
  40. gearman_client_clear_callbacks (Procedural) (No callbacks set: Success
  41. gearman_client_clear_callbacks (Procedural) (Callbacks set: Success
  42. OK