public function testSend()
 {
     try {
         $connection = Connection::connect();
     } catch (\Net\Gearman\Exception $exception) {
         return $this->markTestSkipped('Skipped. You can try this test on your machine with gearman running.');
     }
     Connection::send($connection, 'echo_req', array('text' => 'foobar'));
     do {
         $ret = Connection::read($connection);
     } while (is_array($ret) && !count($ret));
     Connection::close($connection);
     $this->assertInternalType('array', $ret);
     $this->assertEquals('echo_res', $ret['function']);
     $this->assertEquals(17, $ret['type']);
     $this->assertInternalType('array', $ret['data']);
     $this->assertEquals('foobar', $ret['data']['text']);
 }
Exemple #2
0
 /**
  * Mark your job as failing
  *
  * If your job fails for some reason (e.g. a query fails) you need to run
  * this function and exit from your run() method. This will tell Gearman
  * (and the client by proxy) that the job has failed.
  *
  * @param resource $socket
  * @param string $handle
  *
  * @see Net\Gearman\Connection::send()
  */
 private function jobFail($socket, $handle)
 {
     Connection::send($socket, 'work_fail', array('handle' => $handle));
 }