@@ -64,6 +64,8 @@ public function testListPackages()
6464 [
6565 'name ' => 'composer/composer ' ,
6666 'origin ' => 'private ' ,
67+ 'versionConstraint ' => null ,
68+ 'expirationDate ' => null ,
6769 ],
6870 ];
6971
@@ -83,6 +85,8 @@ public function testAddPackages()
8385 [
8486 'name ' => 'composer/composer ' ,
8587 'origin ' => 'private ' ,
88+ 'versionConstraint ' => null ,
89+ 'expirationDate ' => null ,
8690 ],
8791 ];
8892
@@ -125,6 +129,42 @@ public function testRemovePackage()
125129 $ this ->assertSame ($ expected , $ api ->removePackage (1 , $ packageName ));
126130 }
127131
132+ public function testRegenerateToken ()
133+ {
134+ $ expected = [
135+ 'url ' => 'https://repo.packagist.com/acme-website/ ' ,
136+ 'user ' => 'token ' ,
137+ 'token ' => 'regenerated-token ' ,
138+ 'lastUsed ' => null ,
139+ ];
140+
141+ $ confirmation = [
142+ 'IConfirmOldTokenWillStopWorkingImmediately ' => true ,
143+ ];
144+
145+ /** @var Customers&\PHPUnit_Framework_MockObject_MockObject $api */
146+ $ api = $ this ->getApiMock ();
147+ $ api ->expects ($ this ->once ())
148+ ->method ('post ' )
149+ ->with ($ this ->equalTo ('/customers/1/token/regenerate ' ), $ this ->equalTo ($ confirmation ))
150+ ->will ($ this ->returnValue ($ expected ));
151+
152+ $ this ->assertSame ($ expected , $ api ->regenerateToken (1 , $ confirmation ));
153+ }
154+
155+ /**
156+ * @expectedException \PrivatePackagist\ApiClient\Exception\InvalidArgumentException
157+ */
158+ public function testRegenerateTokenMissingConfirmation ()
159+ {
160+ /** @var Customers&\PHPUnit_Framework_MockObject_MockObject $api */
161+ $ api = $ this ->getApiMock ();
162+ $ api ->expects ($ this ->never ())
163+ ->method ('post ' );
164+
165+ $ api ->regenerateToken (1 , []);
166+ }
167+
128168 protected function getApiClass ()
129169 {
130170 return Customers::class;
0 commit comments