@@ -24,16 +24,16 @@ public function testShow()
2424 {
2525 $ expected = $ this ->getProjectDefinition ();
2626
27- $ projectId = 1 ;
27+ $ projectName = ' project ' ;
2828
2929 /** @var Projects&\PHPUnit_Framework_MockObject_MockObject $api */
3030 $ api = $ this ->getApiMock ();
3131 $ api ->expects ($ this ->once ())
3232 ->method ('get ' )
33- ->with ($ this ->equalTo ('/projects/1 / ' ))
33+ ->with ($ this ->equalTo ('/projects/project / ' ))
3434 ->will ($ this ->returnValue ($ expected ));
3535
36- $ this ->assertSame ($ expected , $ api ->show ($ projectId ));
36+ $ this ->assertSame ($ expected , $ api ->show ($ projectName ));
3737 }
3838
3939 public function testCreate ()
@@ -58,10 +58,10 @@ public function testRemove()
5858 $ api = $ this ->getApiMock ();
5959 $ api ->expects ($ this ->once ())
6060 ->method ('delete ' )
61- ->with ($ this ->equalTo ('/projects/1 / ' ))
61+ ->with ($ this ->equalTo ('/projects/project / ' ))
6262 ->will ($ this ->returnValue ($ expected ));
6363
64- $ this ->assertSame ($ expected , $ api ->remove (1 ));
64+ $ this ->assertSame ($ expected , $ api ->remove (' project ' ));
6565 }
6666
6767 public function testListTeams ()
@@ -80,10 +80,10 @@ public function testListTeams()
8080 $ api = $ this ->getApiMock ();
8181 $ api ->expects ($ this ->once ())
8282 ->method ('get ' )
83- ->with ($ this ->equalTo ('/projects/1 /teams/ ' ))
83+ ->with ($ this ->equalTo ('/projects/project /teams/ ' ))
8484 ->will ($ this ->returnValue ($ expected ));
8585
86- $ this ->assertSame ($ expected , $ api ->listTeams (1 ));
86+ $ this ->assertSame ($ expected , $ api ->listTeams (' project ' ));
8787 }
8888
8989 public function testAddOrUpdateTeam ()
@@ -104,10 +104,10 @@ public function testAddOrUpdateTeam()
104104 $ api = $ this ->getApiMock ();
105105 $ api ->expects ($ this ->once ())
106106 ->method ('post ' )
107- ->with ($ this ->equalTo ('/projects/1 /teams/ ' ), $ this ->equalTo ($ teams ))
107+ ->with ($ this ->equalTo ('/projects/project /teams/ ' ), $ this ->equalTo ($ teams ))
108108 ->will ($ this ->returnValue ($ expected ));
109109
110- $ this ->assertSame ($ expected , $ api ->addOrUpdateTeams (1 , $ teams ));
110+ $ this ->assertSame ($ expected , $ api ->addOrUpdateTeams (' project ' , $ teams ));
111111 }
112112
113113 public function testRemoveTeam ()
@@ -118,10 +118,10 @@ public function testRemoveTeam()
118118 $ api = $ this ->getApiMock ();
119119 $ api ->expects ($ this ->once ())
120120 ->method ('delete ' )
121- ->with ($ this ->equalTo ('/projects/1 /teams/42/ ' ))
121+ ->with ($ this ->equalTo ('/projects/project /teams/42/ ' ))
122122 ->will ($ this ->returnValue ($ expected ));
123123
124- $ this ->assertSame ($ expected , $ api ->removeTeam (1 , 42 ));
124+ $ this ->assertSame ($ expected , $ api ->removeTeam (' project ' , 42 ));
125125 }
126126
127127 public function testListPackages ()
@@ -139,10 +139,88 @@ public function testListPackages()
139139 $ api = $ this ->getApiMock ();
140140 $ api ->expects ($ this ->once ())
141141 ->method ('get ' )
142- ->with ($ this ->equalTo ('/projects/1 /packages/ ' ))
142+ ->with ($ this ->equalTo ('/projects/project /packages/ ' ))
143143 ->will ($ this ->returnValue ($ expected ));
144144
145- $ this ->assertSame ($ expected , $ api ->listPackages (1 ));
145+ $ this ->assertSame ($ expected , $ api ->listPackages ('project ' ));
146+ }
147+
148+ public function testListTokens ()
149+ {
150+ $ expected = [
151+ [
152+ 'description ' => 'Generated Client Token ' ,
153+ 'access ' => 'read ' ,
154+ 'url ' => 'https://vendor-org.repo.packagist.com/acme-websites/ ' ,
155+ 'user ' => 'token ' ,
156+ 'token ' => 'password ' ,
157+ 'lastUsed ' => '2018-03-14T11:36:00+00:00 '
158+ ],
159+ ];
160+
161+ /** @var Projects&\PHPUnit_Framework_MockObject_MockObject $api */
162+ $ api = $ this ->getApiMock ();
163+ $ api ->expects ($ this ->once ())
164+ ->method ('get ' )
165+ ->with ($ this ->equalTo ('/projects/project/tokens/ ' ))
166+ ->will ($ this ->returnValue ($ expected ));
167+
168+ $ this ->assertSame ($ expected , $ api ->listTokens ('project ' ));
169+ }
170+
171+ public function testCreateToken ()
172+ {
173+ $ expected = [
174+ 'description ' => 'Project Token ' ,
175+ 'access ' => 'read ' ,
176+ 'url ' => 'https://vendor-org.repo.packagist.com/acme-websites/ ' ,
177+ 'user ' => 'token ' ,
178+ 'token ' => 'password ' ,
179+ 'lastUsed ' => '2018-03-14T11:36:00+00:00 '
180+ ];
181+
182+ /** @var Projects&\PHPUnit_Framework_MockObject_MockObject $api */
183+ $ api = $ this ->getApiMock ();
184+ $ api ->expects ($ this ->once ())
185+ ->method ('post ' )
186+ ->with ($ this ->equalTo ('/projects/project/tokens/ ' ), $ this ->equalTo ([
187+ 'description ' => 'Project Token ' ,
188+ 'access ' => 'read ' ,
189+ ]))
190+ ->will ($ this ->returnValue ($ expected ));
191+
192+ $ this ->assertSame ($ expected , $ api ->createToken ('project ' , [
193+ 'description ' => 'Project Token ' ,
194+ 'access ' => 'read ' ,
195+ ]));
196+ }
197+
198+ public function testRemoveToken ()
199+ {
200+ $ expected = [];
201+
202+ /** @var Projects&\PHPUnit_Framework_MockObject_MockObject $api */
203+ $ api = $ this ->getApiMock ();
204+ $ api ->expects ($ this ->once ())
205+ ->method ('delete ' )
206+ ->with ($ this ->equalTo ('/projects/project/tokens/1/ ' ))
207+ ->will ($ this ->returnValue ($ expected ));
208+
209+ $ this ->assertSame ($ expected , $ api ->removeToken ('project ' , 1 ));
210+ }
211+
212+ public function testRegenerateToken ()
213+ {
214+ $ expected = [];
215+
216+ /** @var Projects&\PHPUnit_Framework_MockObject_MockObject $api */
217+ $ api = $ this ->getApiMock ();
218+ $ api ->expects ($ this ->once ())
219+ ->method ('post ' )
220+ ->with ($ this ->equalTo ('/projects/project/tokens/1/regenerate ' ), $ this ->equalTo (['IConfirmOldTokenWillStopWorkingImmediately ' => true ]))
221+ ->will ($ this ->returnValue ($ expected ));
222+
223+ $ this ->assertSame ($ expected , $ api ->regenerateToken ('project ' , 1 , ['IConfirmOldTokenWillStopWorkingImmediately ' => true ]));
146224 }
147225
148226 private function getProjectDefinition ()
0 commit comments