33namespace AppBundle \Tests \Issues \GitHub ;
44
55use AppBundle \Issues \GitHub \CachedLabelsApi ;
6+ use AppBundle \Repository \Repository ;
67use Github \Api \Issue \Labels ;
78
89/**
@@ -24,12 +25,20 @@ class CachedLabelsApiTest extends \PHPUnit_Framework_TestCase
2425 */
2526 private $ api ;
2627
28+ private $ repository ;
29+
2730 protected function setUp ()
2831 {
2932 $ this ->backendApi = $ this ->getMockBuilder ('Github\Api\Issue\Labels ' )
3033 ->disableOriginalConstructor ()
3134 ->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+ );
3342 }
3443
3544 public function testGetIssueLabels ()
@@ -43,10 +52,10 @@ public function testGetIssueLabels()
4352 array ('name ' => 'c ' ),
4453 ));
4554
46- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
55+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
4756
4857 // 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 ));
5059 }
5160
5261 public function testAddIssueLabel ()
@@ -58,7 +67,7 @@ public function testAddIssueLabel()
5867 ->method ('add ' )
5968 ->with (self ::USER_NAME , self ::REPO_NAME , 1234 , 'a ' );
6069
61- $ this ->api ->addIssueLabel (1234 , 'a ' );
70+ $ this ->api ->addIssueLabel (1234 , 'a ' , $ this -> repository );
6271 }
6372
6473 public function testAddIssueLabelUpdatesCache ()
@@ -76,11 +85,11 @@ public function testAddIssueLabelUpdatesCache()
7685 ->method ('add ' )
7786 ->with (self ::USER_NAME , self ::REPO_NAME , 1234 , 'd ' );
7887
79- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
88+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
8089
81- $ this ->api ->addIssueLabel (1234 , 'd ' );
90+ $ this ->api ->addIssueLabel (1234 , 'd ' , $ this -> repository );
8291
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 ));
8493 }
8594
8695 public function testAddIssueLabelIgnoresDuplicate ()
@@ -97,11 +106,11 @@ public function testAddIssueLabelIgnoresDuplicate()
97106 $ this ->backendApi ->expects ($ this ->never ())
98107 ->method ('add ' );
99108
100- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
109+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
101110
102- $ this ->api ->addIssueLabel (1234 , 'c ' );
111+ $ this ->api ->addIssueLabel (1234 , 'c ' , $ this -> repository );
103112
104- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
113+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
105114 }
106115
107116 public function testRemoveIssueLabel ()
@@ -113,7 +122,7 @@ public function testRemoveIssueLabel()
113122 ->method ('remove ' )
114123 ->with (self ::USER_NAME , self ::REPO_NAME , 1234 , 'a ' );
115124
116- $ this ->api ->removeIssueLabel (1234 , 'a ' );
125+ $ this ->api ->removeIssueLabel (1234 , 'a ' , $ this -> repository );
117126 }
118127
119128 public function testRemoveIssueLabelUpdatesCache ()
@@ -131,11 +140,11 @@ public function testRemoveIssueLabelUpdatesCache()
131140 ->method ('remove ' )
132141 ->with (self ::USER_NAME , self ::REPO_NAME , 1234 , 'a ' );
133142
134- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
143+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
135144
136- $ this ->api ->removeIssueLabel (1234 , 'a ' );
145+ $ this ->api ->removeIssueLabel (1234 , 'a ' , $ this -> repository );
137146
138- $ this ->assertSame (array ('b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
147+ $ this ->assertSame (array ('b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
139148 }
140149
141150 public function testRemoveIssueLabelIgnoresUnsetLabel ()
@@ -152,10 +161,10 @@ public function testRemoveIssueLabelIgnoresUnsetLabel()
152161 $ this ->backendApi ->expects ($ this ->never ())
153162 ->method ('remove ' );
154163
155- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
164+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
156165
157- $ this ->api ->removeIssueLabel (1234 , 'd ' );
166+ $ this ->api ->removeIssueLabel (1234 , 'd ' , $ this -> repository );
158167
159- $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 ));
168+ $ this ->assertSame (array ('a ' , 'b ' , 'c ' ), $ this ->api ->getIssueLabels (1234 , $ this -> repository ));
160169 }
161170}
0 commit comments