@@ -88,6 +88,7 @@ public function gets_replies()
88
88
new Response (200 , [], json_encode ([
89
89
'data ' => [[
90
90
'id ' => 1 ,
91
+ 'request_id ' => 123456 ,
91
92
'author ' => [
92
93
'id ' => 1 ,
93
94
'name ' => 'Jonny Test ' ,
@@ -125,6 +126,7 @@ public function gets_replies()
125
126
$ reply = $ page ->getItems ()[0 ];
126
127
127
128
$ this ->assertEquals (1 , $ reply ->id );
129
+ $ this ->assertEquals (123456 , $ reply ->requestId );
128
130
$ this ->assertEquals (1 , $ reply ->author ->id );
129
131
$ this ->assertEquals ('Jonny Test ' , $ reply ->author ->name );
130
132
$ this ->assertFalse ($ reply ->read );
@@ -142,6 +144,7 @@ public function gets_replies_with_attachments()
142
144
new Response (200 , [], json_encode ([
143
145
'data ' => [[
144
146
'id ' => 1 ,
147
+ 'request_id ' => 123456 ,
145
148
'author ' => [
146
149
'id ' => 1 ,
147
150
'name ' => 'Jonny Test ' ,
@@ -302,6 +305,7 @@ public function gets_one_reply()
302
305
new Response (200 , [], json_encode ([
303
306
'data ' => [
304
307
'id ' => "C485939 " ,
308
+ 'request_id ' => 123456 ,
305
309
'author ' => [
306
310
'id ' => 10 ,
307
311
'name ' => 'Test Man ' ,
@@ -323,8 +327,80 @@ public function gets_one_reply()
323
327
324
328
$ this ->assertTrue ($ reply instanceof \UKFast \SDK \PSS \Entities \Reply);
325
329
$ this ->assertEquals ('C485939 ' , $ reply ->id );
330
+ $ this ->assertEquals (123456 , $ reply ->requestId );
326
331
$ this ->assertEquals ('test ' , $ reply ->description );
327
332
$ this ->assertInstanceOf (DateTime::class, $ reply ->createdAt );
328
333
$ this ->assertTrue ($ reply ->read );
329
334
}
335
+
336
+ /**
337
+ * @test
338
+ */
339
+ public function gets_replies_without_request_id ()
340
+ {
341
+ $ mock = new MockHandler ([
342
+ new Response (200 , [], json_encode ([
343
+ 'data ' => [
344
+ [
345
+ 'id ' => 1 ,
346
+ 'request_id ' => 123456 ,
347
+ 'author ' => [
348
+ 'id ' => 1 ,
349
+ 'name ' => 'Jonny Test ' ,
350
+ 'type ' => 'Client ' ,
351
+ ],
352
+ 'description ' => 'Test ' ,
353
+ 'created_at ' => '2000-01-01T00:00:00+00 ' ,
354
+ 'attachments ' => [],
355
+ 'read ' => false ,
356
+ ],
357
+ [
358
+ 'id ' => 1 ,
359
+ 'request_id ' => 654321 ,
360
+ 'author ' => [
361
+ 'id ' => 1 ,
362
+ 'name ' => 'Jonny Test ' ,
363
+ 'type ' => 'Client ' ,
364
+ ],
365
+ 'description ' => 'Test 2 ' ,
366
+ 'created_at ' => '2000-01-01T00:00:00+00 ' ,
367
+ 'attachments ' => [],
368
+ 'read ' => false ,
369
+ ]
370
+ ],
371
+ 'meta ' => [
372
+ 'pagination ' => [
373
+ 'total ' => 2 ,
374
+ 'count ' => 1 ,
375
+ 'per_page ' => 2 ,
376
+ 'total_pages ' => 1 ,
377
+ 'links ' => [
378
+ 'next ' => 'http://example.com/next ' ,
379
+ 'previous ' => 'http://example.com/previous ' ,
380
+ 'first ' => 'http://example.com/first ' ,
381
+ 'last ' => 'http://example.com/last ' ,
382
+ ]
383
+ ]
384
+ ]
385
+ ])),
386
+ ]);
387
+ $ handler = HandlerStack::create ($ mock );
388
+ $ guzzle = new Client (['handler ' => $ handler ]);
389
+
390
+ $ client = new \UKFast \SDK \PSS \Client ($ guzzle );
391
+ $ page = $ client ->replies ()->getPageWithoutRequest ();
392
+
393
+ $ this ->assertTrue ($ page instanceof \UKFast \SDK \Page);
394
+
395
+ $ reply = $ page ->getItems ()[0 ];
396
+
397
+ $ this ->assertEquals (1 , $ reply ->id );
398
+ $ this ->assertEquals (123456 , $ reply ->requestId );
399
+ $ this ->assertEquals (1 , $ reply ->author ->id );
400
+ $ this ->assertEquals ('Jonny Test ' , $ reply ->author ->name );
401
+ $ this ->assertFalse ($ reply ->read );
402
+ $ this ->assertEquals ('Test ' , $ reply ->description );
403
+ $ this ->assertInstanceOf (DateTime::class, $ reply ->createdAt );
404
+ $ this ->assertEquals ('2000-01-01 00:00:00 ' , $ reply ->createdAt ->format ('Y-m-d H:i:s ' ));
405
+ }
330
406
}
0 commit comments