1818use OCP \IUserSession ;
1919use OCP \SystemTag \ISystemTag ;
2020use OCP \SystemTag \ISystemTagManager ;
21+ use OCP \SystemTag \TagAlreadyExistsException ;
2122use Test \TestCase ;
2223
2324/**
@@ -79,17 +80,6 @@ public static function getAllTagsDataProvider() {
7980 ['two ' , false , false ],
8081 ]
8182 ],
82- [
83- // duplicate names, different flags
84- [
85- ['one ' , false , false ],
86- ['one ' , true , false ],
87- ['one ' , false , true ],
88- ['one ' , true , true ],
89- ['two ' , false , false ],
90- ['two ' , false , true ],
91- ]
92- ]
9383 ];
9484 }
9585
@@ -162,14 +152,14 @@ public static function getAllTagsFilteredDataProvider() {
162152 [
163153 [
164154 ['one ' , true , false ],
165- ['one ' , false , false ],
155+ ['one_different ' , false , false ],
166156 ['two ' , true , false ],
167157 ],
168158 null ,
169159 'on ' ,
170160 [
171161 ['one ' , true , false ],
172- ['one ' , false , false ],
162+ ['one_different ' , false , false ],
173163 ]
174164 ],
175165 // filter by name pattern and visibility
@@ -178,7 +168,7 @@ public static function getAllTagsFilteredDataProvider() {
178168 [
179169 ['one ' , true , false ],
180170 ['two ' , true , false ],
181- ['one ' , false , false ],
171+ ['one_different ' , false , false ],
182172 ],
183173 true ,
184174 'on ' ,
@@ -239,7 +229,7 @@ public static function oneTagMultipleFlagsProvider() {
239229 * @dataProvider oneTagMultipleFlagsProvider
240230 */
241231 public function testCreateDuplicate ($ name , $ userVisible , $ userAssignable ): void {
242- $ this ->expectException (\ OCP \ SystemTag \ TagAlreadyExistsException::class);
232+ $ this ->expectException (TagAlreadyExistsException::class);
243233
244234 try {
245235 $ this ->tagManager ->createTag ($ name , $ userVisible , $ userAssignable );
@@ -249,6 +239,15 @@ public function testCreateDuplicate($name, $userVisible, $userAssignable): void
249239 $ this ->tagManager ->createTag ($ name , $ userVisible , $ userAssignable );
250240 }
251241
242+ public function testCreateDuplicateWithDifferentFlags (): void {
243+ $ this ->expectException (TagAlreadyExistsException::class);
244+
245+ // Create a tag with specific flags
246+ $ this ->tagManager ->createTag ('duplicate ' , true , false );
247+ // Try to create a tag with the same name but different flags - should fail
248+ $ this ->tagManager ->createTag ('duplicate ' , false , true );
249+ }
250+
252251 public function testCreateOverlongName (): void {
253252 $ tag = $ this ->tagManager ->createTag ('Zona circundante do Palácio Nacional da Ajuda (Jardim das Damas, Salão de Física, Torre Sineira, Paço Velho e Jardim Botânico) ' , true , true );
254253 $ this ->assertSame ('Zona circundante do Palácio Nacional da Ajuda (Jardim das Damas ' , $ tag ->getName ()); // 63 characters but 64 bytes due to "á"
@@ -356,32 +355,20 @@ public function testUpdateTag($tagCreate, $tagUpdated): void {
356355
357356 }
358357
359- /**
360- * @dataProvider updateTagProvider
361- */
362- public function testUpdateTagDuplicate ($ tagCreate , $ tagUpdated ): void {
363- $ this ->expectException (\OCP \SystemTag \TagAlreadyExistsException::class);
358+ public function testUpdateTagToExistingName (): void {
359+ $ this ->expectException (TagAlreadyExistsException::class);
364360
365- $ this ->tagManager ->createTag (
366- $ tagCreate [0 ],
367- $ tagCreate [1 ],
368- $ tagCreate [2 ],
369- $ tagCreate [3 ],
370- );
371- $ tag2 = $ this ->tagManager ->createTag (
372- $ tagUpdated [0 ],
373- $ tagUpdated [1 ],
374- $ tagUpdated [2 ],
375- $ tagUpdated [3 ],
376- );
361+ // Create two different tags
362+ $ tag1 = $ this ->tagManager ->createTag ('first ' , true , true );
363+ $ tag2 = $ this ->tagManager ->createTag ('second ' , false , false );
377364
378- // update to match the first tag
365+ // Try to update tag2 to have the same name as tag1 - should fail
379366 $ this ->tagManager ->updateTag (
380367 $ tag2 ->getId (),
381- $ tagCreate [ 0 ] ,
382- $ tagCreate [ 1 ] ,
383- $ tagCreate [ 2 ] ,
384- $ tagCreate [ 3 ],
368+ ' first ' ,
369+ false ,
370+ false ,
371+ null
385372 );
386373 }
387374
0 commit comments