@@ -833,6 +833,46 @@ public function testGetsExpiredArchive()
833833 $ this ->assertEquals ("expired " , $ archive ->status );
834834 }
835835
836+ public function testForceDisconnect ()
837+ {
838+ // Arrange
839+ $ mock = new MockPlugin ();
840+ $ response = MockPlugin::getMockFile (
841+ self ::$ mockBasePath . 'v2/project/APIKEY/connection/CONNECTIONID/delete '
842+ );
843+ $ mock ->addResponse ($ response );
844+ $ this ->client ->addSubscriber ($ mock );
845+
846+ $ connectionId = '063e72a4-64b4-43c8-9da5-eca071daab89 ' ;
847+
848+ // Act
849+ $ success = $ this ->opentok ->forceDisconnect ($ connectionId );
850+
851+ // Assert
852+ $ requests = $ mock ->getReceivedRequests ();
853+ $ this ->assertCount (1 , $ requests );
854+
855+ $ request = $ requests [0 ];
856+ $ this ->assertEquals ('DELETE ' , strtoupper ($ request ->getMethod ()));
857+ $ this ->assertEquals ('/v2/project/ ' .$ this ->API_KEY .'/connection/ ' .$ connectionId , $ request ->getPath ());
858+ $ this ->assertEquals ('api.opentok.com ' , $ request ->getHost ());
859+ $ this ->assertEquals ('https ' , $ request ->getScheme ());
860+
861+ $ contentType = $ request ->getHeader ('Content-Type ' );
862+ $ this ->assertNotEmpty ($ contentType );
863+ $ this ->assertEquals ('application/json ' , $ contentType );
864+
865+ $ authString = $ request ->getHeader ('X-OPENTOK-AUTH ' );
866+ $ this ->assertEquals (true , TestHelpers::validateOpenTokAuthHeader ($ this ->API_KEY , $ this ->API_SECRET , $ authString ));
867+
868+ // TODO: test the dynamically built User Agent string
869+ $ userAgent = $ request ->getHeader ('User-Agent ' );
870+ $ this ->assertNotEmpty ($ userAgent );
871+ $ this ->assertStringStartsWith ('OpenTok-PHP-SDK/2.4.1-alpha.1 ' , $ userAgent ->__toString ());
872+
873+ $ this ->assertTrue ($ success );
874+ }
875+
836876 public function testStartsBroadcast ()
837877 {
838878 // Arrange
0 commit comments