| Current File : /home/mmdealscpanel/yummmdeals.com/alt-php82-pecl-gearman_2.1.4-1.el8.zip |
PK �e�Z�y]�V V tests/gearman_client_016.phptnu �[��� --TEST--
GearmanClient::doStatus(), gearman_client_do_status()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$job_name = uniqid();
$client = new GearmanClient();
$client->addOptions(GEARMAN_CLIENT_NON_BLOCKING);
$client->addServer('localhost', 4730);
# Note: Still need to figure out why doNormal is blocking despite
# GEARMAN_CLIENT_NON_BLOCKING
#$job_handle = $client->doNormal($job_name . "_OO", "test_doStatus");
list($numerator, $denominator) = $client->doStatus();
print "GearmanClient::doStatus() (OO): " . PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_options($client2, GEARMAN_CLIENT_NON_BLOCKING);
gearman_client_add_server($client2, 'localhost', 4730);
# Note: Still need to figure out why doNormal is blocking despite
# GEARMAN_CLIENT_NON_BLOCKING
#$job_handle = gearman_client_do_normal->($client2, $job_name . "_procedural", "test_doStatus");
list($numerator, $denominator) = gearman_client_do_status($client2);
print "gearman_client_do_status() (Procedural): " . PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::doStatus() (OO):
Numerator is 0: Success
Denominator is 0: Success
gearman_client_do_status() (Procedural):
Numerator is 0: Success
Denominator is 0: Success
OK
PK �e�Z��QY Y tests/gearman_task_004.phptnu �[��� --TEST--
GearmanTask::is_known(), gearman_task_is_known(),
GearmanTask::is_running(), gearman_task_is_running(),
GearmanTask::numerator(), gearman_task_numerator(),
GearmanTask::denominator(), gearman_task_denominator()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
$client->setCreatedCallback(function ($task) {
print "GearmanTask::isKnown (OO): "
. ($task->isKnown() === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanTask::isRunning (OO): "
. ($task->isRunning() === false ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanTask::taskNumerator (OO): "
. ($task->taskNumerator() == 0 ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanTask::taskDenominator (OO): "
. ($task->taskDenominator() == 0 ? 'Success' : 'Failure') . PHP_EOL;
});
$client->addTaskBackground("GearmanTaskFunction", "normal");
$client->runTasks();
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
gearman_client_set_created_callback($client2, function ($task) {
print "gearman_task_is_known (Procedural): "
. (gearman_task_is_known($task) === true ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_task_is_running (Procedural): "
. (gearman_task_is_running($task) === false ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_task_numerator (Procedural): "
. (gearman_task_numerator($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_task_denominator (Procedural): "
. (gearman_task_denominator($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
});
gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
gearman_client_run_tasks($client2);
print "OK";
?>
--EXPECT--
GearmanTask::isKnown (OO): Success
GearmanTask::isRunning (OO): Success
GearmanTask::taskNumerator (OO): Success
GearmanTask::taskDenominator (OO): Success
gearman_task_is_known (Procedural): Success
gearman_task_is_running (Procedural): Success
gearman_task_numerator (Procedural): Success
gearman_task_denominator (Procedural): Success
OK
PK �e�Z�@�� � tests/gearman_client_008.phptnu �[��� --TEST--
GearmanClient::removeOptions(), gearman_client_remove_options()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
$client->setOptions(32);
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
print "GearmanClient::removeOptions (OO): " . ($client->removeOptions(GEARMAN_CLIENT_FREE_TASKS) ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_set_options($client2, 32);
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "gearman_client_remove_options (Procedural): " . (gearman_client_remove_options($client2, GEARMAN_CLIENT_FREE_TASKS) ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::options (OO): 32
GearmanClient::removeOptions (OO): Success
GearmanClient::options (OO): 0
gearman_client_options (Procedural): 32
gearman_client_remove_options (Procedural): Success
gearman_client_options (Procedural): 0
OK
PK �e�Z�O�& & tests/gearman_job_003.phptnu �[��� --TEST--
unserialize(serialize(GearmanJob))
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$i = 0;
while ($i <= 5) {
echo $i;
$job = new GearmanJob();
unserialize(serialize($job));
$i++;
}
print PHP_EOL;
print "OK";
?>
--EXPECT--
012345
OK
PK �e�Z�F�{ { tests/gearman_worker_011.phptnu �[��� --TEST--
gearman_worker_wait()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$host = 'localhost';
$port = 4730;
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->setTimeout(1);
/*
Still need to figure out how to test wait here...
$worker->wait();
*/
print "OK";
?>
--EXPECT--
OK
PK �e�Z�&f� + tests/gearman_job_integration_test_010.phptnu �[��� --TEST--
Test GearmanJob::workload(), GearmanJob::workloadSize()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::workload (OO): "
. $job->workload()
. PHP_EOL;
print "GearmanJob::workloadSize (OO): "
. $job->workloadSize()
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::workload (OO): normal
GearmanJob::workloadSize (OO): 6
Done
PK �e�Z>�ok tests/gearman_002.phptnu �[��� --TEST--
gearman_worker_set_id()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$worker= new GearmanWorker();
$worker->setId('test');
$worker = gearman_worker_create();
gearman_worker_set_id($worker, 'test');
echo "OK";
?>
--EXPECT--
OK
PK �e�Z�c�n5 5 tests/gearman_client_012.phptnu �[��� --TEST--
GearmanClient::addServer(), gearman_client_add_server()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient::addServer(OO), implicit port: " . ($client->addServer('localhost') ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::addServer(OO), explicit port: " . ($client->addServer('localhost', 4730) ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_add_server (Procedural), implicit port: " . (gearman_client_add_server($client2, 'localhost') ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_add_server (Procedural): explicit port" . (gearman_client_add_server($client2, 'localhost', 4730) ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::addServer(OO), implicit port: Success
GearmanClient::addServer(OO), explicit port: Success
gearman_client_add_server (Procedural), implicit port: Success
gearman_client_add_server (Procedural): explicit portSuccess
OK
PK �e�Z#|ܦ� � . tests/gearman_worker_integration_test_001.phptnu �[��� --TEST--
Test Gearman worker methods
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
print "addServer: " . var_export($worker->addServer($host, $port), true) . PHP_EOL;
print "setTimeout: " . var_export($worker->setTimeout(100), true) . PHP_EOL;
print "register: " . var_export($worker->register($job_name, 5), true) . PHP_EOL;
print "register: " . var_export($worker->register($job_name . "1", 5), true) . PHP_EOL;
print "register: " . var_export($worker->register($job_name . "2", 5), true) . PHP_EOL;
print "register: " . var_export($worker->register($job_name . "3", 5), true) . PHP_EOL;
print "addFunction: " . var_export(
$worker->addFunction(
$job_name,
function($job) {
print "workload: " . var_export($job->workload(), true) . PHP_EOL;
}
), true
) . PHP_EOL;
print "work: " . var_export($worker->work(), true) . PHP_EOL;
print "unregister: " . var_export($worker->unregister($job_name), true) . PHP_EOL;
print "unregisterAll: " . var_export($worker->unregisterAll(), true) . PHP_EOL;
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$client->doBackground($job_name, "nothing");
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
addServer: true
setTimeout: true
register: true
register: true
register: true
register: true
addFunction: true
workload: 'nothing'
work: true
unregister: true
unregisterAll: true
Done
PK �e�Z��#�^ ^ tests/gearman_task_003.phptnu �[��� --TEST--
GearmanTask::jobHandle(), gearman_task_job_handle()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
$client->setCreatedCallback(function ($task) {
print "GearmanTask::jobHandle (OO): "
. (preg_match('/^(.*):(.*):(.*)$/', $task->jobHandle())
? 'String matches' : 'String does not match')
. PHP_EOL;
});
$client->addTaskBackground("GearmanTaskFunction", "normal");
$client->runTasks();
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
gearman_client_set_created_callback($client2, function ($task) {
print "gearman_task_job_handle (Procedural): "
. (preg_match('/^(.*):(.*):(.*)$/', $task->jobHandle())
? 'String matches' : 'String does not match')
. PHP_EOL;
});
gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
gearman_client_run_tasks($client2);
print "OK";
?>
--EXPECT--
GearmanTask::jobHandle (OO): String matches
gearman_task_job_handle (Procedural): String matches
OK
PK �e�Z�Q�#h h tests/connect.incnu �[��� <?php
$host = getenv("GEARMAN_TEST_HOST") ?: "localhost";
$port = getenv("GEARMAN_TEST_PORT") ?: 4730;
PK �e�ZYS�-� � tests/gearman_client_018.phptnu �[��� --TEST--
GearmanClient::jobStatusByUniqueKey(), gearman_client_job_status_by_unique_key()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$job_name = uniqid();
$client = new GearmanClient();
$client->addServer('localhost', 4730);
$oo_key = $job_name . "_oo";
$client->doBackground($job_name . "_OO", "test_jobStatusByUniqueKey");
list($is_known, $is_running, $numerator, $denominator) =
$client->jobStatusByUniqueKey($oo_key);
print "GearmanClient::doStatus() (OO): " . PHP_EOL
/*
Note: This is returning falso, while jobStatus returns true.
Looks to be across multiple versions of libgearman (1.0.2 and 1.1.2 checked)
. " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
PHP_EOL
*/
. " is_running is false: " . ($is_running=== false ? 'Success' : 'Failure') .
PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$procedural_key = $job_name . "_procedural";
$job_handle = gearman_client_do_background($client2, $job_name .
"_procedural", "test_jobStatusByUniqueKey");
list($is_known, $is_running, $numerator, $denominator) =
gearman_client_job_status_by_unique_key($client2, $procedural_key);
print "gearman_client_job_status_by_unique_key() (Procedural): " . PHP_EOL
/*
Note: This is returning falso, while jobStatus returns true.
Looks to be across multiple versions of libgearman (1.0.2 and 1.1.2 checked)
. " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
PHP_EOL
*/
. " is_running is false: " . ($is_running === false ? 'Success' : 'Failure') .
PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::doStatus() (OO):
is_running is false: Success
Numerator is 0: Success
Denominator is 0: Success
gearman_client_job_status_by_unique_key() (Procedural):
is_running is false: Success
Numerator is 0: Success
Denominator is 0: Success
OK
PK �e�Z[P�z z tests/gearman_client_014.phptnu �[��� --TEST--
GearmanClient::wait(), gearman_client_wait()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
print "Placeholder for GearmanClient::wait function" . PHP_EOL;
/*
print "GearmanClient::wait (OO): " . ($client->wait() ? 'Success' : 'Failure') . PHP_EOL;
*/
$client2 = gearman_client_create();
/*
print "gearman_client_wait (Procedural): " . (gearman_client_wait($client2) ? 'Success' : 'Failure') . PHP_EOL;
*/
print "OK";
?>
--EXPECT--
Placeholder for GearmanClient::wait function
OK
PK �e�Z�S� � tests/gearman_client_002.phptnu �[��� --TEST--
GearmanClient::returnCode(), gearman_client_return_code()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient::returnCode (OO): " . $client->returnCode() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_return_code (Procedural): " . gearman_client_return_code($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::returnCode (OO): 0
gearman_client_return_code (Procedural): 0
OK
PK �e�Z3�~�� � tests/gearman_worker_002.phptnu �[��� --TEST--
gearman_worker_return_code()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$worker = new GearmanWorker();
print "GearmanWorker::returnCode (OO): " . $worker->returnCode() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_return_code (Procedural): " . gearman_worker_return_code($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::returnCode (OO): 0
gearman_worker_return_code (Procedural): 0
OK
PK �e�Zo~0�# # tests/gearman_worker_009.phptnu �[��� --TEST--
gearman_worker_set_id()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$id = 'test';
$worker = new GearmanWorker();
print "GearmanWorker::setId() (OO): " . ($worker->setId($id) === true ? "Success" : "Failure").PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_set_id() (Procedural): " . (gearman_worker_set_id($worker, $id) === true ? "Success" : "Failure").PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::setId() (OO): Success
gearman_worker_set_id() (Procedural): Success
OK
PK �e�Z�֦ tests/gearman_job_001.phptnu �[��� --TEST--
new GearmanJob()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$job = new GearmanJob();
print "GearmanJob() (OO) class: " . get_class($job) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanJob() (OO) class: GearmanJob
OK
PK �e�Z0%TY� � + tests/gearman_job_integration_test_006.phptnu �[��� --TEST--
Test GearmanJob::sendFail()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendFail (OO): "
. ($job->sendFail() === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendFail (OO): Success
Done
PK �e�Z��Q+� � + tests/gearman_job_integration_test_001.phptnu �[��� --TEST--
Test GearmanJob::sendData()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendData (OO): "
. ($job->sendData("{'foo': 'bar'}") === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendData (OO): Success
Done
PK �e�ZL^��P P tests/gearman_worker_007.phptnu �[��� --TEST--
gearman_worker_add_options()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$worker = new GearmanWorker();
print "GearmanWorker::addOptions() (OO): " . ($worker->addOptions(GEARMAN_WORKER_NON_BLOCKING) === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanWorker::options() (OO): " . $worker->options() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_add_options() (Procedural): " . (gearman_worker_add_options($worker2, GEARMAN_WORKER_NON_BLOCKING) === true ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_worker_options() (OO): " . gearman_worker_options($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::addOptions() (OO): Success
GearmanWorker::options() (OO): 646
gearman_worker_add_options() (Procedural): Success
gearman_worker_options() (OO): 646
OK
PK �e�Z[��� � + tests/gearman_job_integration_test_005.phptnu �[��� --TEST--
Test GearmanJob::sendException()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendException (OO): "
. ($job->sendException("Sending exception from job.") === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendException (OO): Success
Done
PK �e�Z��\� � tests/gearman_client_015.phptnu �[��� --TEST--
GearmanClient::doJobHandle(), gearman_client_do_job_handle()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
$job_handle = $client->doBackground("test_doJobHandle", "test_doJobHandle");
print "GearmanClient::doJobHandle() (OO): "
. ($job_handle == $client->doJobHandle() ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$job_handle = gearman_client_do_background($client2, "test_do_job_handle", "test_do_job_handle");
print "gearman_client_do_job_handle() (Procedural): "
. ($job_handle == gearman_client_do_job_handle($client2) ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::doJobHandle() (OO): Success
gearman_client_do_job_handle() (Procedural): Success
OK
PK �e�Z3�~�� � tests/gearman_worker_001.phptnu �[��� --TEST--
gearman_worker_return_code()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$worker = new GearmanWorker();
print "GearmanWorker::returnCode (OO): " . $worker->returnCode() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_return_code (Procedural): " . gearman_worker_return_code($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::returnCode (OO): 0
gearman_worker_return_code (Procedural): 0
OK
PK �e�Z\� � tests/gearman_client_011.phptnu �[��� --TEST--
GearmanClient::context(), GearmanClient::setContext(), gearman_client_context(), gearman_client_set_context()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient::setContext(OO): " . ($client->setContext('context1_context1_context1_context1') ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::context (OO): " . $client->context() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_set_context (Procedural): " . (gearman_client_set_context($client2, 'context2_context2') ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_context (Procedural): " . gearman_client_context($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::setContext(OO): Success
GearmanClient::context (OO): context1_context1_context1_context1
gearman_client_set_context (Procedural): Success
gearman_client_context (Procedural): context2_context2
OK
PK �e�Z�2�M6 6 tests/gearman_task_005.phptnu �[��� --TEST--
GearmanTask::data(), gearman_task_data(),
GearmanTask::dataSize(), gearman_task_data_size()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
$client->setCreatedCallback(function ($task) {
print "GearmanTask::data (OO): "
. ($task->data() === '' ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanTask::dataSize (OO): "
. ($task->dataSize() == 0 ? 'Success' : 'Failure') . PHP_EOL;
});
$client->addTaskBackground("GearmanTaskFunction", "normal", "OO data");
$client->runTasks();
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
gearman_client_set_created_callback($client2, function ($task) {
print "gearman_task_data (Procedural): "
. (gearman_task_data($task) === '' ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_task_data_size (Procedural): "
. (gearman_task_data_size($task) == 0 ? 'Success' : 'Failure') . PHP_EOL;
});
gearman_client_add_task_background($client2, "GearmanTaskFunction2", "normal");
gearman_client_run_tasks($client2);
print "OK";
?>
--EXPECT--
GearmanTask::data (OO): Success
GearmanTask::dataSize (OO): Success
gearman_task_data (Procedural): Success
gearman_task_data_size (Procedural): Success
OK
PK �e�Z;@��R R tests/gearman_job_002.phptnu �[��� --TEST--
GearmanJob::returnCode(), gearman_job_return_code(),
GearmanJob::setReturn(), gearman_job_set_return()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$job = new GearmanJob();
print "GearmanJob::returnCode (OO): " . $job->returnCode() . PHP_EOL;
print "GearmanJob::setReturn with value GEARMAN_TIMEOUT (OO): "
. ($job->setReturn(GEARMAN_TIMEOUT) ? 'Success' : 'Failure')
. PHP_EOL;
print "GearmanJob::returnCode matches GEARMAN_TIMEOUT (OO): "
. ($job->returnCode() == GEARMAN_TIMEOUT ? 'Success' : 'Failure') . PHP_EOL;
$job2 = new GearmanJob();
print "gearman_job_return_code (Procedural): " . gearman_job_return_code($job2) . PHP_EOL;
print "gearman_job_set_return with value GEARMAN_TIMEOUT (Procedural): "
. (gearman_job_set_return($job2, GEARMAN_TIMEOUT) ? 'Success' : 'Failure')
. PHP_EOL;
print "gearman_job_return_code matches GEARMAN_TIMEOUT (OO): "
. (gearman_job_return_code($job2) == GEARMAN_TIMEOUT ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanJob::returnCode (OO): 0
GearmanJob::setReturn with value GEARMAN_TIMEOUT (OO): Success
GearmanJob::returnCode matches GEARMAN_TIMEOUT (OO): Success
gearman_job_return_code (Procedural): 0
gearman_job_set_return with value GEARMAN_TIMEOUT (Procedural): Success
gearman_job_return_code matches GEARMAN_TIMEOUT (OO): Success
OK
PK �e�Z8.� tests/gearman_client_005.phptnu �[��� --TEST--
GearmanClient::options(), gearman_client_options()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
$client->setOptions(32);
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_set_options($client2, 32);
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::options (OO): 32
gearman_client_options (Procedural): 32
OK
PK �e�Z�Z�� � tests/gearman_client_004.phptnu �[��� --TEST--
GearmanClient::getErrno(), gearman_client_get_errno()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient::getErrno (OO): " . $client->getErrno() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_get_errno (Procedural): " . gearman_client_get_errno($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::getErrno (OO): 0
gearman_client_get_errno (Procedural): 0
OK
PK �e�Z&�Hu� � tests/gearman_task_002.phptnu �[��� --TEST--
GearmanTask::unique, gearman_task_unique
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
$task = $client->addTask("GearmanTaskFunction", "normal");
print "GearmanTask::unique (OO): "
. (preg_match('/^(.*)-(.*)-(.*)-(.*)-(.*)$/', $task->unique())
? 'String matches' : 'String does not match')
. PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$task2 = gearman_client_add_task($client2, "GearmanTaskFunction2", "normal");
print "gearman_client_unique (Procedural): "
. (preg_match('/^(.*)-(.*)-(.*)-(.*)-(.*)$/', gearman_task_unique($task))
? 'String matches' : 'String does not match')
. PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanTask::unique (OO): String matches
gearman_client_unique (Procedural): String matches
OK
PK �e�Z�T*3� � tests/gearman_worker_003.phptnu �[��� --TEST--
gearman_worker_error()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$worker = new GearmanWorker();
print "GearmanWorker::error (OO): '" . $worker->error() . "'\n";
$worker2 = gearman_worker_create();
print "gearman_worker_error (Procedural): '" . gearman_worker_error($worker2) . "'\n";
print "OK";
?>
--EXPECT--
GearmanWorker::error (OO): ''
gearman_worker_error (Procedural): ''
OK
PK �e�Z��Y� � tests/gearman_worker_015.phptnu �[��� --TEST--
gearman_worker_ping()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$host = 'localhost';
$port = 4730;
$json_workload = '{"workload":"test"}';
$worker = new GearmanWorker();
$worker->addServer($host, $port);
echo "GearmanWorker::server() (OO): ".($worker->ping($json_workload) ? "Success" : "Failure").PHP_EOL;
$worker2 = gearman_worker_create();
gearman_worker_add_server($worker, $host, $port);
echo "gearman_worker_work() (Procedural): ".($worker->ping($json_workload) ? "Success" : "Failure").PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::server() (OO): Success
gearman_worker_work() (Procedural): Success
OK
PK �e�Z�Y�� � tests/skipif.incnu �[��� <?php
if (!extension_loaded("gearman")) {
die("skip gearman extension unavailable");
}
if (!extension_loaded("pcntl")) {
die("skip pcntl extension unavailable");
}
PK �e�Z�r�� � tests/gearman_worker_008.phptnu �[��� --TEST--
gearman_worker_timeout(), gearman_worker_set_timeout()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$timeout = 5;
$worker = new GearmanWorker();
print "GearmanWorker::timeout() (OO, before setting): " . $worker->timeout() . PHP_EOL;
print "GearmanWorker::setTimeout() (OO): " .($worker->setTimeout($timeout) === true ? "Success" : "Failure") . PHP_EOL;
print "GearmanWorker::timeout() (OO, after setting): " . $worker->timeout() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_timeout() (Procedural, before setting): " . gearman_worker_timeout($worker2) . PHP_EOL;
print "gearman_worker_set_timeout() (Procedural): " . (gearman_worker_set_timeout($worker2, $timeout) === true ? "Success" : "Failure") . PHP_EOL;
print "gearman_worker_timeout() (Procedural, after setting): " . gearman_worker_timeout($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::timeout() (OO, before setting): -1
GearmanWorker::setTimeout() (OO): Success
GearmanWorker::timeout() (OO, after setting): 5
gearman_worker_timeout() (Procedural, before setting): -1
gearman_worker_set_timeout() (Procedural): Success
gearman_worker_timeout() (Procedural, after setting): 5
OK
PK �e�Zi�d]� � tests/gearman_client_003.phptnu �[��� --TEST--
GearmanClient::error(), gearman_client_error()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient::error (OO): '" . $client->error() . "'\n";
$client2 = gearman_client_create();
print "gearman_client_error (Procedural): '" . gearman_client_error($client2) . "'\n";
print "OK";
?>
--EXPECT--
GearmanClient::error (OO): ''
gearman_client_error (Procedural): ''
OK
PK �e�ZPq�� � tests/gearman_client_009.phptnu �[��� --TEST--
GearmanClient::timeout(), gearman_client_timeout()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient::timeout (OO): " . $client->timeout() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_timeout (Procedural): " . gearman_client_timeout($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::timeout (OO): -1
gearman_client_timeout (Procedural): -1
OK
PK �e�Z�7R R tests/gearman_worker_006.phptnu �[��� --TEST--
gearman_worker_set_options()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$worker = new GearmanWorker();
print "GearmanWorker::setOptions (OO): " . ($worker->setOptions(GEARMAN_WORKER_NON_BLOCKING) === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanWorker::options() (OO): " . $worker->options() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_set_options (Procedural): " . (gearman_worker_set_options($worker, GEARMAN_WORKER_NON_BLOCKING) === true ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_worker_options() (Procedural): " . gearman_worker_options($worker) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::setOptions (OO): Success
GearmanWorker::options() (OO): 6
gearman_worker_set_options (Procedural): Success
gearman_worker_options() (Procedural): 6
OK
PK �e�Zˠ/ߣ � + tests/gearman_job_integration_test_009.phptnu �[��� --TEST--
Test GearmanJob::unique()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::unique (OO): "
. (preg_match('/^(.*)-(.*)-(.*)-(.*)-(.*)$/',$job->unique()) ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::unique (OO): Success
Done
PK �e�Z�{{�� � tests/gearman_001.phptnu �[��� --TEST--
Check for gearman presence
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
echo "gearman extension is available";
?>
--EXPECT--
gearman extension is available
PK �e�Z@m�� � tests/gearman_client_020.phptnu �[��� --TEST--
GearmanClient::clearCallbacks(), gearman_client_clear_callbacks()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
print "GearmanClient::clearCallbacks (OO) (No callbacks set): " . ($client->clearCallbacks() ? 'Success' : 'Failure') . PHP_EOL;
$client->setWorkloadCallback(function($task, $context){});
$client->setCreatedCallback(function($task, $context){});
$client->setDataCallback(function($task, $context){});
$client->setWarningCallback(function($task, $context){});
$client->setStatusCallback(function($task, $context){});
$client->setCompleteCallback(function($task, $context){});
$client->setExceptionCallback(function($task, $context){});
$client->setFailCallback(function($task, $context){});
print "GearmanClient::clearCallbacks (OO) (Callbacks set): " . ($client->clearCallbacks() ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
print "gearman_client_clear_callbacks (Procedural) (No callbacks set: "
. (gearman_client_clear_callbacks($client2) ? 'Success' : 'Failure') . PHP_EOL;
gearman_client_set_workload_callback($client2, function($task, $context){});
gearman_client_set_created_callback($client2, function($task, $context){});
gearman_client_set_data_callback($client2, function($task, $context){});
gearman_client_set_warning_callback($client2, function($task, $context){});
gearman_client_set_status_callback($client2, function($task, $context){});
gearman_client_set_complete_callback($client2, function($task, $context){});
gearman_client_set_exception_callback($client2, function($task, $context){});
gearman_client_set_fail_callback($client2, function($task, $context){});
print "gearman_client_clear_callbacks (Procedural) (Callbacks set: "
. (gearman_client_clear_callbacks($client2) ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::clearCallbacks (OO) (No callbacks set): Success
GearmanClient::clearCallbacks (OO) (Callbacks set): Success
gearman_client_clear_callbacks (Procedural) (No callbacks set: Success
gearman_client_clear_callbacks (Procedural) (Callbacks set: Success
OK
PK �e�Z�gd-� � + tests/gearman_job_integration_test_003.phptnu �[��� --TEST--
Test GearmanJob::sendStatus
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendStatus (OO): "
. ($job->sendStatus(1,2) === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendStatus (OO): Success
Done
PK �e�Zr�~�� � tests/gearman_client_006.phptnu �[��� --TEST--
GearmanClient::setOptions(), gearman_client_set_options()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
$client->setOptions(32);
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
print "GearmanClient::setOptions (OO): " . ($client->setOptions(GEARMAN_CLIENT_NON_BLOCKING) ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_set_options($client2, 32);
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "gearman_client_set_options (Procedural): " . (gearman_client_set_options($client2, GEARMAN_CLIENT_NON_BLOCKING) ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::options (OO): 32
GearmanClient::setOptions (OO): Success
GearmanClient::options (OO): 2
gearman_client_options (Procedural): 32
gearman_client_set_options (Procedural): Success
gearman_client_options (Procedural): 2
OK
PK �e�Z�{� � + tests/gearman_job_integration_test_008.phptnu �[��� --TEST--
Test GearmanJob::functionName()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
global $job_name;
print "GearmanJob::functionName (OO): "
. ($job->functionName() == $job_name ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::functionName (OO): Success
Done
PK �e�Zh��� � tests/gearman_worker_004.phptnu �[��� --TEST--
gearman_worker_errno()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$worker = new GearmanWorker();
print "GearmanWorker::getErrno (OO): " . $worker->getErrno() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_errno (Procedural): " . gearman_worker_errno($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::getErrno (OO): 0
gearman_worker_errno (Procedural): 0
OK
PK �e�Z���8 tests/gearman_worker_010.phptnu �[��� --TEST--
gearman_worker_add_server(), gearman_worker_add_servers()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$host = 'localhost';
$port = 4730;
$worker = new GearmanWorker();
print "GearmanWorker::addServer() (OO):" . ($worker->addServer($host, $port) === true ? "Success" : "Failure").PHP_EOL;
print "GearmanWorker::addServers() (OO): " . ($worker->addServers("$host:$port") === true ? "Success" : "Failure").PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_add_server() (Procedural): " . (gearman_worker_add_server($worker, $host, $port) === true ? "Success" : "Failure").PHP_EOL;
print "gearman_worker_add_servers() (Procedural): " . (gearman_worker_add_servers($worker, "$host:$port") === true ? "Success" : "Failure").PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::addServer() (OO):Success
GearmanWorker::addServers() (OO): Success
gearman_worker_add_server() (Procedural): Success
gearman_worker_add_servers() (Procedural): Success
OK
PK �e�Zw���2 2 tests/gearman_worker_017.phptnu �[��� --TEST--
unserialize(serialize(GearmanWorker))
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$i = 0;
while ($i <= 5) {
echo $i;
$client = new GearmanWorker();
unserialize(serialize($client));
$i++;
}
print PHP_EOL;
print "OK";
?>
--EXPECT--
012345
OK
PK �e�Z�]�� � - tests/gearman_tasks_integration_test_001.phptnu �[��� --TEST--
Test Gearman worker methods
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
print "addServer: " . var_export($worker->addServer($host, $port), true) . PHP_EOL;
print "addFunction: " . var_export(
$worker->addFunction(
$job_name,
function($job) {
print "workload: " . var_export($job->workload(), true) . PHP_EOL;
}
),
true
) . PHP_EOL;
for ($i = 0; $i < 6; $i++) {
$worker->work();
}
print "unregister: " . var_export($worker->unregister($job_name), true) . PHP_EOL;
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$tasks[] = $client->addTaskBackground($job_name, "normalbg");
$tasks[] = $client->addTaskHigh($job_name, 1);
$tasks[] = $client->addTaskHighBackground($job_name, 2.0);
$tasks[] = $client->addTaskLow($job_name, "low");
$tasks[] = $client->addTaskLowBackground($job_name, true);
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
addServer: true
addFunction: true
workload: '2'
workload: '1'
workload: 'normalbg'
workload: 'normal'
workload: '1'
workload: 'low'
unregister: true
Done
PK �e�Z�۰�� � tests/gearman_client_001.phptnu �[��� --TEST--
new GearmanClient(), gearman_client_create()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient() (OO) class: " . get_class($client) . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_create() (Procedural) class: " . get_class($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient() (OO) class: GearmanClient
gearman_client_create() (Procedural) class: GearmanClient
OK
PK �e�Zl���- - tests/gearman_task_006.phptnu �[��� --TEST--
unserialize(serialize(GearmanTask))
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$i = 0;
while ($i <= 5) {
echo $i;
$client = new GearmanTask();
unserialize(serialize($client));
$i++;
}
print PHP_EOL;
print "OK";
?>
--EXPECT--
012345
OK
PK �e�Z
�9 9 - tests/gearman_tasks_integration_test_002.phptnu �[��� --TEST--
Test Gearman worker methods
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
require_once('skipifversion.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$contexts = [
"success",
"fail",
"exception"
];
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid == 0) {
// Child. This is the worker.
// Don't echo anything here
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job) {
if ($job->workload() == "success") {
return "done";
} else if ($job->workload() == "exception") {
$job->sendException("unhandled");
return "exception";
} else if ($job->workload() == "fail") {
$job->sendFail();
return "fail";
}
}
);
for ($i = 0; $i < count($contexts); $i++) {
$worker->work();
}
$worker->unregister($job_name);
exit(0);
} else {
//Parent. This is the client.
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$client->setCompleteCallback(function($task) {
print "Complete: " . $task->data() . PHP_EOL;
});
$client->setDataCallback(function($task) {
print "Data: " . $task->data() . PHP_EOL;
});
$client->setExceptionCallback(function($task) {
print "Exception: " . $task->data() . PHP_EOL;
});
$client->setFailCallback(function($task) {
print "Fail" . PHP_EOL;
});
$tasks = [];
foreach ($contexts as $c) {
$tasks[] = $client->addTask($job_name, $c);
}
$client->runTasks();
print "returnCode: " . var_export($client->returnCode(), true) . PHP_EOL;
print "clearCallbacks: " . var_export($client->clearCallbacks(), true) . PHP_EOL;
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
}
print "Done";
--EXPECTF--
Start
Exception: unhandled
Fail
Complete: done
returnCode: 0
clearCallbacks: true
Done
PK �e�Z��1� � tests/skipifconnect.incnu �[��� <?php
if (getenv("SKIP_ONLINE_TESTS")) die("skip online test");
require_once('connect.inc');
$sock = @fsockopen($host, $port);
if ($sock === false) {
die("skip unable to connect");
}
$command = "getpid\n";
if (fwrite($sock, $command) !== strlen($command)) {
die("skip unable to write getpid");
}
if (fread($sock, 8) === false) {
die("skip unable to read pid");
}
fclose($sock);
PK �e�Zڤp�;
;
tests/gearman_client_021.phptnu �[��� --TEST--
GearmanClient::enableExceptionHandler(),gearman_client_enable_exception_handler()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
// Test 1: GearmanClient::addServers, Exception callback disabled. Exceptions
// should be skipped until we call enableExceptionHandler. Port 4731 is not
// being used as the port for GearmanD, so it will fail
$client = new GearmanClient();
$client->addServers('localhost:4731,localhost', false);
// Enabling the exception handler, which will attempt to connect to
// the server and in doing so throw an exception since we can't
// connect to a server that doesn't exist
try {
$client->enableExceptionHandler();
} catch (Exception $e) {
print "Exception 1 caught: " . $e->getMessage() . PHP_EOL;
}
// Test 2: GearmanClient::addServers, Exception callback enabled (by default).
// Here, we don't give the second param, so the exception handler is enabled
// upon calling addServers instead of later in enableExceptionHandler
$client2 = new GearmanClient();
try {
$client2->addServers('localhost:4731,localhost');
} catch (Exception $e) {
print "Exception 2 caught: " . $e->getMessage() . PHP_EOL;
}
// Test 3: GearmanClient::addServers, Also, when we explicitly enable in addServers
$client3 = new GearmanClient();
try {
$client3->addServers('localhost:4731,localhost', true);
} catch (Exception $e) {
print "Exception 3 caught: " . $e->getMessage() . PHP_EOL;
}
// Now, do the same as above but with addServer (singular)
// Test 4: GearmanClient::addServer, Exception callback disabled
$client4 = new GearmanClient();
$client4->addServer('localhost', 4731, false);
try {
$client4->enableExceptionHandler();
} catch (Exception $e) {
print "Exception 4 caught: " . $e->getMessage() . PHP_EOL;
}
// Test 5: GearmanClient::addServer, default
$client5 = new GearmanClient();
try {
$client5->addServer('localhost', 4731);
} catch (Exception $e) {
print "Exception 5 caught: " . $e->getMessage() . PHP_EOL;
}
// Test 6: GearmanClient::addServer, explicitly set enableExceptionHandler
$client6 = new GearmanClient();
try {
$client6->addServer('localhost', 4731, true);
} catch (Exception $e) {
print "Exception 6 caught: " . $e->getMessage() . PHP_EOL;
}
print "OK";
?>
--EXPECTF--
Exception 1 caught: Failed to set exception option
Exception 2 caught: Failed to set exception option
Exception 3 caught: Failed to set exception option
Exception 4 caught: Failed to set exception option
Exception 5 caught: Failed to set exception option
Exception 6 caught: Failed to set exception option
OK
PK �e�Z�j|� � tests/gearman_client_019.phptnu �[��� --TEST--
GearmanClient::ping(), gearman_client_ping()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
print "GearmanClient::ping (OO): " . ($client->ping('oo data') ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
print "gearman_client_ping (Procedural): "
. (gearman_client_ping($client2,'procedural data') ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::ping (OO): Success
gearman_client_ping (Procedural): Success
OK
PK �e�Z�M*2 2 tests/gearman_client_022.phptnu �[��� --TEST--
unserialize(serialize(GearmanClient))
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$i = 0;
while ($i <= 5) {
echo $i;
$client = new GearmanClient();
unserialize(serialize($client));
$i++;
}
print PHP_EOL;
print "OK";
?>
--EXPECT--
012345
OK
PK �e�Z�c��H H tests/gearman_worker_014.phptnu �[��� --TEST--
gearman_worker_work()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$host = 'localhost';
$port = 4730;
$job = 'GenericTestJob';
$func = 'do_work';
$workload = '{"workload":"test"}';
// Adding 2 jobs, one for OO and one for procedural
$client = new GearmanClient();
$client->addServer($host, $port);
$handle = $client->doBackground($job, $workload);
$client->doBackground($job, $workload);
print "GearmanWorker::doBackground() (OO): ".(preg_match('/^H:'.gethostname().':\d+$/', $handle) === 1? 'Success' : 'Failure').PHP_EOL;
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction($job, $func);
print "GearmanWorker::work() (OO): ".($worker->work() === true ? 'Success' : 'Failure') . PHP_EOL;
$worker2 = gearman_worker_create();
gearman_worker_add_server($worker, $host, $port);
gearman_worker_add_function($worker, $job, $func);
print "gearman_worker_work() (Procedural): ".(gearman_worker_work($worker) === true ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
function do_work($job) {
print "Calling function ".__FUNCTION__.PHP_EOL;
}
?>
--EXPECT--
GearmanWorker::doBackground() (OO): Success
Calling function do_work
GearmanWorker::work() (OO): Success
Calling function do_work
gearman_worker_work() (Procedural): Success
OK
PK �e�Z$rңJ J tests/gearman_client_017.phptnu �[��� --TEST--
GearmanClient::jobStatus(), gearman_client_job_status()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$job_name = uniqid();
$client = new GearmanClient();
$client->addServer('localhost', 4730);
$job_handle = $client->doBackground($job_name . "_OO", "test_jobStatus");
list($is_known, $is_running, $numerator, $denominator) = $client->jobStatus($job_handle);
print "GearmanClient::jobStatus() (OO): " . PHP_EOL
. " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
PHP_EOL
. " is_running is false: " . ($is_running=== false ? 'Success' : 'Failure') .
PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$job_handle = gearman_client_do_background($client2, $job_name .
"_procedural", "test_jobStatus");
list($is_known, $is_running, $numerator, $denominator) =
gearman_client_job_status($client2, $job_handle);
print "gearman_client_job_status() (Procedural): " . PHP_EOL
. " is_known is true: " . ($is_known === true ? 'Success' : 'Failure') .
PHP_EOL
. " is_running is false: " . ($is_running === false ? 'Success' : 'Failure') .
PHP_EOL
. " Numerator is 0: " . ($numerator == 0 ? 'Success' : 'Failure') .
PHP_EOL
. " Denominator is 0: " . ($denominator == 0 ? 'Success' : 'Failure') .
PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::jobStatus() (OO):
is_known is true: Success
is_running is false: Success
Numerator is 0: Success
Denominator is 0: Success
gearman_client_job_status() (Procedural):
is_known is true: Success
is_running is false: Success
Numerator is 0: Success
Denominator is 0: Success
OK
PK �e�Zw� . tests/gearman_client_integration_test_001.phptnu �[��� --TEST--
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$host = 'localhost';
$port = '4730';
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This should be the Worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
print "addFunction: " . var_export(
$worker->addFunction(
$job_name,
function($job) {
print "workload: " . var_export($job->workload(), true) . PHP_EOL;
}
),
true
) . PHP_EOL;
for($i=0; $i<6; $i++) {
$worker->work();
}
print "unregister: " . var_export($worker->unregister($job_name), true) . PHP_EOL;
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
print "OK" . PHP_EOL;
} else {
// Child. This is the Client
$client = new GearmanClient();
$client->addServer($host, $port);
$job_types = ['doNormal', 'doHigh', 'doLow'];
foreach ($job_types as $job_type) {
$unique_key = "{$job_name}_{$job_type}";
$workload = "Workload for $job_type";
$handle = $client->$job_type($job_name, $workload, $unique_key);
}
// Background jobs can run into a race condition if they complete out of
// order
$job_types = ['doBackground', 'doHighBackground', 'doLowBackground'];
foreach ($job_types as $job_type) {
$unique_key = "{$job_name}_{$job_type}";
$workload = "Workload for $job_type";
$handle = $client->$job_type($job_name, $workload, $unique_key);
do {
usleep(10000);
list($is_known, $is_running, $numerator, $denominator) =
$client->jobStatus($handle);
} while ($is_known === true || $is_running === true);
}
}
?>
--EXPECT--
addFunction: true
workload: 'Workload for doNormal'
workload: 'Workload for doHigh'
workload: 'Workload for doLow'
workload: 'Workload for doBackground'
workload: 'Workload for doHighBackground'
workload: 'Workload for doLowBackground'
unregister: true
OK
PK �e�Z�>[�: : tests/gearman_worker_013.phptnu �[��� --TEST--
gearman_worker_add_function()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$host = 'localhost';
$port = 4730;
$job = 'GenericJob';
$func = 'do_work';
$worker = new GearmanWorker();
$worker->addServer($host, $port);
print "GearmanWorker::addFunction() (OO): ".($worker->addFunction($job, $func) ? "Success" : "Failure").PHP_EOL;
$worker2 = gearman_worker_create();
gearman_worker_add_server($worker, $host, $port);
print "gearman_worker_add_function() (Procedural): ".(gearman_worker_add_function($worker, $job, $func) ? "Success" : "Failure").PHP_EOL;
print "OK";
function do_work() {
print "I'm in ".__FUNCTION__.PHP_EOL;
}
?>
--EXPECT--
GearmanWorker::addFunction() (OO): Success
gearman_worker_add_function() (Procedural): Success
OK
PK �e�Z�1� � tests/skipifversion.incnu �[��� <?php
$min_ver = '1.1.2';
$version_string= exec('gearmand -V');
$version = explode(' ', $version_string)[1];
if (version_compare($version, $min_ver, '<')) {
die("skip requires gearmand version >= {$min_ver}, found version {$version}\n");
}
PK �e�Z3�2 2 . tests/gearman_client_integration_test_002.phptnu �[��� --TEST--
GearmanClient::setStatusCallback(), gearman_client_set_status_callback(),
GearmanClient::addTaskStatus(), gearman_client_add_task_status(),
GearmanClient::runTasks(), gearman_client_run_tasks()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
function reverse_status($task, $context)
{
print "In " . __FUNCTION__
. " context is '$context'"
. PHP_EOL;
}
$client = new GearmanClient();
$client->addServer('localhost');
$handle = $client->doBackground("reverse", "Hello World!");
$client->setStatusCallback("reverse_status");
$oo_context = "context passed in through OO";
$client->addTaskStatus($handle, $oo_context);
// Should print within reverse_status
$client->runTasks();
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$handle = gearman_client_do_background($client2, "reverse", "Hello World!");
gearman_client_set_status_callback($client2, "reverse_status");
$procedural_context = "context passed in through procedural";
gearman_client_add_task_status($client2, $handle, $procedural_context);
gearman_client_run_tasks($client2);
print "OK";
?>
--EXPECT--
In reverse_status context is 'context passed in through OO'
In reverse_status context is 'context passed in through procedural'
OK
PK �e�Z�h� � + tests/gearman_job_integration_test_004.phptnu �[��� --TEST--
Test GearmanJob::sendComplete()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendComplete (OO): "
. ($job->sendComplete("Job is complete.") === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendComplete (OO): Success
Done
PK �e�Z�
�� � + tests/gearman_job_integration_test_007.phptnu �[��� --TEST--
Test GearmanJob::handle()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::handle (OO): "
. (preg_match('/^(.*):(.*):(.*)$/',$job->handle()) ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::handle (OO): Success
Done
PK �e�Z��M& & tests/gearman_task_001.phptnu �[��� --TEST--
GearmanTask::functionName, gearman_task_function_name
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
$client->addServer('localhost', 4730);
$task = $client->addTask("GearmanTaskFunction", "normal");
print "GearmanTask::functionName (OO): " . $task->functionName() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_add_server($client2, 'localhost', 4730);
$task2 = gearman_client_add_task($client2, "GearmanTaskFunction2", "normal");
print "gearman_client_function_name (Procedural): "
. gearman_task_function_name($task2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanTask::functionName (OO): GearmanTaskFunction
gearman_client_function_name (Procedural): GearmanTaskFunction2
OK
PK �e�Z��l� � tests/gearman_worker_005.phptnu �[��� --TEST--
gearman_worker_options()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$worker = new GearmanWorker();
print "GearmanWorker::options (OO): " . $worker->options() . PHP_EOL;
$worker2 = gearman_worker_create();
print "gearman_worker_options (Procedural): " . gearman_worker_options($worker2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanWorker::options (OO): 644
gearman_worker_options (Procedural): 644
OK
PK �e�Z�oqf� � + tests/gearman_job_integration_test_002.phptnu �[��� --TEST--
Test GearmanJob::sendWarning()
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnect.inc');
?>
--FILE--
<?php
require_once('connect.inc');
print "Start" . PHP_EOL;
$job_name = uniqid();
$pid = pcntl_fork();
if ($pid == -1) {
die("Could not fork");
} else if ($pid > 0) {
// Parent. This is the worker
$worker = new GearmanWorker();
$worker->addServer($host, $port);
$worker->addFunction(
$job_name,
function($job, $data) {
print "GearmanJob::sendWarning (OO): "
. ($job->sendWarning("Warning string") === true ? 'Success' : 'Failure')
. PHP_EOL;
}
);
$worker->work();
$worker->unregister($job_name);
// Wait for child
$exit_status = 0;
if (pcntl_wait($exit_status) <= 0) {
print "pcntl_wait exited with error" . PHP_EOL;
} else if (!pcntl_wifexited($exit_status)) {
print "child exited with error" . PHP_EOL;
}
} else {
//Child. This is the client. Don't echo anything here
$client = new GearmanClient();
if ($client->addServer($host, $port) !== true) {
exit(1); // error
};
$tasks = [];
$tasks[] = $client->addTask($job_name, "normal");
$client->runTasks();
if ($client->returnCode() != GEARMAN_SUCCESS) {
exit(2); // error
}
exit(0);
}
print "Done";
--EXPECTF--
Start
GearmanJob::sendWarning (OO): Success
Done
PK �e�Z�K�x0 0 tests/gearman_worker_016.phptnu �[��� --TEST--
GearmanWorker::addFunction(), context param
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$host = 'localhost';
$port = 4730;
$job = 'AddFunctionArrCtxTest';
$workload = '{"workload":"test"}';
$client = new GearmanClient();
$client->addServer($host, $port);
$handle = $client->doBackground($job, $workload);
$client->doBackground($job, $workload);
$client->doBackground($job, $workload);
$client->doBackground($job, $workload);
print "GearmanWorker::doBackground() (OO): ".(preg_match('/^H:'.gethostname().':\d+$/', $handle) === 1? 'Success' : 'Failure').PHP_EOL;
$worker = new TestWorker();
print "GearmanWorker::work() (OO, array ctx): " .($worker->work() === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanWorker::work() (OO, array ctx): " .($worker->work() === true ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanWorker::work() (OO, array ctx): " .($worker->work() === true ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
class TestWorker extends \GearmanWorker
{
public function __construct()
{
global $job;
parent::__construct();
$this->addServer();
$this->addFunction($job, [$this, 'test'], ['firstArg' => 'firstValue']);
}
public function test($job, $context)
{
echo "Starting job {$job->workload()}". PHP_EOL;
$firstArg = $context['firstArg'];
echo "FirstArg is $firstArg" . PHP_EOL;
}
}
?>
--EXPECT--
GearmanWorker::doBackground() (OO): Success
Starting job {"workload":"test"}
FirstArg is firstValue
GearmanWorker::work() (OO, array ctx): Success
Starting job {"workload":"test"}
FirstArg is firstValue
GearmanWorker::work() (OO, array ctx): Success
Starting job {"workload":"test"}
FirstArg is firstValue
GearmanWorker::work() (OO, array ctx): Success
OK
PK �e�Z=ౖ� � tests/gearman_worker_012.phptnu �[��� --TEST--
gearman_worker_register(), gearman_worker_unregister(), gearman_worker_unregister_all()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$host = 'localhost';
$port = 4730;
$registered_func = 'registered_function';
$worker = new GearmanWorker();
$worker->addServer($host, $port);
print "GearmanWorker::register() (OO): " . ($worker->register($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "GearmanWorker::unregister() (OO): " . ($worker->unregister($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "GearmanWorker::register() (OO): " . ($worker->register($registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "GearmanWorker::unregisterAll() (OO): " . ($worker->unregisterAll() === true ? "Success" : "Failure") . PHP_EOL;
$worker2 = gearman_worker_create();
gearman_worker_add_server($worker, $host, $port);
print "gearman_worker_register() (Procedural): " . (gearman_worker_register($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "gearman_worker_unregister() (Procedural): " . (gearman_worker_unregister($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "gearman_worker_register() (Procedural): " . (gearman_worker_register($worker, $registered_func) === true ? "Success" : "Failure") . PHP_EOL;
print "gearman_worker_unregister_all() (Procedural): " . (gearman_worker_unregister_all($worker) === true ? "Success" : "Failure") . PHP_EOL;
print "OK";
function registered_function() {
print "I'm in ".__FUNCTION__.PHP_EOL;
}
?>
--EXPECT--
GearmanWorker::register() (OO): Success
GearmanWorker::unregister() (OO): Success
GearmanWorker::register() (OO): Success
GearmanWorker::unregisterAll() (OO): Success
gearman_worker_register() (Procedural): Success
gearman_worker_unregister() (Procedural): Success
gearman_worker_register() (Procedural): Success
gearman_worker_unregister_all() (Procedural): Success
OK
PK �e�Z��� � � tests/gearman_client_007.phptnu �[��� --TEST--
GearmanClient::addOptions(), gearman_client_add_options()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
$client->setOptions(GEARMAN_CLIENT_NON_BLOCKING);
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
print "GearmanClient::addOptions (OO): " . ($client->addOptions(GEARMAN_CLIENT_FREE_TASKS) ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::options (OO): " . $client->options() . PHP_EOL;
$client2 = gearman_client_create();
gearman_client_set_options($client2, GEARMAN_CLIENT_NON_BLOCKING);
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "gearman_client_add_options (Procedural): " . (gearman_client_add_options($client2, GEARMAN_CLIENT_FREE_TASKS) ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_options (Procedural): " . gearman_client_options($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::options (OO): 2
GearmanClient::addOptions (OO): Success
GearmanClient::options (OO): 34
gearman_client_options (Procedural): 2
gearman_client_add_options (Procedural): Success
gearman_client_options (Procedural): 34
OK
PK �e�Z_�*/� � tests/gearman_client_013.phptnu �[��� --TEST--
GearmanClient::addServers(), gearman_client_add_servers()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip";
require_once('skipifconnect.inc');
?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient::addServer(OO): " . ($client->addServers('localhost,localhost:4730') ? 'Success' : 'Failure') . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_add_servers (Procedural): " . (gearman_client_add_servers($client2, 'localhost,localhost:4730') ? 'Success' : 'Failure') . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::addServer(OO): Success
gearman_client_add_servers (Procedural): Success
OK
PK �e�Z��[O
tests/gearman_client_010.phptnu �[��� --TEST--
GearmanClient::setTimeout(), gearman_client_set_timeout()
--SKIPIF--
<?php if (!extension_loaded("gearman")) print "skip"; ?>
--FILE--
<?php
$client = new GearmanClient();
print "GearmanClient::timeout (OO): " . $client->timeout() . PHP_EOL;
print "GearmanClient::setTimeout (OO): " . ($client->setTimeout(3) ? 'Success' : 'Failure') . PHP_EOL;
print "GearmanClient::timeout (OO): " . $client->timeout() . PHP_EOL;
$client2 = gearman_client_create();
print "gearman_client_timeout (Procedural): " . gearman_client_timeout($client2) . PHP_EOL;
print "gearman_client_set_timeout (Procedural): " . (gearman_client_set_timeout($client2, 3) ? 'Success' : 'Failure') . PHP_EOL;
print "gearman_client_timeout (Procedural): " . gearman_client_timeout($client2) . PHP_EOL;
print "OK";
?>
--EXPECT--
GearmanClient::timeout (OO): -1
GearmanClient::setTimeout (OO): Success
GearmanClient::timeout (OO): 3
gearman_client_timeout (Procedural): -1
gearman_client_set_timeout (Procedural): Success
gearman_client_timeout (Procedural): 3
OK
PK �e�Z�y]�V V tests/gearman_client_016.phptnu �[��� PK �e�Z��QY Y � tests/gearman_task_004.phptnu �[��� PK �e�Z�@�� � G tests/gearman_client_008.phptnu �[��� PK �e�Z�O�& & , tests/gearman_job_003.phptnu �[��� PK �e�Z�F�{ { � tests/gearman_worker_011.phptnu �[��� PK �e�Z�&f� + d tests/gearman_job_integration_test_010.phptnu �[��� PK �e�Z>�ok � tests/gearman_002.phptnu �[��� PK �e�Z�c�n5 5 3 tests/gearman_client_012.phptnu �[��� PK �e�Z#|ܦ� � . �# tests/gearman_worker_integration_test_001.phptnu �[��� PK �e�Z��#�^ ^ �, tests/gearman_task_003.phptnu �[��� PK �e�Z�Q�#h h K1 tests/connect.incnu �[��� PK �e�ZYS�-� � �1 tests/gearman_client_018.phptnu �[��� PK �e�Z[P�z z ; tests/gearman_client_014.phptnu �[��� PK �e�Z�S� � �= tests/gearman_client_002.phptnu �[��� PK �e�Z3�~�� � @ tests/gearman_worker_002.phptnu �[��� PK �e�Zo~0�# # DB tests/gearman_worker_009.phptnu �[��� PK �e�Z�֦ �D tests/gearman_job_001.phptnu �[��� PK �e�Z0%TY� � + F tests/gearman_job_integration_test_006.phptnu �[��� PK �e�Z��Q+� � + �K tests/gearman_job_integration_test_001.phptnu �[��� PK �e�ZL^��P P �Q tests/gearman_worker_007.phptnu �[��� PK �e�Z[��� � + |U tests/gearman_job_integration_test_005.phptnu �[��� PK �e�Z��\� � �[ tests/gearman_client_015.phptnu �[��� PK �e�Z3�~�� � _ tests/gearman_worker_001.phptnu �[��� PK �e�Z\� � �a tests/gearman_client_011.phptnu �[��� PK �e�Z�2�M6 6 �e tests/gearman_task_005.phptnu �[��� PK �e�Z;@��R R 1k tests/gearman_job_002.phptnu �[��� PK �e�Z8.� �p tests/gearman_client_005.phptnu �[��� PK �e�Z�Z�� � :s tests/gearman_client_004.phptnu �[��� PK �e�Z&�Hu� � nu tests/gearman_task_002.phptnu �[��� PK �e�Z�T*3� � \y tests/gearman_worker_003.phptnu �[��� PK �e�Z��Y� � \{ tests/gearman_worker_015.phptnu �[��� PK �e�Z�Y�� � i~ tests/skipif.incnu �[��� PK �e�Z�r�� � W tests/gearman_worker_008.phptnu �[��� PK �e�Zi�d]� � p� tests/gearman_client_003.phptnu �[��� PK �e�ZPq�� � �� tests/gearman_client_009.phptnu �[��� PK �e�Z�7R R �� tests/gearman_worker_006.phptnu �[��� PK �e�Zˠ/ߣ � + Q� tests/gearman_job_integration_test_009.phptnu �[��� PK �e�Z�{{�� � O� tests/gearman_001.phptnu �[��� PK �e�Z@m�� � b� tests/gearman_client_020.phptnu �[��� PK �e�Z�gd-� � + �� tests/gearman_job_integration_test_003.phptnu �[��� PK �e�Zr�~�� � ~� tests/gearman_client_006.phptnu �[��� PK �e�Z�{� � + O� tests/gearman_job_integration_test_008.phptnu �[��� PK �e�Zh��� � ^� tests/gearman_worker_004.phptnu �[��� PK �e�Z���8 g� tests/gearman_worker_010.phptnu �[��� PK �e�Zw���2 2 dz tests/gearman_worker_017.phptnu �[��� PK �e�Z�]�� � - F� tests/gearman_tasks_integration_test_001.phptnu �[��� PK �e�Z�۰�� � h� tests/gearman_client_001.phptnu �[��� PK �e�Zl���- - �� tests/gearman_task_006.phptnu �[��� PK �e�Z
�9 9 - � tests/gearman_tasks_integration_test_002.phptnu �[��� PK �e�Z��1� � �� tests/skipifconnect.incnu �[��� PK �e�Zڤp�;
;
�� tests/gearman_client_021.phptnu �[��� PK �e�Z�j|� �
� tests/gearman_client_019.phptnu �[��� PK �e�Z�M*2 2 �� tests/gearman_client_022.phptnu �[��� PK �e�Z�c��H H w� tests/gearman_worker_014.phptnu �[��� PK �e�Z$rңJ J � tests/gearman_client_017.phptnu �[��� PK �e�Zw� . �� tests/gearman_client_integration_test_001.phptnu �[��� PK �e�Z�>[�: : � tests/gearman_worker_013.phptnu �[��� PK �e�Z�1� � �� tests/skipifversion.incnu �[��� PK �e�Z3�2 2 . � tests/gearman_client_integration_test_002.phptnu �[��� PK �e�Z�h� � + q� tests/gearman_job_integration_test_004.phptnu �[��� PK �e�Z�
�� � + w tests/gearman_job_integration_test_007.phptnu �[��� PK �e�Z��M& & k tests/gearman_task_001.phptnu �[��� PK �e�Z��l� � �
tests/gearman_worker_005.phptnu �[��� PK �e�Z�oqf� � + � tests/gearman_job_integration_test_002.phptnu �[��� PK �e�Z�K�x0 0 � tests/gearman_worker_016.phptnu �[��� PK �e�Z=ౖ� � k tests/gearman_worker_012.phptnu �[��� PK �e�Z��� � � �" tests/gearman_client_007.phptnu �[��� PK �e�Z_�*/� � �' tests/gearman_client_013.phptnu �[��� PK �e�Z��[O
j* tests/gearman_client_010.phptnu �[��� PK E E � �.