@@ -42,7 +42,7 @@ public function testGetCampaignStatisticsWithExpiredSessionKeyReturnsForbidden()
42
42
public function testGetCampaignStatisticsWithValidSessionReturnsOkay (): void
43
43
{
44
44
$ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, MessageFixture::class]);
45
-
45
+
46
46
$ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/campaigns ' );
47
47
$ this ->assertHttpOkay ();
48
48
}
@@ -68,7 +68,7 @@ public function testGetViewOpensStatisticsWithoutSessionKeyReturnsForbidden(): v
68
68
public function testGetViewOpensStatisticsWithValidSessionReturnsOkay (): void
69
69
{
70
70
$ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, MessageFixture::class]);
71
-
71
+
72
72
$ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/view-opens ' );
73
73
$ this ->assertHttpOkay ();
74
74
}
@@ -96,7 +96,7 @@ public function testGetTopDomainsWithoutSessionKeyReturnsForbidden(): void
96
96
public function testGetTopDomainsWithValidSessionReturnsOkay (): void
97
97
{
98
98
$ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, SubscriberFixture::class]);
99
-
99
+
100
100
$ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/domains/top ' );
101
101
$ this ->assertHttpOkay ();
102
102
}
@@ -111,6 +111,69 @@ public function testGetTopDomainsReturnsDomainsData(): void
111
111
self ::assertIsArray ($ response );
112
112
self ::assertArrayHasKey ('domains ' , $ response );
113
113
self ::assertArrayHasKey ('total ' , $ response );
114
+ self ::assertIsArray ($ response ['domains ' ]);
115
+ self ::assertIsInt ($ response ['total ' ]);
116
+ }
117
+
118
+ public function testGetTopDomainsWithLimitParameter (): void
119
+ {
120
+ $ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, SubscriberFixture::class]);
121
+
122
+ $ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/domains/top?limit=5 ' );
123
+ $ response = $ this ->getDecodedJsonResponseContent ();
124
+
125
+ self ::assertIsArray ($ response );
126
+ self ::assertArrayHasKey ('domains ' , $ response );
127
+ self ::assertIsArray ($ response ['domains ' ]);
128
+ self ::assertLessThanOrEqual (5 , count ($ response ['domains ' ]));
129
+ }
130
+
131
+ public function testGetTopDomainsWithMinSubscribersParameter (): void
132
+ {
133
+ $ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, SubscriberFixture::class]);
134
+
135
+ $ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/domains/top?min_subscribers=10 ' );
136
+ $ response = $ this ->getDecodedJsonResponseContent ();
137
+
138
+ self ::assertIsArray ($ response );
139
+ self ::assertArrayHasKey ('domains ' , $ response );
140
+ self ::assertIsArray ($ response ['domains ' ]);
141
+
142
+ // Verify all domains have at least 10 subscribers
143
+ foreach ($ response ['domains ' ] as $ domain ) {
144
+ self ::assertArrayHasKey ('subscribers ' , $ domain );
145
+ self ::assertGreaterThanOrEqual (10 , $ domain ['subscribers ' ]);
146
+ }
147
+ }
148
+
149
+ public function testGetTopDomainsWithBothParameters (): void
150
+ {
151
+ $ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, SubscriberFixture::class]);
152
+
153
+ $ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/domains/top?limit=3&min_subscribers=10 ' );
154
+ $ response = $ this ->getDecodedJsonResponseContent ();
155
+
156
+ self ::assertIsArray ($ response );
157
+ self ::assertArrayHasKey ('domains ' , $ response );
158
+ self ::assertIsArray ($ response ['domains ' ]);
159
+ self ::assertLessThanOrEqual (3 , count ($ response ['domains ' ]));
160
+
161
+ foreach ($ response ['domains ' ] as $ domain ) {
162
+ self ::assertArrayHasKey ('subscribers ' , $ domain );
163
+ self ::assertGreaterThanOrEqual (10 , $ domain ['subscribers ' ]);
164
+ }
165
+ }
166
+
167
+ public function testGetTopDomainsWithInvalidLimitParameter (): void
168
+ {
169
+ $ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, SubscriberFixture::class]);
170
+
171
+ $ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/domains/top?limit=invalid ' );
172
+ $ response = $ this ->getDecodedJsonResponseContent ();
173
+
174
+ self ::assertIsArray ($ response );
175
+ self ::assertArrayHasKey ('domains ' , $ response );
176
+ self ::assertIsArray ($ response ['domains ' ]);
114
177
}
115
178
116
179
public function testGetDomainConfirmationStatisticsWithoutSessionKeyReturnsForbidden (): void
@@ -122,7 +185,7 @@ public function testGetDomainConfirmationStatisticsWithoutSessionKeyReturnsForbi
122
185
public function testGetDomainConfirmationStatisticsWithValidSessionReturnsOkay (): void
123
186
{
124
187
$ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, SubscriberFixture::class]);
125
-
188
+
126
189
$ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/domains/confirmation ' );
127
190
$ this ->assertHttpOkay ();
128
191
}
@@ -148,7 +211,7 @@ public function testGetTopLocalPartsWithoutSessionKeyReturnsForbidden(): void
148
211
public function testGetTopLocalPartsWithValidSessionReturnsOkay (): void
149
212
{
150
213
$ this ->loadFixtures ([AdministratorFixture::class, AdministratorTokenFixture::class, SubscriberFixture::class]);
151
-
214
+
152
215
$ this ->authenticatedJsonRequest ('GET ' , '/api/v2/analytics/local-parts/top ' );
153
216
$ this ->assertHttpOkay ();
154
217
}
0 commit comments