Skip to content

Commit bc50424

Browse files
committed
More tests for current user api implementation
1 parent 4ef88e4 commit bc50424

File tree

2 files changed

+158
-0
lines changed

2 files changed

+158
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
namespace Github\Tests\Api;
4+
5+
use Github\Tests\Api\TestCase;
6+
7+
/**
8+
* CurrentUser followers api test case
9+
*
10+
* @author Joseph Bielawski <[email protected]>
11+
*/
12+
class FollowersTest extends TestCase
13+
{
14+
/**
15+
* @test
16+
*/
17+
public function shouldGetFollowers()
18+
{
19+
$expectedValue = array(
20+
array('login' => 'l3l0'),
21+
array('login' => 'cordoval')
22+
);
23+
24+
$api = $this->getApiMock();
25+
$api->expects($this->once())
26+
->method('get')
27+
->with('user/following')
28+
->will($this->returnValue($expectedValue));
29+
30+
$this->assertEquals($expectedValue, $api->all());
31+
}
32+
33+
/**
34+
* @test
35+
*/
36+
public function shouldCheckFollower()
37+
{
38+
$api = $this->getApiMock();
39+
$api->expects($this->once())
40+
->method('get')
41+
->with('user/following/l3l0')
42+
->will($this->returnValue(null));
43+
44+
$this->assertNull($api->check('l3l0'));
45+
}
46+
47+
/**
48+
* @test
49+
*/
50+
public function shouldFollowUser()
51+
{
52+
$api = $this->getApiMock();
53+
$api->expects($this->once())
54+
->method('put')
55+
->with('user/following/l3l0')
56+
->will($this->returnValue(null));
57+
58+
$this->assertNull($api->follow('l3l0'));
59+
}
60+
61+
/**
62+
* @test
63+
*/
64+
public function shouldUnfollowUser()
65+
{
66+
$api = $this->getApiMock();
67+
$api->expects($this->once())
68+
->method('delete')
69+
->with('user/following/l3l0')
70+
->will($this->returnValue(null));
71+
72+
$this->assertNull($api->unfollow('l3l0'));
73+
}
74+
75+
protected function getApiClass()
76+
{
77+
return 'Github\Api\CurrentUser\Followers';
78+
}
79+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
namespace Github\Tests\Api;
4+
5+
use Github\Tests\Api\TestCase;
6+
7+
/**
8+
* CurrentUser watchers api test case
9+
*
10+
* @author Joseph Bielawski <[email protected]>
11+
*/
12+
class WatchersTest extends TestCase
13+
{
14+
/**
15+
* @test
16+
*/
17+
public function shouldGetWatchers()
18+
{
19+
$expectedValue = array(
20+
array('name' => 'l3l0/test'),
21+
array('name' => 'cordoval/test')
22+
);
23+
24+
$api = $this->getApiMock();
25+
$api->expects($this->once())
26+
->method('get')
27+
->with('user/watched')
28+
->will($this->returnValue($expectedValue));
29+
30+
$this->assertEquals($expectedValue, $api->all());
31+
}
32+
33+
/**
34+
* @test
35+
*/
36+
public function shouldCheckWatcher()
37+
{
38+
$api = $this->getApiMock();
39+
$api->expects($this->once())
40+
->method('get')
41+
->with('user/watched/l3l0/test')
42+
->will($this->returnValue(null));
43+
44+
$this->assertNull($api->check('l3l0', 'test'));
45+
}
46+
47+
/**
48+
* @test
49+
*/
50+
public function shouldWatchUser()
51+
{
52+
$api = $this->getApiMock();
53+
$api->expects($this->once())
54+
->method('put')
55+
->with('user/watched/l3l0/test')
56+
->will($this->returnValue(null));
57+
58+
$this->assertNull($api->watch('l3l0', 'test'));
59+
}
60+
61+
/**
62+
* @test
63+
*/
64+
public function shouldUnwatchUser()
65+
{
66+
$api = $this->getApiMock();
67+
$api->expects($this->once())
68+
->method('delete')
69+
->with('user/watched/l3l0/test')
70+
->will($this->returnValue(null));
71+
72+
$this->assertNull($api->unwatch('l3l0', 'test'));
73+
}
74+
75+
protected function getApiClass()
76+
{
77+
return 'Github\Api\CurrentUser\Watchers';
78+
}
79+
}

0 commit comments

Comments
 (0)