gearman_client_017.phpt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. --TEST--
  2. GearmanClient::jobStatus(), gearman_client_job_status()
  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. $job_handle = $client->doBackground($job_name . "_OO", "test_jobStatus");
  13. list($is_known, $is_running, $numerator, $denominator) = $client->jobStatus($job_handle);
  14. print "GearmanClient::jobStatus() (OO): " . PHP_EOL
  15. . " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
  16. PHP_EOL
  17. . " is_running is false: " . ($is_running=== false ? 'Success' : 'Failure') .
  18. PHP_EOL
  19. . " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
  20. PHP_EOL
  21. . " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
  22. PHP_EOL;
  23. $client2 = gearman_client_create();
  24. gearman_client_add_server($client2, 'localhost', 4730);
  25. $job_handle = gearman_client_do_background($client2, $job_name .
  26. "_procedural", "test_jobStatus");
  27. list($is_known, $is_running, $numerator, $denominator) =
  28. gearman_client_job_status($client2, $job_handle);
  29. print "gearman_client_job_status() (Procedural): " . PHP_EOL
  30. . " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
  31. PHP_EOL
  32. . " is_running is false: " . ($is_running === false ? 'Success' : 'Failure') .
  33. PHP_EOL
  34. . " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
  35. PHP_EOL
  36. . " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
  37. PHP_EOL;
  38. print "OK";
  39. ?>
  40. --EXPECT--
  41. GearmanClient::jobStatus() (OO):
  42. is_known is true: Success
  43. is_running is false: Success
  44. Numerator is 0: Success
  45. Denominator is 0: Success
  46. gearman_client_job_status() (Procedural):
  47. is_known is true: Success
  48. is_running is false: Success
  49. Numerator is 0: Success
  50. Denominator is 0: Success
  51. OK