55use GuzzleHttp \Client ;
66use GuzzleHttp \ClientInterface ;
77use GuzzleHttp \Exception \GuzzleException ;
8- use GuzzleHttp \Handler \MockHandler ;
98use GuzzleHttp \HandlerStack ;
109use GuzzleHttp \Psr7 \Response ;
1110use ScayTrase \Api \JsonRpc \JsonRpcNotification ;
@@ -21,14 +20,16 @@ abstract class AbstractJsonRpcClientTest extends \PHPUnit_Framework_TestCase
2120
2221 protected function setUp ()
2322 {
24- $ this ->queue = null ;
23+ $ this ->queue = null ;
2524 $ this ->client = null ;
2625 parent ::setUp ();
2726 }
2827
2928 protected function tearDown ()
3029 {
31- self ::assertEquals (0 , $ this ->getQueue ()->count ());
30+ if (null !== $ this ->queue ) {
31+ self ::assertEquals (0 , $ this ->getQueue ()->count ());
32+ }
3233 parent ::tearDown ();
3334 }
3435
@@ -38,14 +39,15 @@ protected function getQueue()
3839 if (null === $ this ->queue ) {
3940 $ this ->queue = new MockHandler ();
4041 }
42+
4143 return $ this ->queue ;
4244 }
4345
4446 /** @return ClientInterface */
4547 protected function getClient ()
4648 {
4749 if (null === $ this ->client ) {
48- $ handler = HandlerStack::create ($ this ->getQueue ());
50+ $ handler = HandlerStack::create ($ this ->getQueue ());
4951 $ this ->client = new Client (['handler ' => $ handler ]);
5052 }
5153
@@ -66,14 +68,16 @@ protected function createRequestForSingleInvocation($method, array $parameters,
6668 200 ,
6769 [],
6870 json_encode (
69- [[
70- 'jsonrpc ' => '2.0 ' ,
71- 'id ' => $ hash ,
72- 'error ' => [
73- 'code ' => $ result ->getCode (),
74- 'message ' => $ result ->getMessage ()
75- ]
76- ]]
71+ [
72+ [
73+ 'jsonrpc ' => '2.0 ' ,
74+ 'id ' => $ hash ,
75+ 'error ' => [
76+ 'code ' => $ result ->getCode (),
77+ 'message ' => $ result ->getMessage (),
78+ ],
79+ ],
80+ ]
7781 )
7882 )
7983 );
@@ -83,11 +87,13 @@ protected function createRequestForSingleInvocation($method, array $parameters,
8387 200 ,
8488 [],
8589 json_encode (
86- [[
87- 'jsonrpc ' => '2.0 ' ,
88- 'id ' => $ hash ,
89- 'result ' => $ result
90- ]]
90+ [
91+ [
92+ 'jsonrpc ' => '2.0 ' ,
93+ 'id ' => $ hash ,
94+ 'result ' => $ result ,
95+ ],
96+ ]
9197 )
9298 )
9399 );
0 commit comments