Skip to content

Commit 10a85ea

Browse files
committed
Add docs and tests for List Events by Authenticated User method
1 parent b565d6d commit 10a85ea

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

doc/activity.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ $activity = $client->api('current_user')->starring()->all();
3131
```
3232
Returns an array of starred repos.
3333

34+
### Get list of private and public events for an authenticated user for all repos
35+
36+
```php
37+
$activity = $client->api('user')->events('ornicar');
38+
```
39+
Returns an array of private and public events created for all repos related to the user.
40+
3441
### Get repos that a authenticated user has starred with creation date
3542

3643
Support for getting the star creation timestamp in the response, using the custom `Accept: application/vnd.github.v3.star+json` header.
@@ -100,4 +107,4 @@ $owner = "KnpLabs";
100107
$repo = "php-github-api";
101108
$activity = $client->api('current_user')->watchers()->unwatch($owner, $repo);
102109
```
103-
Throws an Exception in case of failure or NULL in case of success.
110+
Throws an Exception in case of failure or NULL in case of success.

doc/users.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,17 @@ $users = $client->api('current_user')->starring()->all();
148148

149149
Returns an array of starred repos.
150150

151+
### Get the authenticated user activity
152+
153+
> Requires [authentication](security.md).
154+
155+
```php
156+
$activity = $client->api('user')->events('ornicar');
157+
```
158+
159+
Returns an array of private and public events created for all repos related to the user.
160+
> See [more](activity.md).
161+
151162
### Get the authenticated user emails
152163

153164
> Requires [authentication](security.md).

test/Github/Tests/Integration/UserTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,25 @@ public function shouldGetReposBeingStarred()
138138
$this->assertArrayHasKey('git_url', $repo);
139139
$this->assertArrayHasKey('svn_url', $repo);
140140
}
141+
142+
/**
143+
* @test
144+
*/
145+
public function shouldGetEventsForAuthenticatedUserBeignWatched()
146+
{
147+
$username = 'l3l0';
148+
149+
$events = $this->client->api('user')->events($username);
150+
$event = array_pop($events);
151+
152+
$this->assertArrayHasKey('id', $event);
153+
$this->assertArrayHasKey('type', $event);
154+
$this->assertArrayHasKey('actor', $event);
155+
$this->assertArrayHasKey('login', $event['actor']);
156+
$this->assertArrayHasKey('repo', $event);
157+
$this->assertArrayHasKey('name', $event['repo']);
158+
$this->assertArrayHasKey('payload', $event);
159+
$this->assertArrayHasKey('public', $event);
160+
$this->assertArrayHasKey('created_at', $event);
161+
}
141162
}

0 commit comments

Comments
 (0)