aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/jobqueue/JobTest.php
diff options
context:
space:
mode:
authoraddshore <addshorewiki@gmail.com>2014-09-23 21:52:39 +0100
committeraddshore <addshorewiki@gmail.com>2014-09-23 21:57:31 +0100
commitf960c2434b7ccd9444e178f033f1f8123da82f7b (patch)
treecbc2ccf42f705e99bbd071140f479cc8e5a9e9c3 /tests/phpunit/includes/jobqueue/JobTest.php
parent38d651fab24bfed7e6de8eb09c9354be49e8a319 (diff)
downloadmediawikicore-f960c2434b7ccd9444e178f033f1f8123da82f7b.tar.gz
mediawikicore-f960c2434b7ccd9444e178f033f1f8123da82f7b.zip
Add tests for Job::toString
Change-Id: I00f41808af42a198a1e45a93201dd7bb3e4d9c2c
Diffstat (limited to 'tests/phpunit/includes/jobqueue/JobTest.php')
-rw-r--r--tests/phpunit/includes/jobqueue/JobTest.php67
1 files changed, 67 insertions, 0 deletions
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;
+ }
+
+}