@@ -, +, @@ --- t/db_dependent/VirtualShelves.t | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) --- a/t/db_dependent/VirtualShelves.t +++ a/t/db_dependent/VirtualShelves.t @@ -5,7 +5,7 @@ # Larger modifications by Jonathan Druart and Marcel de Rooy use Modern::Perl; -use Test::More tests => 71; +use Test::More tests => 83; use MARC::Record; use C4::Biblio qw( AddBiblio DelBiblio ); @@ -177,6 +177,43 @@ for my $i(0..9){ } } +#----------------------- TEST AddShare ----------------------------------------# + +#first count the number of shares in the table; keep in mind that AddShare may +#delete some expired records while housekeeping +my $sql_sharecount="select count(*) from virtualshelfshares where DATEDIFF(sharedate, NOW())>0"; +my $cnt1=$dbh->selectrow_array($sql_sharecount); + +#try to add a share without shelfnumber: should fail +AddShare(0, 'abcdefghij'); +my $cnt2=$dbh->selectrow_array($sql_sharecount); +ok($cnt1 == $cnt2, "Did not add an invalid share record"); + +#add another share: should be okay +#AddShare assumes that you tested if category==private (so we could actually +#be doing something illegal here :) +my $n=$shelves[0]->{number}; +if($n<0) { + ok(1, 'Skip AddShare for shelf -1'); +} +else { + AddShare($n, 'abcdefghij'); + my $cnt3=$dbh->selectrow_array($sql_sharecount); + ok(1+$cnt2 == $cnt3, "Added one new share record with invitekey"); +} + +#----------------TEST DelShelf & DelFromShelf functions------------------------# + +for(my $i=0; $i<10;$i++){ + my $shelfnumber = $shelves[$i]->{number}; + if($shelfnumber<0) { + ok(1, 'Skip DelShelf for shelf -1'); + next; + } + my $status = DelShelf($shelfnumber); + ok(1 == $status, "deleted shelf $shelfnumber and its contents"); +} + #----------------------- SOME SUBS --------------------------------------------# sub randomname { --