gearman_task_003.phpt 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. --TEST--
  2. GearmanTask::jobHandle(), gearman_task_job_handle()
  3. --SKIPIF--
  4. <?php if (!extension_loaded("gearman")) print "skip";
  5. require_once('skipifconnect.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. $client = new GearmanClient();
  10. $client->addServer('localhost', 4730);
  11. $client->setCreatedCallback(function ($task) {
  12. print "GearmanTask::jobHandle (OO): "
  13. . (preg_match('/^(.*):(.*):(.*)$/', $task->jobHandle())
  14. ? 'String matches' : 'String does not match')
  15. . PHP_EOL;
  16. });
  17. $client->addTaskBackground("GearmanTaskFunction", "normal");
  18. $client->runTasks();
  19. $client2 = gearman_client_create();
  20. gearman_client_add_server($client2, 'localhost', 4730);
  21. gearman_client_set_created_callback($client2, function ($task) {
  22. print "gearman_task_job_handle (Procedural): "
  23. . (preg_match('/^(.*):(.*):(.*)$/', $task->jobHandle())
  24. ? 'String matches' : 'String does not match')
  25. . PHP_EOL;
  26. });
  27. gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
  28. gearman_client_run_tasks($client2);
  29. print "OK";
  30. ?>
  31. --EXPECT--
  32. GearmanTask::jobHandle (OO): String matches
  33. gearman_task_job_handle (Procedural): String matches
  34. OK