Skip to content

Commit

Permalink
Merge pull request #188 from opentok/dev
Browse files Browse the repository at this point in the history
Release v2.5.1
  • Loading branch information
aiham authored Jun 30, 2017
2 parents 3557fac + bd7ce03 commit ebf9129
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
17 changes: 13 additions & 4 deletions src/OpenTok/Util/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

// TODO: build this dynamically
/** @internal */
define('OPENTOK_SDK_VERSION', '2.5.0');
define('OPENTOK_SDK_VERSION', '2.5.1');
/** @internal */
define('OPENTOK_SDK_USER_AGENT', 'OpenTok-PHP-SDK/' . OPENTOK_SDK_VERSION);

Expand Down Expand Up @@ -123,7 +123,10 @@ public function deleteArchive($archiveId)
$request = $this->delete('/v2/project/'.$this->apiKey.'/archive/'.$archiveId);
$request->setHeader('Content-Type', 'application/json');
try {
$request->send()->json();
$response = $request->send();
if ($response->getStatusCode() != 204) {
$response->json();
}
} catch (\Exception $e) {
$this->handleException($e);
return false;
Expand All @@ -136,7 +139,10 @@ public function forceDisconnect($sessionId,$connectionId)
$request = $this->delete('/v2/project/'.$this->apiKey.'/session/'.$sessionId.'/connection/'.$connectionId);
$request->setHeader('Content-Type', 'application/json');
try {
$request->send()->json();
$response = $request->send();
if ($response->getStatusCode() != 204) {
$response->json();
}
} catch (\Exception $e) {
$this->handleException($e);
return false;
Expand Down Expand Up @@ -229,7 +235,10 @@ public function updateStream($sessionId, $streamId, $properties)
$request->setBody(json_encode($properties));
$request->setHeader('Content-Type', 'application/json');
try {
$request->send()->json();
$response = $request->send();
if ($response->getStatusCode() != 204) {
$response->json();
}
} catch (\Exception $e) {
$this->handleException($e);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/OpenTok/ArchiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public function testStopsArchive()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

// TODO: test the properties of the actual archive object
$this->assertEquals('stopped', $this->archive->status);
Expand Down Expand Up @@ -154,7 +154,7 @@ public function testDeletesArchive()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertTrue($success);
// TODO: assert that all properties of the archive object were cleared
Expand Down
40 changes: 20 additions & 20 deletions tests/OpenTok/OpenTokTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function testCreatesDefaultSession()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$p2p_preference = $request->getPostField('p2p.preference');
$this->assertEquals('enabled', $p2p_preference);
Expand Down Expand Up @@ -140,7 +140,7 @@ public function testCreatesMediaRoutedAndLocationSession()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$location = $request->getPostField('location');
$this->assertEquals('12.34.56.78', $location);
Expand Down Expand Up @@ -188,7 +188,7 @@ public function testCreatesMediaRelayedSession()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$p2p_preference = $request->getPostField('p2p.preference');
$this->assertEquals('enabled', $p2p_preference);
Expand Down Expand Up @@ -233,7 +233,7 @@ public function testCreatesAutoArchivedSession()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$archiveMode = $request->getPostField('archiveMode');
$this->assertEquals('always', $archiveMode);
Expand Down Expand Up @@ -429,7 +429,7 @@ public function testStartsArchive()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertInstanceOf('OpenTok\Archive', $archive);
$this->assertEquals(0, $archive->duration);
Expand Down Expand Up @@ -479,7 +479,7 @@ public function testStartsArchiveNamed()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$body = json_decode($request->getBody());
$this->assertEquals($sessionId, $body->sessionId);
Expand Down Expand Up @@ -527,7 +527,7 @@ public function testStartsArchiveNamedDeprecated()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$body = json_decode($request->getBody());
$this->assertEquals($sessionId, $body->sessionId);
Expand Down Expand Up @@ -574,7 +574,7 @@ public function testStartsArchiveAudioOnly()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$body = json_decode($request->getBody());
$this->assertEquals($sessionId, $body->sessionId);
Expand Down Expand Up @@ -624,7 +624,7 @@ public function testStartsArchiveIndividualOutput()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$body = json_decode($request->getBody());
$this->assertEquals($sessionId, $body->sessionId);
Expand Down Expand Up @@ -669,7 +669,7 @@ public function testStopsArchive()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertInstanceOf('OpenTok\Archive', $archive);
// TODO: test the properties of the actual archive object
Expand Down Expand Up @@ -708,7 +708,7 @@ public function testGetsArchive()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertInstanceOf('OpenTok\Archive', $archive);
// TODO: test the properties of the actual archive object
Expand Down Expand Up @@ -749,7 +749,7 @@ public function testDeletesArchive()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertTrue($success);
// TODO: test the properties of the actual archive object
Expand Down Expand Up @@ -784,7 +784,7 @@ public function testListsArchives()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertInstanceOf('OpenTok\ArchiveList', $archiveList);
// TODO: test the properties of the actual archiveList object and its contained archive
Expand Down Expand Up @@ -872,7 +872,7 @@ public function testForceDisconnect()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertTrue($success);
}
Expand Down Expand Up @@ -914,7 +914,7 @@ public function testStartsBroadcast()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertInstanceOf('OpenTok\Broadcast', $broadcast);
$this->assertInternalType('string', $broadcast->id);
Expand Down Expand Up @@ -959,7 +959,7 @@ public function testStopsBroadcast()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertInstanceOf('OpenTok\Broadcast', $broadcast);
$this->assertTrue($broadcast->isStopped);
Expand Down Expand Up @@ -996,7 +996,7 @@ public function testGetsBroadcast()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());

$this->assertInstanceOf('OpenTok\Broadcast', $broadcast);
}
Expand Down Expand Up @@ -1040,7 +1040,7 @@ public function testUpdatesBroadcastLayoutWithPredefined()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());
}

public function testUpdatesBroadcastLayoutWithCustom()
Expand Down Expand Up @@ -1086,7 +1086,7 @@ public function testUpdatesBroadcastLayoutWithCustom()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());
}

public function testUpdatesStreamLayoutClassList()
Expand Down Expand Up @@ -1131,7 +1131,7 @@ public function testUpdatesStreamLayoutClassList()
// TODO: test the dynamically built User Agent string
$userAgent = $request->getHeader('User-Agent');
$this->assertNotEmpty($userAgent);
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.0', $userAgent->__toString());
$this->assertStringStartsWith('OpenTok-PHP-SDK/2.5.1', $userAgent->__toString());
}


Expand Down

0 comments on commit ebf9129

Please sign in to comment.