gearman_worker_012.phpt 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. --TEST--
  2. gearman_worker_register(), gearman_worker_unregister(), gearman_worker_unregister_all()
  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. $registered_func = 'registered_function';
  12. $worker = new GearmanWorker();
  13. $worker->addServer($host, $port);
  14. print "GearmanWorker::register() (OO): " . ($worker->register($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
  15. print "GearmanWorker::unregister() (OO): " . ($worker->unregister($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
  16. print "GearmanWorker::register() (OO): " . ($worker->register($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
  17. print "GearmanWorker::unregisterAll() (OO): " . ($worker->unregisterAll() === true ? "Success" : "Failure") . PHP_EOL;
  18. $worker2 = gearman_worker_create();
  19. gearman_worker_add_server($worker, $host, $port);
  20. print "gearman_worker_register() (Procedural): " . (gearman_worker_register($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
  21. print "gearman_worker_unregister() (Procedural): " . (gearman_worker_unregister($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
  22. print "gearman_worker_register() (Procedural): " . (gearman_worker_register($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
  23. print "gearman_worker_unregister_all() (Procedural): " . (gearman_worker_unregister_all($worker) === true ? "Success" : "Failure") . PHP_EOL;
  24. print "OK";
  25. function registered_function() {
  26. print "I'm in ".__FUNCTION__.PHP_EOL;
  27. }
  28. ?>
  29. --EXPECT--
  30. GearmanWorker::register() (OO): Success
  31. GearmanWorker::unregister() (OO): Success
  32. GearmanWorker::register() (OO): Success
  33. GearmanWorker::unregisterAll() (OO): Success
  34. gearman_worker_register() (Procedural): Success
  35. gearman_worker_unregister() (Procedural): Success
  36. gearman_worker_register() (Procedural): Success
  37. gearman_worker_unregister_all() (Procedural): Success
  38. OK