gearman_client_018.phpt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. --TEST--
  2. GearmanClient::jobStatusByUniqueKey(), gearman_client_job_status_by_unique_key()
  3. --SKIPIF--
  4. <?php if (!extension_loaded("gearman")) print "skip";
  5. require_once('skipifconnect.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. $job_name = uniqid();
  10. $client = new GearmanClient();
  11. $client->addServer('localhost', 4730);
  12. $oo_key = $job_name . "_oo";
  13. $client->doBackground($job_name . "_OO", "test_jobStatusByUniqueKey");
  14. list($is_known, $is_running, $numerator, $denominator) =
  15. $client->jobStatusByUniqueKey($oo_key);
  16. print "GearmanClient::doStatus() (OO): " . PHP_EOL
  17. /*
  18. Note: This is returning falso, while jobStatus returns true.
  19. Looks to be across multiple versions of libgearman (1.0.2 and 1.1.2 checked)
  20. . " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
  21. PHP_EOL
  22. */
  23. . " is_running is false: " . ($is_running=== false ? 'Success' : 'Failure') .
  24. PHP_EOL
  25. . " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
  26. PHP_EOL
  27. . " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
  28. PHP_EOL;
  29. $client2 = gearman_client_create();
  30. gearman_client_add_server($client2, 'localhost', 4730);
  31. $procedural_key = $job_name . "_procedural";
  32. $job_handle = gearman_client_do_background($client2, $job_name .
  33. "_procedural", "test_jobStatusByUniqueKey");
  34. list($is_known, $is_running, $numerator, $denominator) =
  35. gearman_client_job_status_by_unique_key($client2, $procedural_key);
  36. print "gearman_client_job_status_by_unique_key() (Procedural): " . PHP_EOL
  37. /*
  38. Note: This is returning falso, while jobStatus returns true.
  39. Looks to be across multiple versions of libgearman (1.0.2 and 1.1.2 checked)
  40. . " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
  41. PHP_EOL
  42. */
  43. . " is_running is false: " . ($is_running === false ? 'Success' : 'Failure') .
  44. PHP_EOL
  45. . " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
  46. PHP_EOL
  47. . " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
  48. PHP_EOL;
  49. print "OK";
  50. ?>
  51. --EXPECT--
  52. GearmanClient::doStatus() (OO):
  53. is_running is false: Success
  54. Numerator is 0: Success
  55. Denominator is 0: Success
  56. gearman_client_job_status_by_unique_key() (Procedural):
  57. is_running is false: Success
  58. Numerator is 0: Success
  59. Denominator is 0: Success
  60. OK