Example #1
0
 public static function init()
 {
     if (!is_array(self::$queue_namespace)) {
         self::$queue_namespace = array();
     }
     \PHPQueue\Base::$queue_namespace = array_merge(array('CKFQueue\\Queues'), self::$queue_namespace);
     if (!is_array(self::$worker_namespace)) {
         self::$worker_namespace = array();
     }
     \PHPQueue\Base::$worker_namespace = array_merge(array('CKFQueue\\Workers'), self::$worker_namespace);
     if (!empty(self::$queue_path)) {
         \PHPQueue\Base::$queue_path = array(self::$queue_path);
     }
     if (!empty(self::$worker_path)) {
         \PHPQueue\Base::$worker_path = array(self::$worker_path);
     }
 }
Example #2
0
<?php

require_once dirname(__DIR__) . '/vendor/autoload.php';
PHPQueue\Base::$queue_path = dirname(__DIR__) . '/demo/queues/';
PHPQueue\Base::$worker_path = dirname(__DIR__) . '/demo/workers/';
Example #3
0
 public function testWorkJob()
 {
     try {
         PHPQueue\Base::workJob(null, null);
         $this->fail("Should not be able to work the Job");
     } catch (Exception $ex) {
         $this->assertStringStartsWith("Invalid worker object", $ex->getMessage());
     }
     $worker = PHPQueue\Base::getWorker('Sample');
     try {
         PHPQueue\Base::workJob($worker, null);
         $this->fail("Should not be able to work the Job");
     } catch (Exception $ex) {
         $this->assertStringStartsWith("Invalid job object", $ex->getMessage());
     }
     $job = new PHPQueue\Job();
     $job->worker = 'Sample';
     $job->data = array('var1' => 'Hello, world!');
     $result = PHPQueue\Base::workJob($worker, $job);
     $this->assertEquals(array('var1' => 'Hello, world!', 'var2' => "Welcome back!"), $result->result_data);
     $this->assertEquals(\PHPQueue\Job::OK, $job->status);
     $this->assertTrue($job->isSuccessful());
 }
Example #4
0
<?php

require_once dirname(dirname(__DIR__)) . '/vendor/autoload.php';
PHPQueue\Base::$queue_path = __DIR__ . '/queues/';
PHPQueue\Base::$worker_path = __DIR__ . '/workers/';