@@ -2769,6 +2769,61 @@ public function shouldCreateProjectAccessToken(): void
27692769 ]));
27702770 }
27712771
2772+ #[Test]
2773+ public function shouldRotateProjectAccessToken (): void
2774+ {
2775+ $ expectedArray = [
2776+ 'scopes ' => [
2777+ 'api ' ,
2778+ 'read_repository ' ,
2779+ ],
2780+ 'active ' => true ,
2781+ 'name ' => 'test ' ,
2782+ 'revoked ' => false ,
2783+ 'created_at ' => '2021-01-21T19:35:37.921Z ' ,
2784+ 'user_id ' => 166 ,
2785+ 'id ' => 58 ,
2786+ 'expires_at ' => '2021-01-31 ' ,
2787+ 'token ' => 'D4y...Wzr ' ,
2788+ ];
2789+ $ expiresAt = new DateTime ('2021-01-31 ' );
2790+
2791+ $ api = $ this ->getApiMock ();
2792+ $ api ->expects ($ this ->once ())
2793+ ->method ('post ' )
2794+ ->with ('projects/1/access_tokens/2/rotate ' , ['expires_at ' => '2021-01-31 ' ])
2795+ ->willReturn ($ expectedArray );
2796+
2797+ $ this ->assertEquals ($ expectedArray , $ api ->rotateProjectAccessToken (1 , 2 , ['expires_at ' => $ expiresAt ]));
2798+ }
2799+
2800+ #[Test]
2801+ public function shouldRotateCurrentProjectAccessToken (): void
2802+ {
2803+ $ expectedArray = [
2804+ 'scopes ' => [
2805+ 'api ' ,
2806+ 'read_repository ' ,
2807+ ],
2808+ 'active ' => true ,
2809+ 'name ' => 'test ' ,
2810+ 'revoked ' => false ,
2811+ 'created_at ' => '2021-01-21T19:35:37.921Z ' ,
2812+ 'user_id ' => 166 ,
2813+ 'id ' => 58 ,
2814+ 'expires_at ' => '2021-01-31 ' ,
2815+ 'token ' => 'D4y...Wzr ' ,
2816+ ];
2817+
2818+ $ api = $ this ->getApiMock ();
2819+ $ api ->expects ($ this ->once ())
2820+ ->method ('post ' )
2821+ ->with ('projects/1/access_tokens/self/rotate ' , [])
2822+ ->willReturn ($ expectedArray );
2823+
2824+ $ this ->assertEquals ($ expectedArray , $ api ->rotateProjectAccessToken (1 , 'self ' ));
2825+ }
2826+
27722827 #[Test]
27732828 public function shouldDeleteProjectAccessToken (): void
27742829 {
0 commit comments