gearman_client_016.phpt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. --TEST--
  2. GearmanClient::doStatus(), gearman_client_do_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->addOptions(GEARMAN_CLIENT_NON_BLOCKING);
  12. $client->addServer('localhost', 4730);
  13. # Note: Still need to figure out why doNormal is blocking despite
  14. # GEARMAN_CLIENT_NON_BLOCKING
  15. #$job_handle = $client->doNormal($job_name . "_OO", "test_doStatus");
  16. list($numerator, $denominator) = $client->doStatus();
  17. print "GearmanClient::doStatus() (OO): " . PHP_EOL
  18. . " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
  19. PHP_EOL
  20. . " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
  21. PHP_EOL;
  22. $client2 = gearman_client_create();
  23. gearman_client_add_options($client2, GEARMAN_CLIENT_NON_BLOCKING);
  24. gearman_client_add_server($client2, 'localhost', 4730);
  25. # Note: Still need to figure out why doNormal is blocking despite
  26. # GEARMAN_CLIENT_NON_BLOCKING
  27. #$job_handle = gearman_client_do_normal->($client2, $job_name . "_procedural", "test_doStatus");
  28. list($numerator, $denominator) = gearman_client_do_status($client2);
  29. print "gearman_client_do_status() (Procedural): " . PHP_EOL
  30. . " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
  31. PHP_EOL
  32. . " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
  33. PHP_EOL;
  34. print "OK";
  35. ?>
  36. --EXPECT--
  37. GearmanClient::doStatus() (OO):
  38. Numerator is 0: Success
  39. Denominator is 0: Success
  40. gearman_client_do_status() (Procedural):
  41. Numerator is 0: Success
  42. Denominator is 0: Success
  43. OK