@@ -24,16 +24,16 @@ public function testShow()
24
24
{
25
25
$ expected = $ this ->getProjectDefinition ();
26
26
27
- $ projectId = 1 ;
27
+ $ projectName = ' project ' ;
28
28
29
29
/** @var Projects&\PHPUnit_Framework_MockObject_MockObject $api */
30
30
$ api = $ this ->getApiMock ();
31
31
$ api ->expects ($ this ->once ())
32
32
->method ('get ' )
33
- ->with ($ this ->equalTo ('/projects/1 / ' ))
33
+ ->with ($ this ->equalTo ('/projects/project / ' ))
34
34
->will ($ this ->returnValue ($ expected ));
35
35
36
- $ this ->assertSame ($ expected , $ api ->show ($ projectId ));
36
+ $ this ->assertSame ($ expected , $ api ->show ($ projectName ));
37
37
}
38
38
39
39
public function testCreate ()
@@ -58,10 +58,10 @@ public function testRemove()
58
58
$ api = $ this ->getApiMock ();
59
59
$ api ->expects ($ this ->once ())
60
60
->method ('delete ' )
61
- ->with ($ this ->equalTo ('/projects/1 / ' ))
61
+ ->with ($ this ->equalTo ('/projects/project / ' ))
62
62
->will ($ this ->returnValue ($ expected ));
63
63
64
- $ this ->assertSame ($ expected , $ api ->remove (1 ));
64
+ $ this ->assertSame ($ expected , $ api ->remove (' project ' ));
65
65
}
66
66
67
67
public function testListTeams ()
@@ -80,10 +80,10 @@ public function testListTeams()
80
80
$ api = $ this ->getApiMock ();
81
81
$ api ->expects ($ this ->once ())
82
82
->method ('get ' )
83
- ->with ($ this ->equalTo ('/projects/1 /teams/ ' ))
83
+ ->with ($ this ->equalTo ('/projects/project /teams/ ' ))
84
84
->will ($ this ->returnValue ($ expected ));
85
85
86
- $ this ->assertSame ($ expected , $ api ->listTeams (1 ));
86
+ $ this ->assertSame ($ expected , $ api ->listTeams (' project ' ));
87
87
}
88
88
89
89
public function testAddOrUpdateTeam ()
@@ -104,10 +104,10 @@ public function testAddOrUpdateTeam()
104
104
$ api = $ this ->getApiMock ();
105
105
$ api ->expects ($ this ->once ())
106
106
->method ('post ' )
107
- ->with ($ this ->equalTo ('/projects/1 /teams/ ' ), $ this ->equalTo ($ teams ))
107
+ ->with ($ this ->equalTo ('/projects/project /teams/ ' ), $ this ->equalTo ($ teams ))
108
108
->will ($ this ->returnValue ($ expected ));
109
109
110
- $ this ->assertSame ($ expected , $ api ->addOrUpdateTeams (1 , $ teams ));
110
+ $ this ->assertSame ($ expected , $ api ->addOrUpdateTeams (' project ' , $ teams ));
111
111
}
112
112
113
113
public function testRemoveTeam ()
@@ -118,10 +118,10 @@ public function testRemoveTeam()
118
118
$ api = $ this ->getApiMock ();
119
119
$ api ->expects ($ this ->once ())
120
120
->method ('delete ' )
121
- ->with ($ this ->equalTo ('/projects/1 /teams/42/ ' ))
121
+ ->with ($ this ->equalTo ('/projects/project /teams/42/ ' ))
122
122
->will ($ this ->returnValue ($ expected ));
123
123
124
- $ this ->assertSame ($ expected , $ api ->removeTeam (1 , 42 ));
124
+ $ this ->assertSame ($ expected , $ api ->removeTeam (' project ' , 42 ));
125
125
}
126
126
127
127
public function testListPackages ()
@@ -139,10 +139,88 @@ public function testListPackages()
139
139
$ api = $ this ->getApiMock ();
140
140
$ api ->expects ($ this ->once ())
141
141
->method ('get ' )
142
- ->with ($ this ->equalTo ('/projects/1 /packages/ ' ))
142
+ ->with ($ this ->equalTo ('/projects/project /packages/ ' ))
143
143
->will ($ this ->returnValue ($ expected ));
144
144
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 ]));
146
224
}
147
225
148
226
private function getProjectDefinition ()
0 commit comments