Skip to content

Commit

Permalink
better tests for get app activities
Browse files Browse the repository at this point in the history
  • Loading branch information
ruggi committed Sep 17, 2018
1 parent 86b6b94 commit 1aa0d7e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/GetStream/Stream/Client.php
Expand Up @@ -229,7 +229,7 @@ public function getActivitiesByForeignId($foreignIdTimes = [])
$timestamps = [];
foreach ($foreignIdTimes as $fidTime) {
if (count($fidTime) != 2) {
throw new Exception('malformed foreign ID and time combination');
throw new StreamClientException('malformed foreign ID and time combination');
}
array_push($foreignIds, $fidTime[0]);
array_push($timestamps, $fidTime[1]);
Expand Down
6 changes: 6 additions & 0 deletions lib/GetStream/Stream/StreamClientException.php
@@ -0,0 +1,6 @@
<?php
namespace GetStream\Stream;

class StreamClientException extends \Exception
{
}
6 changes: 6 additions & 0 deletions tests/integration/FeedTest.php
Expand Up @@ -644,5 +644,11 @@ public function testGetAppActivities()
$resp = $this->client->getActivitiesById([$id]);
$this->assertCount(1, $resp['results']);
$this->assertSame($resp['results'][0]['id'], $id);

$resp = $this->client->getActivitiesByForeignId([
[$fid, $resp['results'][0]['time']],
]);
$this->assertCount(1, $resp['results']);
$this->assertSame($resp['results'][0]['id'], $id);
}
}
8 changes: 8 additions & 0 deletions tests/unit/ClientTest.php
Expand Up @@ -68,4 +68,12 @@ public function testEnvironmentVariable()
putenv('STREAM_BASE_URL='.$previous);
}
}

/**
* @expectedException \GetStream\Stream\StreamClientException
*/
public function testGetActivitiesByForeignIdException() {
$client = new Client('key', 'secret');
$client->getActivitiesByForeignId([1, 2]);
}
}

0 comments on commit 1aa0d7e

Please sign in to comment.