Beispiel #1
0
exec('cd ' . TEST_MISC . '; redis-server ' . REDIS_CONF, $output, $returnVar);
usleep(500000);
if ($returnVar != 0) {
    echo "Cannot start redis-server.\n";
    exit(1);
}
// Get redis port from conf
$config = file_get_contents(REDIS_CONF);
if (!preg_match('#^\\s*port\\s+([0-9]+)#m', $config, $matches)) {
    echo "Could not determine redis port from redis.conf";
    exit(1);
}
define('REDIS_HOST', 'localhost:' . $matches[1]);
define('REDIS_DATABASE', 7);
define('REDIS_NAMESPACE', 'testResque');
\PhpResque\Resque::setBackend(REDIS_HOST, REDIS_DATABASE, REDIS_NAMESPACE);
// Shutdown
function killRedis($pid)
{
    if (getmypid() !== $pid) {
        return;
        // don't kill from a forked worker
    }
    $config = file_get_contents(REDIS_CONF);
    if (!preg_match('#^\\s*pidfile\\s+([^\\s]+)#m', $config, $matches)) {
        return;
    }
    $pidFile = TEST_MISC . '/' . $matches[1];
    if (file_exists($pidFile)) {
        $pid = trim(file_get_contents($pidFile));
        posix_kill((int) $pid, 9);
Beispiel #2
0
 public function testJobWithNamespace()
 {
     Resque::setBackend(REDIS_HOST, REDIS_DATABASE, 'php');
     $queue = 'jobs';
     $payload = ['another_value'];
     Resque::enqueue($queue, 'Test_Job_With_TearDown', $payload);
     $this->assertEquals(Resque::queues(), ['jobs']);
     $this->assertEquals(Resque::size($queue), 1);
     Resque::setBackend(REDIS_HOST, REDIS_DATABASE, REDIS_NAMESPACE);
     $this->assertEquals(Resque::size($queue), 0);
 }