- my $numA = $shelves[$rand];
- my $shelf = { shelfname => "NewName_".$rand,
- category => int(rand(2))+1 };
-
- ModShelf($numA,$shelf);
- my ($numB,$nameB,$ownerB,$categoryB) = GetShelf($numA);
-
- ok($numA == $numB, 'modified shelf');
- ok($shelf->{shelfname} eq $nameB, '... and name change took');
- ok($shelf->{category} eq $categoryB, '... and category change took');
+ my $numA = $shelves[$rand]->{number};
+ if($numA<0) {
+ ok(1, 'Skip ModShelf test for shelf -1');
+ ok(1, 'Skip ModShelf test for shelf -1');
+ ok(1, 'Skip ModShelf test for shelf -1');
+ next;
+ }
+ my $newname= randomname();
+ my $shelf = {
+ shelfname => $newname,
+ category => 3-$shelves[$rand]->{catg}, # tric: 1->2 and 2->1
+ };
+ #check name change (with category change)
+ if(C4::VirtualShelves::_CheckShelfName($newname,$shelf->{category},
+ $shelves[$rand]->{owner}, $numA)) {
+ ModShelf($numA,$shelf);
+ my ($numB,$nameB,$ownerB,$categoryB) = GetShelf($numA);
+ ok($numA == $numB, 'modified shelf');
+ ok($shelf->{shelfname} eq $nameB, '... and name change took');
+ ok($shelf->{category} eq $categoryB, '... and category change took');
+ }
+ else {
+ ok(1, "No ModShelf for $newname") for 1..3;
+ }