Skip to content

Commit ec92248

Browse files
committed
Add additional test and move JSON to file for readability
1 parent fd09058 commit ec92248

File tree

2 files changed

+120
-60
lines changed

2 files changed

+120
-60
lines changed

tests/Integration/Messages/MessagesTest.php

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -103,66 +103,7 @@ public function testListMessage(): void
103103
$this->mockClient->expects(self::atLeastOnce())->method('performHttpRequest')->willReturn([
104104
200,
105105
'',
106-
'{
107-
"offset": 0,
108-
"limit": 10,
109-
"count": 10,
110-
"totalCount": 16,
111-
"links": {
112-
"first": "https://rest.messagebird.com/messages/?offset=0&limit=10&recipient=31653474496&from=2021-03-16T00%3A00%3A00%2B00%3A00",
113-
"previous": null,
114-
"next": "https://rest.messagebird.com/messages/?offset=10&limit=10&recipient=31653474496&from=2021-03-16T00%3A00%3A00%2B00%3A00",
115-
"last": "https://rest.messagebird.com/messages/?offset=10&limit=10&recipient=31653474496&from=2021-03-16T00%3A00%3A00%2B00%3A00"
116-
},
117-
"items": [
118-
{
119-
"id": "7d8451f8",
120-
"href": "https://rest.messagebird.com/messages/7d8451f8",
121-
"direction": "mt",
122-
"type": "sms",
123-
"originator": "+31612345678",
124-
"body": "Hi there",
125-
"reference": null,
126-
"validity": null,
127-
"gateway": 10,
128-
"typeDetails": {
129-
"verify": true
130-
},
131-
"datacoding": "plain",
132-
"mclass": 1,
133-
"scheduledDatetime": null,
134-
"createdDatetime": "2022-10-12T18:46:22+00:00",
135-
"recipients": {
136-
"totalCount": 1,
137-
"totalSentCount": 1,
138-
"totalDeliveredCount": 1,
139-
"totalDeliveryFailedCount": 0,
140-
"items": [
141-
{
142-
"recipient": 31612345678,
143-
"originator": null,
144-
"status": "delivered",
145-
"statusDatetime": "2022-10-12T18:46:24+00:00",
146-
"recipientCountry": "Netherlands",
147-
"recipientCountryPrefix": 31,
148-
"recipientOperator": "KPN",
149-
"messageLength": 20,
150-
"statusErrorCode": null,
151-
"statusReason": "successfully delivered",
152-
"price": {
153-
"amount": 0.076,
154-
"currency": "EUR"
155-
},
156-
"mccmnc": "20408",
157-
"mcc": "204",
158-
"mnc": "08",
159-
"messagePartCount": 1
160-
}
161-
]
162-
}
163-
}
164-
]
165-
}',
106+
file_get_contents(__DIR__ . '/get-list-response.json')
166107
]);
167108

168109
$this->mockClient->expects(self::once())->method('performHttpRequest')->with(
@@ -178,6 +119,9 @@ public function testListMessage(): void
178119
self::assertSame('7d8451f8', $messageList->items[0]->id);
179120
self::assertSame('https://rest.messagebird.com/messages/7d8451f8', $messageList->items[0]->href);
180121

122+
self::assertSame('7d8451f8', $messageList->items[1]->id);
123+
self::assertSame('https://rest.messagebird.com/messages/7d8451f8', $messageList->items[1]->href);
124+
181125
}
182126

183127
public function testReadMessage(): void
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
{
2+
"offset": 0,
3+
"limit": 10,
4+
"count": 10,
5+
"totalCount": 16,
6+
"links":
7+
{
8+
"first": "https://rest.messagebird.com/messages/?offset=0&limit=10&recipient=31653474496&from=2021-03-16T00%3A00%3A00%2B00%3A00",
9+
"previous": null,
10+
"next": "https://rest.messagebird.com/messages/?offset=10&limit=10&recipient=31653474496&from=2021-03-16T00%3A00%3A00%2B00%3A00",
11+
"last": "https://rest.messagebird.com/messages/?offset=10&limit=10&recipient=31653474496&from=2021-03-16T00%3A00%3A00%2B00%3A00"
12+
},
13+
"items":
14+
[
15+
{
16+
"id": "7d8451f8",
17+
"href": "https://rest.messagebird.com/messages/7d8451f8",
18+
"direction": "mt",
19+
"type": "sms",
20+
"originator": "+31612345678",
21+
"body": "Hi there",
22+
"reference": null,
23+
"validity": null,
24+
"gateway": 10,
25+
"typeDetails":
26+
{
27+
"verify": true
28+
},
29+
"datacoding": "plain",
30+
"mclass": 1,
31+
"scheduledDatetime": null,
32+
"createdDatetime": "2022-10-12T18:46:22+00:00",
33+
"recipients":
34+
{
35+
"totalCount": 1,
36+
"totalSentCount": 1,
37+
"totalDeliveredCount": 1,
38+
"totalDeliveryFailedCount": 0,
39+
"items":
40+
[
41+
{
42+
"recipient": 31612345678,
43+
"originator": null,
44+
"status": "delivered",
45+
"statusDatetime": "2022-10-12T18:46:24+00:00",
46+
"recipientCountry": "Netherlands",
47+
"recipientCountryPrefix": 31,
48+
"recipientOperator": "KPN",
49+
"messageLength": 20,
50+
"statusErrorCode": null,
51+
"statusReason": "successfully delivered",
52+
"price":
53+
{
54+
"amount": 0.076,
55+
"currency": "EUR"
56+
},
57+
"mccmnc": "20408",
58+
"mcc": "204",
59+
"mnc": "08",
60+
"messagePartCount": 1
61+
}
62+
]
63+
}
64+
},
65+
{
66+
"id": "7d8451f8",
67+
"href": "https://rest.messagebird.com/messages/7d8451f8",
68+
"direction": "mt",
69+
"type": "sms",
70+
"originator": "+31612345678",
71+
"body": "Hi there",
72+
"reference": null,
73+
"validity": null,
74+
"gateway": 10,
75+
"typeDetails":
76+
{
77+
"verify": true
78+
},
79+
"datacoding": "plain",
80+
"mclass": 1,
81+
"scheduledDatetime": null,
82+
"createdDatetime": "2022-10-12T18:46:22+00:00",
83+
"recipients":
84+
{
85+
"totalCount": 1,
86+
"totalSentCount": 1,
87+
"totalDeliveredCount": 1,
88+
"totalDeliveryFailedCount": 0,
89+
"items":
90+
[
91+
{
92+
"recipient": 31612345678,
93+
"originator": null,
94+
"status": "delivered",
95+
"statusDatetime": "2022-10-12T18:46:24+00:00",
96+
"recipientCountry": "Netherlands",
97+
"recipientCountryPrefix": 31,
98+
"recipientOperator": "KPN",
99+
"messageLength": 20,
100+
"statusErrorCode": null,
101+
"statusReason": "successfully delivered",
102+
"price":
103+
{
104+
"amount": 0.076,
105+
"currency": "EUR"
106+
},
107+
"mccmnc": "20408",
108+
"mcc": "204",
109+
"mnc": "08",
110+
"messagePartCount": 1
111+
}
112+
]
113+
}
114+
}
115+
]
116+
}

0 commit comments

Comments
 (0)