&AddToShelf
&ModShelf
&ShelfPossibleAction
- &DelFromShelf &DelShelf
+ &DelFromShelf
&GetBibliosShelves
&AddShare &AcceptShare &RemoveShare &IsSharedList
);
return $t;
}
-=head2 DelShelf
-
- $Number = DelShelf($shelfnumber);
-
-This function deletes the shelf number, and all of it's content.
-Authorization to do so MUST have been checked before calling, while using
-ShelfPossibleAction with manage parameter.
-
-=cut
-
-sub DelShelf {
- my ($shelfnumber)= @_;
- return unless $shelfnumber && $shelfnumber =~ /^\d+$/;
- my $dbh = C4::Context->dbh;
- my $sth = $dbh->prepare("DELETE FROM virtualshelves WHERE shelfnumber=?");
- return $sth->execute($shelfnumber);
-}
-
=head2 GetBibliosShelves
This finds all the public lists that this bib record is in.
#Instead of deleting we could also disown lists (based on a pref).
#In that way we could save shared and public lists.
#The current table constraints support that idea now.
- #This pref should then govern the results of other routines such as
- #DelShelf too.
+ #This pref should then govern the results of other routines/methods such as
+ #Koha::Virtualshelf->new->delete too.
}
=head2 AddShare
$name = $shelflist->{$number}->{'shelfname'};
delete $shelflist->{$number};
}
- unless ( DelShelf($number) ) {
+ unless( Koha::Virtualshelves->find($number)->delete ) {
push( @paramsloop, { delete_fail => $name } );
last;
}
is(IsSharedList($sh),$n? 1: '', "Checked IsSharedList for shelf $sh");
}
-#----------------TEST DelShelf & DelFromShelf functions------------------------#
+#----------------TEST Koha::Virtualshelf->delete & DelFromShelf functions------------------------#
for my $i (0..9){
my $shelfnumber = $shelves[$i]->{number};
if($shelfnumber<0) {
- ok(1, 'Skip DelShelf for shelf -1');
+ ok(1, 'Skip Koha::Virtualshelf->delete for shelf -1');
next;
}
- my $status = DelShelf($shelfnumber);
+ my $status = Koha::Virtualshelves->find($shelfnumber)->delete;
is($status, 1, "deleted shelf $shelfnumber and its contents");
}
my $builder = t::lib::TestBuilder->new;
subtest 'CRUD' => sub {
- plan tests => 11;
+ plan tests => 13;
my $patron = $builder->build({
source => 'Borrower',
});
)->store;
$number_of_shelves = Koha::Virtualshelves->search->count;
is( $number_of_shelves, 2, 'Another patron should be able to create a shelf with an existing shelfname');
+
+ my $is_deleted = Koha::Virtualshelves->find( $shelf->shelfnumber )->delete;
+ is( $is_deleted, 1, 'The shelf has been deleted correctly' );
+ $number_of_shelves = Koha::Virtualshelves->search->count;
+ is( $number_of_shelves, 1, 'To be sure the shelf has been deleted' );
};