6 use t::lib::TestBuilder;
8 use Test::More tests => 7;
14 my $schema = Koha::Database->schema;
15 $schema->storage->txn_begin;
16 my $builder = t::lib::TestBuilder->new;
18 my $library = $builder->build({
22 my ( $biblionumber, $bibitemnum ) = get_biblio();
24 my ( $item_bibnum, $item_bibitemnum, $itemnumber );
25 ( $item_bibnum, $item_bibitemnum, $itemnumber ) =
26 AddItem( { homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }, $biblionumber );
28 my $deleted = DelItem( { biblionumber => $biblionumber, itemnumber => $itemnumber } );
29 is( $deleted, 1, "DelItem should return 1 if the item has been deleted" );
30 my $deleted_item = GetItem($itemnumber);
31 is( $deleted_item->{itemnumber}, undef, "DelItem with biblionumber parameter - the item should be deleted." );
33 ( $item_bibnum, $item_bibitemnum, $itemnumber ) =
34 AddItem( { homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }, $biblionumber );
35 $deleted = DelItem( { biblionumber => $biblionumber, itemnumber => $itemnumber } );
36 is( $deleted, 1, "DelItem should return 1 if the item has been deleted" );
37 $deleted_item = GetItem($itemnumber);
38 is( $deleted_item->{itemnumber}, undef, "DelItem without biblionumber parameter - the item should be deleted." );
40 $deleted = DelItem( { itemnumber => $itemnumber + 1} );
41 is ( $deleted, 0, "DelItem should return 0 if no item has been deleted" );
43 $deleted = DelItem( { itemnumber => $itemnumber + 1, biblionumber => $biblionumber } );
44 is ( $deleted, 0, "DelItem should return 0 if no item has been deleted" );
46 # Helper method to set up a Biblio.
48 my $bib = MARC::Record->new();
50 MARC::Field->new( '100', ' ', ' ', a => 'Moffat, Steven' ),
51 MARC::Field->new( '245', ' ', ' ', a => 'Silence in the library' ),
53 my ( $bibnum, $bibitemnum ) = AddBiblio( $bib, '' );
54 return ( $bibnum, $bibitemnum );