88use chobie \Jira \Api \Authentication \AuthenticationInterface ;
99use chobie \Jira \Api \Authentication \Basic ;
1010use chobie \Jira \Api \Client \ClientInterface ;
11+ use InvalidArgumentException ;
1112use Tests \chobie \Jira \AbstractTestCase ;
12- use Yoast \PHPUnitPolyfills \Polyfills \ExpectException ;
13+ use chobie \Jira \Api \UnauthorizedException ;
14+ use chobie \Jira \Api \Exception ;
1315
1416abstract class AbstractClientTestCase extends AbstractTestCase
1517{
1618
17- use ExpectException;
18-
1919 /**
2020 * Client.
2121 *
@@ -48,7 +48,7 @@ public function testGetRequestWithKnownHttpCode($http_code)
4848 $ this ->assertEquals ($ data , $ trace_result ['_GET ' ]);
4949 }
5050
51- public function getRequestWithKnownHttpCodeDataProvider ()
51+ public static function getRequestWithKnownHttpCodeDataProvider ()
5252 {
5353 return array (
5454 'http 200 ' => array (200 ),
@@ -58,7 +58,7 @@ public function getRequestWithKnownHttpCodeDataProvider()
5858
5959 public function testGetRequestError ()
6060 {
61- $ this ->expectException (' \ InvalidArgumentException' );
61+ $ this ->expectException (InvalidArgumentException::class );
6262 $ this ->expectExceptionMessage ('Data must be an array. ' );
6363
6464 $ this ->traceRequest (Api::REQUEST_GET , 'param1=value1¶m2=value2 ' );
@@ -136,31 +136,23 @@ public function testFileUpload($filename, $name)
136136 );
137137 }
138138
139- public function fileUploadDataProvider ()
139+ public static function fileUploadDataProvider ()
140140 {
141141 return array (
142- 'default name ' => array ('file ' => __FILE__ , 'name ' => null ),
143- 'overridden name ' => array ('file ' => __FILE__ , 'name ' => 'custom_name.php ' ),
142+ 'default name ' => array ('filename ' => __FILE__ , 'name ' => null ),
143+ 'overridden name ' => array ('filename ' => __FILE__ , 'name ' => 'custom_name.php ' ),
144144 );
145145 }
146146
147147 public function testUnsupportedCredentialGiven ()
148148 {
149149 $ client_class_parts = explode ('\\' , get_class ($ this ->client ));
150- $ credential = $ this ->prophesize (' chobie\Jira\Api\Authentication\ AuthenticationInterface' )->reveal ();
150+ $ credential = $ this ->prophesize (AuthenticationInterface::class )->reveal ();
151151
152- if ( \method_exists ($ this , 'setExpectedException ' ) ) {
153- $ this ->setExpectedException (
154- 'InvalidArgumentException ' ,
155- end ($ client_class_parts ) . ' does not support ' . get_class ($ credential ) . ' authentication. '
156- );
157- }
158- else {
159- $ this ->expectException ('InvalidArgumentException ' );
160- $ this ->expectExceptionMessage (
161- end ($ client_class_parts ) . ' does not support ' . get_class ($ credential ) . ' authentication. '
162- );
163- }
152+ $ this ->expectException ('InvalidArgumentException ' );
153+ $ this ->expectExceptionMessage (
154+ end ($ client_class_parts ) . ' does not support ' . get_class ($ credential ) . ' authentication. '
155+ );
164156
165157 $ this ->client ->sendRequest (Api::REQUEST_GET , 'url ' , array (), 'endpoint ' , $ credential );
166158 }
@@ -185,15 +177,15 @@ public function testCommunicationError()
185177
186178 public function testUnauthorizedRequest ()
187179 {
188- $ this ->expectException (' \chobie\Jira\Api\ UnauthorizedException' );
180+ $ this ->expectException (UnauthorizedException::class );
189181 $ this ->expectExceptionMessage ('Unauthorized ' );
190182
191183 $ this ->traceRequest (Api::REQUEST_GET , array ('http_code ' => 401 ));
192184 }
193185
194186 public function testEmptyResponseWithUnknownHttpCode ()
195187 {
196- $ this ->expectException (' \chobie\Jira\Api\ Exception' );
188+ $ this ->expectException (Exception::class );
197189 $ this ->expectExceptionMessage ('JIRA Rest server returns unexpected result. ' );
198190
199191 $ this ->traceRequest (Api::REQUEST_GET , array ('response_mode ' => 'empty ' ));
@@ -210,7 +202,7 @@ public function testEmptyResponseWithKnownHttpCode($http_code)
210202 );
211203 }
212204
213- public function emptyResponseWithKnownHttpCodeDataProvider ()
205+ public static function emptyResponseWithKnownHttpCodeDataProvider ()
214206 {
215207 return array (
216208 'http 201 ' => array (201 ),
@@ -246,10 +238,10 @@ protected function assertContentType($expected, array $trace_result)
246238 /**
247239 * Traces a request.
248240 *
249- * @param string $method Request method.
250- * @param array $data Request data.
251- * @param AuthenticationInterface|null $credential Credential.
252- * @param boolean $is_file This is a file upload request.
241+ * @param string $method Request method.
242+ * @param array $data Request data.
243+ * @param AuthenticationInterface|null $credential Credential.
244+ * @param boolean $is_file This is a file upload request.
253245 *
254246 * @return array
255247 */
0 commit comments