File tree Expand file tree Collapse file tree
test/Tmdb/Tests/HttpClient Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -279,6 +279,20 @@ public function addSubscriber(EventSubscriberInterface $subscriber)
279279 $ this ->eventDispatcher ->addSubscriber ($ subscriber );
280280 }
281281
282+ /**
283+ * Remove a subscriber
284+ *
285+ * @param EventSubscriberInterface $subscriber
286+ */
287+ public function removeSubscriber (EventSubscriberInterface $ subscriber )
288+ {
289+ if ($ subscriber instanceof HttpClientEventSubscriber) {
290+ $ subscriber ->attachHttpClient ($ this );
291+ }
292+
293+ $ this ->eventDispatcher ->removeSubscriber ($ subscriber );
294+ }
295+
282296 /**
283297 * @return GuestSessionToken|SessionToken
284298 */
Original file line number Diff line number Diff line change @@ -158,6 +158,33 @@ public function shouldRegisterSubscribers()
158158 $ this ->testApi ->addSubscriber ($ subscriber );
159159 }
160160
161+ /**
162+ * @test
163+ */
164+ public function shouldDeregisterSubscribers ()
165+ {
166+ $ this ->eventDispatcher = $ this ->getMock ('Symfony\Component\EventDispatcher\EventDispatcherInterface ' );
167+ $ this ->client = new Client (new ApiToken ('abcdef ' ), [
168+ 'adapter ' => $ this ->adapter ,
169+ 'event_dispatcher ' => $ this ->eventDispatcher
170+ ]);
171+ $ this ->testApi = new TestApi ($ this ->client );
172+
173+ $ this ->eventDispatcher
174+ ->expects ($ this ->once ())
175+ ->method ('addSubscriber ' )
176+ ;
177+
178+ $ this ->eventDispatcher
179+ ->expects ($ this ->once ())
180+ ->method ('removeSubscriber ' )
181+ ;
182+
183+ $ subscriber = $ this ->getMock ('Symfony\Component\EventDispatcher\EventSubscriberInterface ' );
184+ $ this ->testApi ->addSubscriber ($ subscriber );
185+ $ this ->testApi ->removeSubscriber ($ subscriber );
186+ }
187+
161188 /**
162189 * @test
163190 */
@@ -222,4 +249,9 @@ public function addSubscriber($event)
222249 {
223250 $ this ->client ->getHttpClient ()->addSubscriber ($ event );
224251 }
252+
253+ public function removeSubscriber ($ event )
254+ {
255+ $ this ->client ->getHttpClient ()->removeSubscriber ($ event );
256+ }
225257}
You can’t perform that action at this time.
0 commit comments