@@ -117,7 +117,7 @@ public function testUpdateContactByEmail(): void
117
117
$ this ->contact ->expects ($ this ->once ())
118
118
->method ('httpPut ' )
119
119
->with (
120
- AbstractApi::DEFAULT_HOST . '/api/accounts/ ' . self ::FAKE_ACCOUNT_ID . '/contacts/ ' . $ contactEmail ,
120
+ AbstractApi::DEFAULT_HOST . '/api/accounts/ ' . self ::FAKE_ACCOUNT_ID . '/contacts/ ' . urlencode ( $ contactEmail) ,
121
121
[],
122
122
['contact ' => $ contactDTO ->toArray ()]
123
123
)
@@ -132,6 +132,33 @@ public function testUpdateContactByEmail(): void
132
132
$ this ->assertEquals ($ contactEmail , $ responseData ['email ' ]);
133
133
}
134
134
135
+ public function testUpdateContactExcludesNullUnsubscribed (): void
136
+ {
137
+ $ contactEmail = 'test@example.com ' ;
138
+ $ contactDTO = new UpdateContact ($ contactEmail , ['last_name ' => 'Smith ' ], [3 ], [1 , 2 ]);
139
+
140
+ $ this ->contact ->expects ($ this ->once ())
141
+ ->method ('httpPut ' )
142
+ ->with (
143
+ AbstractApi::DEFAULT_HOST . '/api/accounts/ ' . self ::FAKE_ACCOUNT_ID . '/contacts/ ' . urlencode ($ contactEmail ),
144
+ [],
145
+ $ this ->callback (function (array $ payload ) {
146
+ $ this ->assertArrayHasKey ('contact ' , $ payload );
147
+ $ this ->assertArrayNotHasKey ('unsubscribed ' , $ payload ['contact ' ]);
148
+ return true ;
149
+ })
150
+ )
151
+ ->willReturn (
152
+ new Response (200 , ['Content-Type ' => 'application/json ' ], json_encode ($ this ->getExpectedUpdateContactData ()))
153
+ );
154
+
155
+ $ response = $ this ->contact ->updateContactByEmail ($ contactEmail , $ contactDTO );
156
+ $ responseData = ResponseHelper::toArray ($ response )['data ' ];
157
+
158
+ $ this ->assertInstanceOf (Response::class, $ response );
159
+ $ this ->assertEquals ('unsubscribed ' , $ responseData ['status ' ]);
160
+ }
161
+
135
162
public function testDeleteContactById (): void
136
163
{
137
164
$ contactId = '019706a8-9612-77be-8586-4f26816b467a ' ;
@@ -151,7 +178,7 @@ public function testDeleteContactByEmail(): void
151
178
$ contactEmail = 'test@example.com ' ;
152
179
$ this ->contact ->expects ($ this ->once ())
153
180
->method ('httpDelete ' )
154
- ->with (AbstractApi::DEFAULT_HOST . '/api/accounts/ ' . self ::FAKE_ACCOUNT_ID . '/contacts/ ' . $ contactEmail )
181
+ ->with (AbstractApi::DEFAULT_HOST . '/api/accounts/ ' . self ::FAKE_ACCOUNT_ID . '/contacts/ ' . urlencode ( $ contactEmail) )
155
182
->willReturn (new Response (204 ));
156
183
157
184
$ response = $ this ->contact ->deleteContactByEmail ($ contactEmail );
0 commit comments