@@ -75,38 +75,45 @@ public function tagNodeProvider() {
7575 [
7676 true ,
7777 new SystemTag (1 , 'Original ' , true , true ),
78- ['Renamed ' , true , true ]
78+ ['Renamed ' , true , true ],
79+ true ,
7980 ],
8081 [
8182 true ,
8283 new SystemTag (1 , 'Original ' , true , true ),
83- ['Original ' , false , false ]
84+ ['Original ' , false , false ],
85+ true ,
8486 ],
8587 // non-admin
8688 [
87- // renaming allowed
89+ // renaming not allowed
8890 false ,
8991 new SystemTag (1 , 'Original ' , true , true ),
90- ['Rename ' , true , true ]
92+ ['Renamed ' , true , true ],
93+ false ,
9194 ],
9295 ];
9396 }
9497
9598 /**
9699 * @dataProvider tagNodeProvider
97100 */
98- public function testUpdateTag ($ isAdmin , ISystemTag $ originalTag , $ changedArgs ): void {
99- $ this ->tagManager ->expects ($ this ->once ())
100- ->method ('canUserSeeTag ' )
101+ public function testUpdateTag ($ isAdmin , ISystemTag $ originalTag , $ changedArgs , $ allowed ): void {
102+ $ this ->tagManager ->method ('canUserSeeTag ' )
101103 ->with ($ originalTag )
102104 ->willReturn ($ originalTag ->isUserVisible () || $ isAdmin );
103- $ this ->tagManager ->expects ($ this ->once ())
104- ->method ('canUserAssignTag ' )
105+ $ this ->tagManager ->method ('canUserAssignTag ' )
105106 ->with ($ originalTag )
106107 ->willReturn ($ originalTag ->isUserAssignable () || $ isAdmin );
107- $ this ->tagManager ->expects ($ this ->once ())
108- ->method ('updateTag ' )
109- ->with (1 , $ changedArgs [0 ], $ changedArgs [1 ], $ changedArgs [2 ]);
108+ if ($ allowed ) {
109+ $ this ->tagManager ->expects ($ this ->once ())
110+ ->method ('updateTag ' )
111+ ->with (1 , $ changedArgs [0 ], $ changedArgs [1 ], $ changedArgs [2 ]);
112+ } else {
113+ $ this ->expectException (\Sabre \DAV \Exception \Forbidden::class);
114+ $ this ->tagManager ->expects ($ this ->never ())
115+ ->method ('updateTag ' );
116+ }
110117 $ this ->getTagNode ($ isAdmin , $ originalTag )
111118 ->update ($ changedArgs [0 ], $ changedArgs [1 ], $ changedArgs [2 ]);
112119 }
@@ -196,7 +203,7 @@ public function testUpdateTagAlreadyExists(): void {
196203 ->method ('updateTag ' )
197204 ->with (1 , 'Renamed ' , true , true )
198205 ->will ($ this ->throwException (new TagAlreadyExistsException ()));
199- $ this ->getTagNode (false , $ tag )->update ('Renamed ' , true , true );
206+ $ this ->getTagNode (true , $ tag )->update ('Renamed ' , true , true );
200207 }
201208
202209
@@ -216,7 +223,7 @@ public function testUpdateTagNotFound(): void {
216223 ->method ('updateTag ' )
217224 ->with (1 , 'Renamed ' , true , true )
218225 ->will ($ this ->throwException (new TagNotFoundException ()));
219- $ this ->getTagNode (false , $ tag )->update ('Renamed ' , true , true );
226+ $ this ->getTagNode (true , $ tag )->update ('Renamed ' , true , true );
220227 }
221228
222229 /**
0 commit comments