11<?php
22/**
3- * Net_Gearman_ConnectionTest
3+ * Net_Gearman_TaskTest.
44 */
55class Net_Gearman_TaskTest extends \PHPUnit \Framework \TestCase
66{
77 /**
88 * Unknown job type.
99 *
1010 * @return void
11- * @expectedException Net_Gearman_Exception
11+ * @expectedException \ Net_Gearman_Exception
1212 */
1313 public function testExceptionFromConstruct ()
1414 {
15- new Net_Gearman_Task ('foo ' , array () , null , 8 );
15+ new Net_Gearman_Task ('foo ' , [] , null , 8 );
1616 }
1717
1818 /**
@@ -23,46 +23,46 @@ public function testExceptionFromConstruct()
2323 public function testParameters ()
2424 {
2525 $ uniq = uniqid ();
26- $ task = new Net_Gearman_Task ('foo ' , array ( 'bar ' ) , $ uniq , 1 );
26+ $ task = new Net_Gearman_Task ('foo ' , [ 'bar ' ] , $ uniq , 1 );
2727
2828 $ this ->assertEquals ('foo ' , $ task ->func );
29- $ this ->assertEquals (array ( 'bar ' ) , $ task ->arg );
29+ $ this ->assertEquals ([ 'bar ' ] , $ task ->arg );
3030 $ this ->assertEquals ($ uniq , $ task ->uniq );
3131 }
3232
3333 /**
34- * @expectedException Net_Gearman_Exception
34+ * @expectedException \ Net_Gearman_Exception
3535 */
3636 public function testAttachInvalidCallback ()
3737 {
38- $ task = new Net_Gearman_Task ('foo ' , array () );
38+ $ task = new Net_Gearman_Task ('foo ' , [] );
3939 $ task ->attachCallback ('func_bar ' );
4040 }
4141
4242 /**
43- * @expectedException Net_Gearman_Exception
43+ * @expectedException \ Net_Gearman_Exception
4444 */
4545 public function testAttachInvalidCallbackType ()
4646 {
47- $ task = new Net_Gearman_Task ('foo ' , array () );
47+ $ task = new Net_Gearman_Task ('foo ' , [] );
4848 $ this ->assertInstanceOf ('Net_Gearman_Task ' , $ task ->attachCallback ('strlen ' , 666 ));
4949 }
5050
5151 public static function callbackProvider ()
5252 {
53- return array (
54- array ( 'strlen ' , Net_Gearman_Task::TASK_FAIL ) ,
55- array ( 'intval ' , Net_Gearman_Task::TASK_COMPLETE ) ,
56- array ( 'explode ' , Net_Gearman_Task::TASK_STATUS ) ,
57- ) ;
53+ return [
54+ [ 'strlen ' , Net_Gearman_Task::TASK_FAIL ] ,
55+ [ 'intval ' , Net_Gearman_Task::TASK_COMPLETE ] ,
56+ [ 'explode ' , Net_Gearman_Task::TASK_STATUS ] ,
57+ ] ;
5858 }
5959
6060 /**
6161 * @dataProvider callbackProvider
6262 */
6363 public function testAttachCallback ($ func , $ type )
6464 {
65- $ task = new Net_Gearman_Task ('foo ' , array () );
65+ $ task = new Net_Gearman_Task ('foo ' , [] );
6666 $ task ->attachCallback ($ func , $ type );
6767
6868 $ callbacks = $ task ->getCallbacks ();
@@ -77,7 +77,7 @@ public function testAttachCallback($func, $type)
7777 */
7878 public function testCompleteCallback ()
7979 {
80- $ task = new Net_Gearman_Task ('foo ' , array ( 'foo ' => 'bar ' ) );
80+ $ task = new Net_Gearman_Task ('foo ' , [ 'foo ' => 'bar ' ] );
8181
8282 $ this ->assertEquals (null , $ task ->complete ('foo ' ));
8383
@@ -91,7 +91,7 @@ public function testCompleteCallback()
9191 $ this ->assertEquals ($ json , $ task ->result );
9292
9393 $ this ->assertEquals (
94- array ( 'func ' => 'foo ' , 'handle ' => '' , 'result ' => $ json) ,
94+ [ 'func ' => 'foo ' , 'handle ' => '' , 'result ' => $ json] ,
9595 $ GLOBALS ['Net_Gearman_TaskTest ' ]
9696 );
9797
@@ -102,13 +102,14 @@ public function testCompleteCallback()
102102 * See that task has handle and server assigned.
103103 *
104104 * @group functional
105+ *
105106 * @return void
106107 */
107108 public function testTaskStatus ()
108109 {
109- $ client = new Net_Gearman_Client ([" 127.0.0.1:4730 " ]);
110+ $ client = new Net_Gearman_Client ([NET_GEARMAN_TEST_SERVER ]);
110111
111- $ task = new Net_Gearman_Task ('Reverse ' , range (1 ,5 ));
112+ $ task = new Net_Gearman_Task ('Reverse ' , range (1 , 5 ));
112113 $ task ->type = Net_Gearman_Task::JOB_BACKGROUND ;
113114
114115 $ set = new Net_Gearman_Set ();
@@ -117,7 +118,6 @@ public function testTaskStatus()
117118 $ client ->runSet ($ set );
118119
119120 $ this ->assertNotEquals ('' , $ task ->handle );
120- $ this ->assertNotEquals ('' , $ task ->server );
121121 }
122122}
123123
@@ -132,9 +132,9 @@ public function testTaskStatus()
132132 */
133133function Net_Gearman_TaskTest_testCallBack ($ func , $ handle , $ result )
134134{
135- $ GLOBALS ['Net_Gearman_TaskTest ' ] = array (
136- 'func ' => $ func ,
135+ $ GLOBALS ['Net_Gearman_TaskTest ' ] = [
136+ 'func ' => $ func ,
137137 'handle ' => $ handle ,
138- 'result ' => $ result
139- ) ;
138+ 'result ' => $ result,
139+ ] ;
140140}
0 commit comments