gearman_task_005.phpt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --TEST--
  2. GearmanTask::data(), gearman_task_data(),
  3. GearmanTask::dataSize(), gearman_task_data_size()
  4. --SKIPIF--
  5. <?php if (!extension_loaded("gearman")) print "skip";
  6. require_once('skipifconnect.inc');
  7. ?>
  8. --FILE--
  9. <?php
  10. $client = new GearmanClient();
  11. $client->addServer('localhost', 4730);
  12. $client->setCreatedCallback(function ($task) {
  13. print "GearmanTask::data (OO): "
  14. . ($task->data() === '' ? 'Success' : 'Failure') . PHP_EOL;
  15. print "GearmanTask::dataSize (OO): "
  16. . ($task->dataSize() == 0 ? 'Success' : 'Failure') . PHP_EOL;
  17. });
  18. $client->addTaskBackground("GearmanTaskFunction", "normal", "OO data");
  19. $client->runTasks();
  20. $client2 = gearman_client_create();
  21. gearman_client_add_server($client2, 'localhost', 4730);
  22. gearman_client_set_created_callback($client2, function ($task) {
  23. print "gearman_task_data (Procedural): "
  24. . (gearman_task_data($task) === '' ? 'Success' : 'Failure') . PHP_EOL;
  25. print "gearman_task_data_size (Procedural): "
  26. . (gearman_task_data_size($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
  27. });
  28. gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
  29. gearman_client_run_tasks($client2);
  30. print "OK";
  31. ?>
  32. --EXPECT--
  33. GearmanTask::data (OO): Success
  34. GearmanTask::dataSize (OO): Success
  35. gearman_task_data (Procedural): Success
  36. gearman_task_data_size (Procedural): Success
  37. OK