gearman_worker_013.phpt 826 B

1234567891011121314151617181920212223242526272829303132
  1. --TEST--
  2. gearman_worker_add_function()
  3. --SKIPIF--
  4. <?php if (!extension_loaded("gearman")) print "skip";
  5. require_once('skipifconnect.inc');
  6. ?>
  7. --FILE--
  8. <?php
  9. $host = 'localhost';
  10. $port = 4730;
  11. $job = 'GenericJob';
  12. $func = 'do_work';
  13. $worker = new GearmanWorker();
  14. $worker->addServer($host, $port);
  15. print "GearmanWorker::addFunction() (OO): ".($worker->addFunction($job, $func) ? "Success" : "Failure").PHP_EOL;
  16. $worker2 = gearman_worker_create();
  17. gearman_worker_add_server($worker, $host, $port);
  18. print "gearman_worker_add_function() (Procedural): ".(gearman_worker_add_function($worker, $job, $func) ? "Success" : "Failure").PHP_EOL;
  19. print "OK";
  20. function do_work() {
  21. print "I'm in ".__FUNCTION__.PHP_EOL;
  22. }
  23. ?>
  24. --EXPECT--
  25. GearmanWorker::addFunction() (OO): Success
  26. gearman_worker_add_function() (Procedural): Success
  27. OK