gearman_client_integration_test_002.phpt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. --TEST--
  2. GearmanClient::setStatusCallback(), gearman_client_set_status_callback(),
  3. GearmanClient::addTaskStatus(), gearman_client_add_task_status(),
  4. GearmanClient::runTasks(), gearman_client_run_tasks()
  5. --SKIPIF--
  6. <?php if (!extension_loaded("gearman")) print "skip";
  7. require_once('skipifconnect.inc');
  8. ?>
  9. --FILE--
  10. <?php
  11. function reverse_status($task, $context)
  12. {
  13. print "In " . __FUNCTION__
  14. . " context is '$context'"
  15. . PHP_EOL;
  16. }
  17. $client = new GearmanClient();
  18. $client->addServer('localhost');
  19. $handle = $client->doBackground("reverse", "Hello World!");
  20. $client->setStatusCallback("reverse_status");
  21. $oo_context = "context passed in through OO";
  22. $client->addTaskStatus($handle, $oo_context);
  23. // Should print within reverse_status
  24. $client->runTasks();
  25. $client2 = gearman_client_create();
  26. gearman_client_add_server($client2, 'localhost', 4730);
  27. $handle = gearman_client_do_background($client2, "reverse", "Hello World!");
  28. gearman_client_set_status_callback($client2, "reverse_status");
  29. $procedural_context = "context passed in through procedural";
  30. gearman_client_add_task_status($client2, $handle, $procedural_context);
  31. gearman_client_run_tasks($client2);
  32. print "OK";
  33. ?>
  34. --EXPECT--
  35. In reverse_status context is 'context passed in through OO'
  36. In reverse_status context is 'context passed in through procedural'
  37. OK