Example #1
0
 /**
  * @group job
  */
 public function testJobSubmit()
 {
     if (!defined('CONNECTOR') || CONNECTOR != 'redis') {
         $this->markTestSkipped('skipped requires `redis` celery workers');
     }
     $options = array('broker' => array('type' => 'Predis', 'options' => array('exchange' => 'celery')), 'result_store' => array('type' => 'Predis', 'options' => array('exchange' => 'celery')));
     $rhubarb = new \Rhubarb\Rhubarb($options);
     $res = $rhubarb->sendTask('predis.add', array(2, 3));
     $res->delay();
     //        $result = $res->get(2);
     //        $this->assertEquals(5, $result);
     $res = $rhubarb->sendTask('predis.add', array(2102, 3));
     $res->delay();
     //        $this->assertEquals(2105, $res->get());
 }
Example #2
0
 /**
  * @expectedException PHPUnit_Framework_Error_Deprecated
  */
 public function testDeprecatedWarning()
 {
     if (!defined('CONNECTOR') || CONNECTOR != 'amqp') {
         $this->markTestSkipped('skipped requires AMQP celery workers');
     }
     $options = array('broker' => array('type' => 'PhpAmqp', 'options' => array('exchange' => 'celery', 'queue' => array('arguments' => array()), 'uri' => 'amqp://*****:*****@localhost:5672/celery')), 'result_store' => array('type' => 'PhpAmqp', 'options' => array('exchange' => 'celery', 'uri' => 'amqp://*****:*****@localhost:5672/celery')));
     $rhubarb = new \Rhubarb\Rhubarb($options);
     $res = $rhubarb->sendTask('phpamqp.subtract', array(3, 2));
     $res->delay(array('queue' => 'subtract_queue', 'exchange' => 'subtract_queue'));
     $result = $res->get(2);
     $this->assertEquals(1, $result);
 }
Example #3
0
 /**
  * @group queue_change
  */
 public function testAlternateRoutingKey()
 {
     if (!defined('CONNECTOR') || CONNECTOR != 'amqp') {
         $this->markTestSkipped('skipped requires AMQP celery workers');
     }
     $options = array('broker' => array('type' => 'Amqp', 'options' => array('exchange' => 'celery', 'queue' => array('arguments' => array('x-ha-policy' => array('S', 'all'))), 'uri' => 'amqp://*****:*****@localhost:5672/celery')), 'result_store' => array('type' => 'Amqp', 'options' => array('exchange' => 'celery', 'uri' => 'amqp://*****:*****@localhost:5672/celery')));
     $rhubarb = new \Rhubarb\Rhubarb($options);
     $routing_key = 'this_is_my_test';
     $res = $rhubarb->sendTask('phpamqp.subtract', array(3, 2));
     $res->delay(array('queue' => 'subtract_queue', 'exchange' => 'subtract_queue', 'routing_key' => $routing_key));
     $this->assertEquals($routing_key, $res->getMessage()->getPropRoutingKey());
     $result = $res->get(2);
     $this->assertEquals(1, $result);
 }