@@ -70,36 +70,43 @@ public static function tagNodeProvider(): array {
7070 [
7171 true ,
7272 new SystemTag ('1 ' , 'Original ' , true , true ),
73- ['Renamed ' , true , true , null ]
73+ ['Renamed ' , true , true , null ],
74+ true ,
7475 ],
7576 [
7677 true ,
7778 new SystemTag ('1 ' , 'Original ' , true , true ),
78- ['Original ' , false , false , null ]
79+ ['Original ' , false , false , null ],
80+ true ,
7981 ],
8082 // non-admin
8183 [
82- // renaming allowed
84+ // renaming not allowed
8385 false ,
8486 new SystemTag ('1 ' , 'Original ' , true , true ),
85- ['Rename ' , true , true , '0082c9 ' ]
87+ ['Renamed ' , true , true , null ],
88+ false ,
8689 ],
8790 ];
8891 }
8992
9093 #[\PHPUnit \Framework \Attributes \DataProvider('tagNodeProvider ' )]
91- public function testUpdateTag (bool $ isAdmin , ISystemTag $ originalTag , array $ changedArgs ): void {
92- $ this ->tagManager ->expects ($ this ->once ())
93- ->method ('canUserSeeTag ' )
94+ public function testUpdateTag (bool $ isAdmin , ISystemTag $ originalTag , $ changedArgs , $ allowed ): void {
95+ $ this ->tagManager ->method ('canUserSeeTag ' )
9496 ->with ($ originalTag )
9597 ->willReturn ($ originalTag ->isUserVisible () || $ isAdmin );
96- $ this ->tagManager ->expects ($ this ->once ())
97- ->method ('canUserAssignTag ' )
98+ $ this ->tagManager ->method ('canUserAssignTag ' )
9899 ->with ($ originalTag )
99100 ->willReturn ($ originalTag ->isUserAssignable () || $ isAdmin );
100- $ this ->tagManager ->expects ($ this ->once ())
101- ->method ('updateTag ' )
102- ->with (1 , $ changedArgs [0 ], $ changedArgs [1 ], $ changedArgs [2 ], $ changedArgs [3 ]);
101+ if ($ allowed ) {
102+ $ this ->tagManager ->expects ($ this ->once ())
103+ ->method ('updateTag ' )
104+ ->with (1 , $ changedArgs [0 ], $ changedArgs [1 ], $ changedArgs [2 ], $ changedArgs [3 ]);
105+ } else {
106+ $ this ->expectException (\Sabre \DAV \Exception \Forbidden::class);
107+ $ this ->tagManager ->expects ($ this ->never ())
108+ ->method ('updateTag ' );
109+ }
103110 $ this ->getTagNode ($ isAdmin , $ originalTag )
104111 ->update ($ changedArgs [0 ], $ changedArgs [1 ], $ changedArgs [2 ], $ changedArgs [3 ]);
105112 }
@@ -187,7 +194,7 @@ public function testUpdateTagAlreadyExists(): void {
187194 ->method ('updateTag ' )
188195 ->with (1 , 'Renamed ' , true , true )
189196 ->willThrowException (new TagAlreadyExistsException ());
190- $ this ->getTagNode (false , $ tag )->update ('Renamed ' , true , true , null );
197+ $ this ->getTagNode (true , $ tag )->update ('Renamed ' , true , true , null );
191198 }
192199
193200
@@ -207,7 +214,7 @@ public function testUpdateTagNotFound(): void {
207214 ->method ('updateTag ' )
208215 ->with (1 , 'Renamed ' , true , true )
209216 ->willThrowException (new TagNotFoundException ());
210- $ this ->getTagNode (false , $ tag )->update ('Renamed ' , true , true , null );
217+ $ this ->getTagNode (true , $ tag )->update ('Renamed ' , true , true , null );
211218 }
212219
213220 #[\PHPUnit \Framework \Attributes \DataProvider('adminFlagProvider ' )]
0 commit comments