* 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
*/
* 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
*/
/**
* @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;
--- /dev/null
+<?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;
+ }
+
+}