1 | <?php |
||
21 | class ClientTest extends PHPUnit_Framework_TestCase |
||
22 | { |
||
23 | const ACCESS_TOKEN = '2ec09aeccaf634d982eec793037e37fe'; |
||
24 | const REFRESH_TOKEN = '0c59f7e609b0cc467067e39d523116ce'; |
||
25 | |||
26 | public function testSetApiDetails() |
||
27 | { |
||
28 | $newApiDetails = new ApiDetails('1', '2', '3', '4', '5'); |
||
29 | |||
30 | $expected = $this->getApiClient( |
||
31 | new OauthTokenService(new \GuzzleHttp\Client()), |
||
32 | $newApiDetails, |
||
33 | new ClientProxy('example.com'), |
||
34 | $this->getFileHelper(), |
||
35 | new Helper\Csv(), |
||
36 | $this->getTimeHelperMock() |
||
37 | ); |
||
38 | |||
39 | $api = $this->getApiClient( |
||
40 | new OauthTokenService(new \GuzzleHttp\Client()), |
||
41 | new ApiDetails(null, null, null, null, null), |
||
42 | new ClientProxy('example.com'), |
||
43 | $this->getFileHelper(), |
||
44 | new Helper\Csv(), |
||
45 | $this->getTimeHelperMock() |
||
46 | ); |
||
47 | |||
48 | $this->assertNotEquals($expected, $api); |
||
49 | $api->setApiDetails($newApiDetails); |
||
50 | $this->assertEquals($expected, $api); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * @dataProvider getTestSoapExceptionData |
||
55 | * |
||
56 | * @param int $code |
||
57 | * @param string $exceptionClassName |
||
58 | */ |
||
59 | public function testSoapExceptions($code, $exceptionClassName) |
||
64 | |||
65 | /** |
||
66 | * @dataProvider getTestSoapExceptionData |
||
67 | * |
||
68 | * @param int $code |
||
69 | * @param string $exceptionClassName |
||
70 | */ |
||
71 | public function testSoapOperationErrorExceptions($code, $exceptionClassName) |
||
76 | |||
77 | /** |
||
78 | * @dataProvider getTestSoapExceptionData |
||
79 | * |
||
80 | * @param int $code |
||
81 | * @param string $exceptionClassName |
||
82 | */ |
||
83 | public function testSoapBatchErrorExceptions($code, $exceptionClassName) |
||
88 | |||
89 | public function getTestSoapExceptionData() |
||
118 | |||
119 | /** |
||
120 | * @param int $code |
||
121 | * @param null|string $type |
||
122 | * |
||
123 | * @return MockInterface |
||
124 | */ |
||
125 | private function runClientSoapException($code, $type = null) |
||
143 | |||
144 | /** |
||
145 | * @return Mockery\MockInterface |
||
146 | */ |
||
147 | private function getOauthTokenServiceMock() |
||
158 | |||
159 | private function getTimeHelperMock() |
||
166 | |||
167 | /** |
||
168 | * @param OauthTokenService $oauthTokenService |
||
169 | * @param ApiDetails $apiDetails |
||
170 | * @param ClientProxy $clientProxy |
||
171 | * @param Helper\File $fileHelper |
||
172 | * @param Helper\Csv $csvHelper |
||
173 | * @param Helper\Time $timeHelper |
||
174 | * |
||
175 | * @return Client |
||
176 | */ |
||
177 | private function getApiClient(OauthTokenService $oauthTokenService, ApiDetails $apiDetails, ClientProxy $clientProxy, Helper\File $fileHelper, Helper\Csv $csvHelper, Helper\Time $timeHelper) |
||
184 | |||
185 | /** |
||
186 | * @param int $code |
||
187 | * @param null|string $type |
||
188 | * |
||
189 | * @return \SoapFault |
||
190 | */ |
||
191 | private function generateSoapFault($code, $type = null) |
||
215 | |||
216 | private function getClientProxyMock() |
||
228 | |||
229 | /** |
||
230 | * @return Helper\File |
||
231 | */ |
||
232 | private function getFileHelper() |
||
236 | } |
||
237 |
It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.