@@ -496,7 +496,7 @@ public function testStartsArchive()
496496 ]]);
497497
498498 // This sessionId was generated using a different apiKey, but this method doesn't do any
499- // decoding to check, so its fine.
499+ // decoding to check, so it's fine.
500500 $ sessionId = '2_MX44NTQ1MTF-flR1ZSBOb3YgMTIgMDk6NDA6NTkgUFNUIDIwMTN-MC43NjU0Nzh- ' ;
501501
502502 // Act
@@ -546,7 +546,7 @@ public function testStartsArchiveNamed()
546546 ]]);
547547
548548 // This sessionId was generated using a different apiKey, but this method doesn't do any
549- // decoding to check, so its fine.
549+ // decoding to check, so it's fine.
550550 $ sessionId = '2_MX44NTQ1MTF-flR1ZSBOb3YgMTIgMDk6NDA6NTkgUFNUIDIwMTN-MC43NjU0Nzh- ' ;
551551
552552 // Act
@@ -594,7 +594,7 @@ public function testStartsArchiveNamedDeprecated()
594594 ]]);
595595
596596 // This sessionId was generated using a different apiKey, but this method doesn't do any
597- // decoding to check, so its fine.
597+ // decoding to check, so it's fine.
598598 $ sessionId = '2_MX44NTQ1MTF-flR1ZSBOb3YgMTIgMDk6NDA6NTkgUFNUIDIwMTN-MC43NjU0Nzh- ' ;
599599
600600 // Act
@@ -641,7 +641,7 @@ public function testStartsArchiveAudioOnly()
641641 ]]);
642642
643643 // This sessionId was generated using a different apiKey, but this method doesn't do any
644- // decoding to check, so its fine.
644+ // decoding to check, so it's fine.
645645 $ sessionId = '2_MX44NTQ1MTF-flR1ZSBOb3YgMTIgMDk6NDA6NTkgUFNUIDIwMTN-MC43NjU0Nzh- ' ;
646646
647647 // Act
@@ -689,7 +689,7 @@ public function testStartsArchiveIndividualOutput()
689689 ]]);
690690
691691 // This sessionId was generated using a different apiKey, but this method doesn't do any
692- // decoding to check, so its fine.
692+ // decoding to check, so it's fine.
693693 $ sessionId = '2_MX44NTQ1MTF-flR1ZSBOb3YgMTIgMDk6NDA6NTkgUFNUIDIwMTN-MC43NjU0Nzh- ' ;
694694
695695 // Act
@@ -738,7 +738,7 @@ public function testStartsArchiveResolutionSD()
738738 ]]);
739739
740740 // This sessionId was generated using a different apiKey, but this method doesn't do any
741- // decoding to check, so its fine.
741+ // decoding to check, so it's fine.
742742 $ sessionId = '2_MX44NTQ1MTF-flR1ZSBOb3YgMTIgMDk6NDA6NTkgUFNUIDIwMTN-MC43NjU0Nzh- ' ;
743743
744744 // Act
@@ -786,7 +786,7 @@ public function testStartsArchiveResolutionHD()
786786 ]]);
787787
788788 // This sessionId was generated using a different apiKey, but this method doesn't do any
789- // decoding to check, so its fine.
789+ // decoding to check, so it's fine.
790790 $ sessionId = '2_MX44NTQ1MTF-flR1ZSBOb3YgMTIgMDk6NDA6NTkgUFNUIDIwMTN-MC43NjU0Nzh- ' ;
791791
792792 // Act
@@ -1167,7 +1167,7 @@ public function testStartsBroadcast()
11671167 ]]);
11681168
11691169 // This sessionId was generated using a different apiKey, but this method doesn't do any
1170- // decoding to check, so its fine.
1170+ // decoding to check, so it's fine.
11711171 $ sessionId = '2_MX44NTQ1MTF-fjE0NzI0MzU2MDUyMjN-eVgwNFJhZmR6MjdockFHanpxNzBXaEFXfn4 ' ;
11721172
11731173 // Act
@@ -1204,6 +1204,64 @@ public function testStartsBroadcast()
12041204 $ this ->assertFalse ($ broadcast ->isStopped );
12051205 }
12061206
1207+ public function testStartBroadcastWithOptions ()
1208+ {
1209+ // Arrange
1210+ $ this ->setupOTWithMocks ([[
1211+ 'code ' => 200 ,
1212+ 'headers ' => [
1213+ 'Content-Type ' => 'application/json '
1214+ ],
1215+ 'path ' => '/v2/project/APIKEY/broadcast/session_layout-bestfit '
1216+ ]]);
1217+
1218+ // This sessionId was generated using a different apiKey, but this method doesn't do any
1219+ // decoding to check, so it's fine.
1220+ $ sessionId = '2_MX44NTQ1MTF-fjE0NzI0MzU2MDUyMjN-eVgwNFJhZmR6MjdockFHanpxNzBXaEFXfn4 ' ;
1221+
1222+ $ maxDuration = 5400 ;
1223+ $ resolution = '1280x720 ' ;
1224+ $ broadcastOptions = [
1225+ 'maxDuration ' => $ maxDuration ,
1226+ 'resolution ' => $ resolution ,
1227+ ];
1228+
1229+ // Act
1230+ $ broadcast = $ this ->opentok ->startBroadcast ($ sessionId , $ broadcastOptions );
1231+
1232+ // Assert
1233+ $ this ->assertCount (1 , $ this ->historyContainer );
1234+
1235+ $ request = $ this ->historyContainer [0 ]['request ' ];
1236+ $ this ->assertEquals ('POST ' , strtoupper ($ request ->getMethod ()));
1237+ $ this ->assertEquals ('/v2/project/ ' .$ this ->API_KEY .'/broadcast ' , $ request ->getUri ()->getPath ());
1238+ $ this ->assertEquals ('api.opentok.com ' , $ request ->getUri ()->getHost ());
1239+ $ this ->assertEquals ('https ' , $ request ->getUri ()->getScheme ());
1240+
1241+ $ contentType = $ request ->getHeaderLine ('Content-Type ' );
1242+ $ this ->assertNotEmpty ($ contentType );
1243+ $ this ->assertEquals ('application/json ' , $ contentType );
1244+
1245+ $ authString = $ request ->getHeaderLine ('X-OPENTOK-AUTH ' );
1246+ $ this ->assertEquals (true , TestHelpers::validateOpenTokAuthHeader ($ this ->API_KEY , $ this ->API_SECRET , $ authString ));
1247+
1248+ // TODO: test the dynamically built User Agent string
1249+ $ userAgent = $ request ->getHeaderLine ('User-Agent ' );
1250+ $ this ->assertNotEmpty ($ userAgent );
1251+ $ this ->assertStringStartsWith ('OpenTok-PHP-SDK/4.3.0 ' , $ userAgent );
1252+
1253+ $ this ->assertInstanceOf ('OpenTok\Broadcast ' , $ broadcast );
1254+ $ this ->assertInternalType ('string ' , $ broadcast ->id );
1255+ $ this ->assertEquals ($ sessionId , $ broadcast ->sessionId );
1256+ $ this ->assertEquals ($ maxDuration , $ broadcast ->maxDuration );
1257+ $ this ->assertEquals ($ resolution , $ broadcast ->resolution );
1258+ $ this ->assertInternalType ('array ' , $ broadcast ->broadcastUrls );
1259+ $ this ->assertArrayHasKey ('hls ' , $ broadcast ->broadcastUrls );
1260+ $ this ->assertInternalType ('string ' , $ broadcast ->broadcastUrls ['hls ' ]);
1261+ $ this ->assertInternalType ('string ' , $ broadcast ->hlsUrl );
1262+ $ this ->assertFalse ($ broadcast ->isStopped );
1263+ }
1264+
12071265 // TODO: test startBroadcast with layout
12081266
12091267 public function testStopsBroadcast ()
0 commit comments