gearman_task_004.phpt 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. --TEST--
  2. GearmanTask::is_known(), gearman_task_is_known(),
  3. GearmanTask::is_running(), gearman_task_is_running(),
  4. GearmanTask::numerator(), gearman_task_numerator(),
  5. GearmanTask::denominator(), gearman_task_denominator()
  6. --SKIPIF--
  7. <?php if (!extension_loaded("gearman")) print "skip";
  8. require_once('skipifconnect.inc');
  9. ?>
  10. --FILE--
  11. <?php
  12. $client = new GearmanClient();
  13. $client->addServer('localhost', 4730);
  14. $client->setCreatedCallback(function ($task) {
  15. print "GearmanTask::isKnown (OO): "
  16. . ($task->isKnown() === true ? 'Success' : 'Failure') . PHP_EOL;
  17. print "GearmanTask::isRunning (OO): "
  18. . ($task->isRunning() === false ? 'Success' : 'Failure') . PHP_EOL;
  19. print "GearmanTask::taskNumerator (OO): "
  20. . ($task->taskNumerator() == 0 ? 'Success' : 'Failure') . PHP_EOL;
  21. print "GearmanTask::taskDenominator (OO): "
  22. . ($task->taskDenominator() == 0 ? 'Success' : 'Failure') . PHP_EOL;
  23. });
  24. $client->addTaskBackground("GearmanTaskFunction", "normal");
  25. $client->runTasks();
  26. $client2 = gearman_client_create();
  27. gearman_client_add_server($client2, 'localhost', 4730);
  28. gearman_client_set_created_callback($client2, function ($task) {
  29. print "gearman_task_is_known (Procedural): "
  30. . (gearman_task_is_known($task) === true ? 'Success' : 'Failure') . PHP_EOL;
  31. print "gearman_task_is_running (Procedural): "
  32. . (gearman_task_is_running($task) === false ? 'Success' : 'Failure') . PHP_EOL;
  33. print "gearman_task_numerator (Procedural): "
  34. . (gearman_task_numerator($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
  35. print "gearman_task_denominator (Procedural): "
  36. . (gearman_task_denominator($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
  37. });
  38. gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
  39. gearman_client_run_tasks($client2);
  40. print "OK";
  41. ?>
  42. --EXPECT--
  43. GearmanTask::isKnown (OO): Success
  44. GearmanTask::isRunning (OO): Success
  45. GearmanTask::taskNumerator (OO): Success
  46. GearmanTask::taskDenominator (OO): Success
  47. gearman_task_is_known (Procedural): Success
  48. gearman_task_is_running (Procedural): Success
  49. gearman_task_numerator (Procedural): Success
  50. gearman_task_denominator (Procedural): Success
  51. OK