aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/jobqueue/Job.php6
-rw-r--r--includes/jobqueue/JobQueueGroup.php2
-rw-r--r--tests/phpunit/includes/jobqueue/JobTest.php67
3 files changed, 71 insertions, 4 deletions
diff --git a/includes/jobqueue/Job.php b/includes/jobqueue/Job.php
index ee3f2c2b60c4..d89c5d29608e 100644
--- a/includes/jobqueue/Job.php
+++ b/includes/jobqueue/Job.php
@@ -87,7 +87,7 @@ abstract class Job implements IJobSpecification {
* This may add duplicate at insert time, but they will be
* removed later on, when the first one is popped.
*
- * @param array $jobs Array of Job objects
+ * @param Job[] $jobs Array of Job objects
* @return bool
* @deprecated since 1.21
*/
@@ -103,7 +103,7 @@ abstract class Job implements IJobSpecification {
* be rolled-back as part of a larger transaction. However,
* large batches of jobs can cause slave lag.
*
- * @param array $jobs Array of Job objects
+ * @param Job[] $jobs Array of Job objects
* @return bool
* @deprecated since 1.21
*/
@@ -143,7 +143,7 @@ abstract class Job implements IJobSpecification {
/**
* @param string $command
* @param Title $title
- * @param array|bool $params
+ * @param array|bool $params Can not be === true
*/
public function __construct( $command, $title, $params = false ) {
$this->command = $command;
diff --git a/includes/jobqueue/JobQueueGroup.php b/includes/jobqueue/JobQueueGroup.php
index 98a78c5e39a1..b0b35e9818c1 100644
--- a/includes/jobqueue/JobQueueGroup.php
+++ b/includes/jobqueue/JobQueueGroup.php
@@ -104,7 +104,7 @@ class JobQueueGroup {
* This inserts the jobs into the queue specified by $wgJobTypeConf
* and updates the aggregate job queue information cache as needed.
*
- * @param Job|array $jobs A single Job or a list of Jobs
+ * @param Job|Job[] $jobs A single Job or a list of Jobs
* @throws MWException
* @return void
*/
diff --git a/tests/phpunit/includes/jobqueue/JobTest.php b/tests/phpunit/includes/jobqueue/JobTest.php
new file mode 100644
index 000000000000..93069d2e8df8
--- /dev/null
+++ b/tests/phpunit/includes/jobqueue/JobTest.php
@@ -0,0 +1,67 @@
+<?php
+
+/**
+ * @author Adam Shorland
+ */
+class JobTest extends MediaWikiTestCase {
+
+ /**
+ * @dataProvider provideTestToString
+ *
+ * @param Job $job
+ * @param string $expected
+ *
+ * @covers Job::toString
+ */
+ public function testToString( $job, $expected ) {
+ $this->assertEquals( $expected, $job->toString() );
+ }
+
+ public function provideTestToString() {
+ $mockToStringObj = $this->getMock( 'stdClass', array( '__toString' ) );
+ $mockToStringObj->expects( $this->any() )
+ ->method( '__toString' )
+ ->will( $this->returnValue( '{STRING_OBJ_VAL}' ) );
+
+ return array(
+ array(
+ $this->getMockJob( false ),
+ 'someCommand '
+ ),
+ array(
+ $this->getMockJob( array( 'key' => 'val' ) ),
+ 'someCommand key=val'
+ ),
+ array(
+ $this->getMockJob( array( 'key' => array( 'inkey' => 'inval' ) ) ),
+ 'someCommand key={"inkey":"inval"}'
+ ),
+ array(
+ $this->getMockJob( array( 'val1' ) ),
+ 'someCommand 0=val1'
+ ),
+ array(
+ $this->getMockJob( array( 'val1', 'val2' ) ),
+ 'someCommand 0=val1 1=val2'
+ ),
+ array(
+ $this->getMockJob( array( new stdClass() ) ),
+ 'someCommand 0=object(stdClass)'
+ ),
+ array(
+ $this->getMockJob( array( $mockToStringObj ) ),
+ 'someCommand 0={STRING_OBJ_VAL}'
+ ),
+ );
+ }
+
+ public function getMockJob( $params ) {
+ $mock = $this->getMockForAbstractClass(
+ 'Job',
+ array( 'someCommand', new Title(), $params ),
+ 'SomeJob'
+ );
+ return $mock;
+ }
+
+}