Convert spaces to tabs

This commit is contained in:
Sebastian Machuca 2016-10-13 14:45:02 +11:00
parent 8f542e5035
commit df20186c37
No known key found for this signature in database
GPG Key ID: 4B3DA17F9CCF39DE
5 changed files with 134 additions and 134 deletions

View File

@ -28,10 +28,10 @@ class Resque_Job implements Resque_JobInterface
*/ */
private $instance; private $instance;
/** /**
* @var Resque_Job_FactoryInterface * @var Resque_Job_FactoryInterface
*/ */
private $jobFactory; private $jobFactory;
/** /**
* Instantiate a new instance of a job. * Instantiate a new instance of a job.
@ -45,18 +45,18 @@ class Resque_Job implements Resque_JobInterface
$this->payload = $payload; $this->payload = $payload;
} }
/** /**
* Create a new job and save it to the specified queue. * Create a new job and save it to the specified queue.
* *
* @param string $queue The name of the queue to place the job in. * @param string $queue The name of the queue to place the job in.
* @param string $class The name of the class that contains the code to execute the job. * @param string $class The name of the class that contains the code to execute the job.
* @param array $args Any optional arguments that should be passed when the job is executed. * @param array $args Any optional arguments that should be passed when the job is executed.
* @param boolean $monitor Set to true to be able to monitor the status of a job. * @param boolean $monitor Set to true to be able to monitor the status of a job.
* @param string $id Unique identifier for tracking the job. Generated if not supplied. * @param string $id Unique identifier for tracking the job. Generated if not supplied.
* *
* @return string * @return string
* @throws \InvalidArgumentException * @throws \InvalidArgumentException
*/ */
public static function create($queue, $class, $args = null, $monitor = false, $id = null) public static function create($queue, $class, $args = null, $monitor = false, $id = null)
{ {
if (is_null($id)) { if (is_null($id)) {
@ -82,41 +82,41 @@ class Resque_Job implements Resque_JobInterface
return $id; return $id;
} }
/** /**
* Find the next available job from the specified queue and return an * Find the next available job from the specified queue and return an
* instance of Resque_Job for it. * instance of Resque_Job for it.
* *
* @param string $queue The name of the queue to check for a job in. * @param string $queue The name of the queue to check for a job in.
* @return false|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found. * @return false|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
*/ */
public static function reserve($queue) public static function reserve($queue)
{ {
$payload = Resque::pop($queue); $payload = Resque::pop($queue);
if(!is_array($payload)) { if(!is_array($payload)) {
return false; return false;
} }
return new Resque_Job($queue, $payload); return new Resque_Job($queue, $payload);
} }
/** /**
* Find the next available job from the specified queues using blocking list pop * Find the next available job from the specified queues using blocking list pop
* and return an instance of Resque_Job for it. * and return an instance of Resque_Job for it.
* *
* @param array $queues * @param array $queues
* @param int $timeout * @param int $timeout
* @return false|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found. * @return false|object Null when there aren't any waiting jobs, instance of Resque_Job when a job was found.
*/ */
public static function reserveBlocking(array $queues, $timeout = null) public static function reserveBlocking(array $queues, $timeout = null)
{ {
$item = Resque::blpop($queues, $timeout); $item = Resque::blpop($queues, $timeout);
if(!is_array($item)) { if(!is_array($item)) {
return false; return false;
} }
return new Resque_Job($item['queue'], $item['payload']); return new Resque_Job($item['queue'], $item['payload']);
} }
/** /**
* Update the status of the current job. * Update the status of the current job.
@ -158,11 +158,11 @@ class Resque_Job implements Resque_JobInterface
return $this->payload['args'][0]; return $this->payload['args'][0];
} }
/** /**
* Get the instantiated object for this job that will be performing work. * Get the instantiated object for this job that will be performing work.
* @return Resque_JobInterface Instance of the object that this job belongs to. * @return Resque_JobInterface Instance of the object that this job belongs to.
* @throws Resque_Exception * @throws Resque_Exception
*/ */
public function getInstance() public function getInstance()
{ {
if (!is_null($this->instance)) { if (!is_null($this->instance)) {
@ -181,14 +181,14 @@ class Resque_Job implements Resque_JobInterface
); );
} }
if ($this->jobFactory !== null) { if ($this->jobFactory !== null) {
$this->instance = $this->jobFactory->create($this->payload['class'], $this->getArguments(), $this->queue); $this->instance = $this->jobFactory->create($this->payload['class'], $this->getArguments(), $this->queue);
return $this->instance; return $this->instance;
} }
$this->instance = new $this->payload['class']; $this->instance = new $this->payload['class'];
$this->instance->job = $this; $this->instance->job = $this;
$this->instance->args = $this->getArguments(); $this->instance->args = $this->getArguments();
$this->instance->queue = $this->queue; $this->instance->queue = $this->queue;
return $this->instance; return $this->instance;
} }
@ -284,14 +284,14 @@ class Resque_Job implements Resque_JobInterface
return '(' . implode(' | ', $name) . ')'; return '(' . implode(' | ', $name) . ')';
} }
/** /**
* @param Resque_Job_FactoryInterface $jobFactory * @param Resque_Job_FactoryInterface $jobFactory
* @return Resque_Job * @return Resque_Job
*/ */
public function setJobFactory(Resque_Job_FactoryInterface $jobFactory) public function setJobFactory(Resque_Job_FactoryInterface $jobFactory)
{ {
$this->jobFactory = $jobFactory; $this->jobFactory = $jobFactory;
return $this; return $this;
} }
} }

View File

@ -2,11 +2,11 @@
interface Resque_Job_FactoryInterface interface Resque_Job_FactoryInterface
{ {
/** /**
* @param $className * @param $className
* @param array $args * @param array $args
* @param $queue * @param $queue
* @return Resque_JobInterface * @return Resque_JobInterface
*/ */
public function create($className, array $args, $queue); public function create($className, array $args, $queue);
} }

View File

@ -2,8 +2,8 @@
interface Resque_JobInterface interface Resque_JobInterface
{ {
/** /**
* @return bool * @return bool
*/ */
public function perform(); public function perform();
} }

View File

@ -183,16 +183,16 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
public function testJobWithNamespace() public function testJobWithNamespace()
{ {
Resque_Redis::prefix('php'); Resque_Redis::prefix('php');
$queue = 'jobs'; $queue = 'jobs';
$payload = array('another_value'); $payload = array('another_value');
Resque::enqueue($queue, 'Test_Job_With_TearDown', $payload); Resque::enqueue($queue, 'Test_Job_With_TearDown', $payload);
$this->assertEquals(Resque::queues(), array('jobs'));
$this->assertEquals(Resque::size($queue), 1);
Resque_Redis::prefix('resque'); $this->assertEquals(Resque::queues(), array('jobs'));
$this->assertEquals(Resque::size($queue), 0); $this->assertEquals(Resque::size($queue), 1);
Resque_Redis::prefix('resque');
$this->assertEquals(Resque::size($queue), 0);
} }
public function testDequeueAll() public function testDequeueAll()
@ -363,56 +363,56 @@ class Resque_Tests_JobTest extends Resque_Tests_TestCase
} }
public function testUseFactoryToGetJobInstance() public function testUseFactoryToGetJobInstance()
{ {
$payload = array( $payload = array(
'class' => 'Some_Job_Class', 'class' => 'Some_Job_Class',
'args' => null 'args' => null
); );
$job = new Resque_Job('jobs', $payload); $job = new Resque_Job('jobs', $payload);
$factory = new Some_Stub_Factory(); $factory = new Some_Stub_Factory();
$job->setJobFactory($factory); $job->setJobFactory($factory);
$instance = $job->getInstance(); $instance = $job->getInstance();
$this->assertInstanceOf('Resque_JobInterface', $instance); $this->assertInstanceOf('Resque_JobInterface', $instance);
} }
public function testDoNotUseFactoryToGetInstance() public function testDoNotUseFactoryToGetInstance()
{ {
$payload = array( $payload = array(
'class' => 'Some_Job_Class', 'class' => 'Some_Job_Class',
'args' => null 'args' => null
); );
$job = new Resque_Job('jobs', $payload); $job = new Resque_Job('jobs', $payload);
$factory = $this->getMock('Resque_Job_FactoryInterface'); $factory = $this->getMock('Resque_Job_FactoryInterface');
$testJob = $this->getMock('Resque_JobInterface'); $testJob = $this->getMock('Resque_JobInterface');
$factory->expects(self::never())->method('create')->will(self::returnValue($testJob)); $factory->expects(self::never())->method('create')->will(self::returnValue($testJob));
$instance = $job->getInstance(); $instance = $job->getInstance();
$this->assertInstanceOf('Resque_JobInterface', $instance); $this->assertInstanceOf('Resque_JobInterface', $instance);
} }
} }
class Some_Job_Class implements Resque_JobInterface class Some_Job_Class implements Resque_JobInterface
{ {
/** /**
* @return bool * @return bool
*/ */
public function perform() public function perform()
{ {
return true; return true;
} }
} }
class Some_Stub_Factory implements Resque_Job_FactoryInterface class Some_Stub_Factory implements Resque_Job_FactoryInterface
{ {
/** /**
* @param $className * @param $className
* @param array $args * @param array $args
* @param $queue * @param $queue
* @return Resque_JobInterface * @return Resque_JobInterface
*/ */
public function create($className, array $args, $queue) public function create($className, array $args, $queue)
{ {
return new Some_Job_Class(); return new Some_Job_Class();
} }
} }

View File

@ -11,10 +11,10 @@ class Resque_Tests_TestCase extends PHPUnit_Framework_TestCase
protected $resque; protected $resque;
protected $redis; protected $redis;
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
} }
public function setUp() public function setUp()
{ {