Skip to content

Commit 3bf25e8

Browse files
committed
added tests for Starred API
1 parent fb54d8a commit 3bf25e8

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace Github\Tests\Api;
4+
5+
use Github\Tests\Api\TestCase;
6+
7+
class StarredTest extends TestCase
8+
{
9+
/**
10+
* @test
11+
*/
12+
public function shouldGetStarred()
13+
{
14+
$expectedValue = array(
15+
array('name' => 'l3l0/test'),
16+
array('name' => 'cordoval/test')
17+
);
18+
19+
$api = $this->getApiMock();
20+
$api->expects($this->once())
21+
->method('get')
22+
->with('user/starred')
23+
->will($this->returnValue($expectedValue));
24+
25+
$this->assertEquals($expectedValue, $api->all());
26+
}
27+
28+
/**
29+
* @test
30+
*/
31+
public function shouldCheckStar()
32+
{
33+
$api = $this->getApiMock();
34+
$api->expects($this->once())
35+
->method('get')
36+
->with('user/starred/l3l0/test')
37+
->will($this->returnValue(null));
38+
39+
$this->assertNull($api->check('l3l0', 'test'));
40+
}
41+
42+
/**
43+
* @test
44+
*/
45+
public function shouldStarUser()
46+
{
47+
$api = $this->getApiMock();
48+
$api->expects($this->once())
49+
->method('put')
50+
->with('user/starred/l3l0/test')
51+
->will($this->returnValue(null));
52+
53+
$this->assertNull($api->star('l3l0', 'test'));
54+
}
55+
56+
/**
57+
* @test
58+
*/
59+
public function shouldUnstarUser()
60+
{
61+
$api = $this->getApiMock();
62+
$api->expects($this->once())
63+
->method('delete')
64+
->with('user/starred/l3l0/test')
65+
->will($this->returnValue(null));
66+
67+
$this->assertNull($api->unstar('l3l0', 'test'));
68+
}
69+
70+
protected function getApiClass()
71+
{
72+
return 'Github\Api\CurrentUser\Starred';
73+
}
74+
}

test/Github/Tests/Api/CurrentUserTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ public function shouldGetWatchersApiObject()
133133

134134
$this->assertInstanceOf('Github\Api\CurrentUser\Watchers', $api->watchers());
135135
}
136+
137+
/**
138+
* @test
139+
*/
140+
public function shouldGetStarredApiObject()
141+
{
142+
$api = $this->getApiMock();
143+
144+
$this->assertInstanceOf('Github\Api\CurrentUser\Starred', $api->starred());
145+
}
136146

137147
protected function getApiClass()
138148
{

0 commit comments

Comments
 (0)