3
3
namespace AppBundle \Tests \Issues \GitHub ;
4
4
5
5
use AppBundle \Issues \GitHub \CachedLabelsApi ;
6
+ use AppBundle \Repository \Repository ;
6
7
use Github \Api \Issue \Labels ;
7
8
8
9
/**
@@ -24,12 +25,20 @@ class CachedLabelsApiTest extends \PHPUnit_Framework_TestCase
24
25
*/
25
26
private $ api ;
26
27
28
+ private $ repository ;
29
+
27
30
protected function setUp ()
28
31
{
29
32
$ this ->backendApi = $ this ->getMockBuilder ('Github\Api\Issue\Labels ' )
30
33
->disableOriginalConstructor ()
31
34
->getMock ();
32
- $ this ->api = new CachedLabelsApi ($ this ->backendApi , self ::USER_NAME .'/ ' .self ::REPO_NAME );
35
+ $ this ->api = new CachedLabelsApi ($ this ->backendApi );
36
+ $ this ->repository = new Repository (
37
+ self ::USER_NAME ,
38
+ self ::REPO_NAME ,
39
+ [],
40
+ null
41
+ );
33
42
}
34
43
35
44
public function testGetIssueLabels ()
@@ -43,10 +52,10 @@ public function testGetIssueLabels()
43
52
array ('name ' => 'c ' ),
44
53
));
45
54
46
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
55
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
47
56
48
57
// Subsequent access goes to cache
49
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
58
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
50
59
}
51
60
52
61
public function testAddIssueLabel ()
@@ -58,7 +67,7 @@ public function testAddIssueLabel()
58
67
->method ('add ' )
59
68
->with (self ::USER_NAME , self ::REPO_NAME , 1234 , 'a ' );
60
69
61
- $ this ->api ->addIssueLabel (1234 , 'a ' );
70
+ $ this ->api ->addIssueLabel (1234 , 'a ' , $ this -> repository );
62
71
}
63
72
64
73
public function testAddIssueLabelUpdatesCache ()
@@ -76,11 +85,11 @@ public function testAddIssueLabelUpdatesCache()
76
85
->method ('add ' )
77
86
->with (self ::USER_NAME , self ::REPO_NAME , 1234 , 'd ' );
78
87
79
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
88
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
80
89
81
- $ this ->api ->addIssueLabel (1234 , 'd ' );
90
+ $ this ->api ->addIssueLabel (1234 , 'd ' , $ this -> repository );
82
91
83
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' , 'd ' ), $ this ->api ->getIssueLabels (1234 ));
92
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' , 'd ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
84
93
}
85
94
86
95
public function testAddIssueLabelIgnoresDuplicate ()
@@ -97,11 +106,11 @@ public function testAddIssueLabelIgnoresDuplicate()
97
106
$ this ->backendApi ->expects ($ this ->never ())
98
107
->method ('add ' );
99
108
100
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
109
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
101
110
102
- $ this ->api ->addIssueLabel (1234 , 'c ' );
111
+ $ this ->api ->addIssueLabel (1234 , 'c ' , $ this -> repository );
103
112
104
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
113
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
105
114
}
106
115
107
116
public function testRemoveIssueLabel ()
@@ -113,7 +122,7 @@ public function testRemoveIssueLabel()
113
122
->method ('remove ' )
114
123
->with (self ::USER_NAME , self ::REPO_NAME , 1234 , 'a ' );
115
124
116
- $ this ->api ->removeIssueLabel (1234 , 'a ' );
125
+ $ this ->api ->removeIssueLabel (1234 , 'a ' , $ this -> repository );
117
126
}
118
127
119
128
public function testRemoveIssueLabelUpdatesCache ()
@@ -131,11 +140,11 @@ public function testRemoveIssueLabelUpdatesCache()
131
140
->method ('remove ' )
132
141
->with (self ::USER_NAME , self ::REPO_NAME , 1234 , 'a ' );
133
142
134
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
143
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
135
144
136
- $ this ->api ->removeIssueLabel (1234 , 'a ' );
145
+ $ this ->api ->removeIssueLabel (1234 , 'a ' , $ this -> repository );
137
146
138
- $ this ->assertSame (array ('b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
147
+ $ this ->assertSame (array ('b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
139
148
}
140
149
141
150
public function testRemoveIssueLabelIgnoresUnsetLabel ()
@@ -152,10 +161,10 @@ public function testRemoveIssueLabelIgnoresUnsetLabel()
152
161
$ this ->backendApi ->expects ($ this ->never ())
153
162
->method ('remove ' );
154
163
155
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
164
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
156
165
157
- $ this ->api ->removeIssueLabel (1234 , 'd ' );
166
+ $ this ->api ->removeIssueLabel (1234 , 'd ' , $ this -> repository );
158
167
159
- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
168
+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
160
169
}
161
170
}
0 commit comments