Koha/t/db_dependent/Items/DelItem.t
Jonathan Druart e28eaae983 Bug 12787: Reorganise t/db_dependent files
This patch tries to reorganise test files in the db_dependent directory:
- Circulation_Branch.t       has been moved to Circulation/Branch.t
- Circulation_issuingrules.t has been moved to Circulation/CalcDateDue.t
- Circulation_Issuingrule.t  has been moved to Circulation/GetHardDueDate.t
- Circulation_dateexpiry.t   has been moved to Circulation/dateexpiry.t
- Circulation_issue.t        has been moved to Circulation/issue.t
- Circulation_transfers.t    has been moved to Circulation/transfers.t
- Items_DelItem.t            has been moved to Items/DelItem.t
- BiblioObject.t             has been moved to Koha/Biblio.t
- Members_Attributes.t       has been moved to Members/Attributes.t
- Members_columns.t          has been moved to Members/columns.t
- Circulation_OfflineOperation.t   has been moved to Circulation/OfflineOperation.t
- Koha_template_plugin_KohaDates.t has been moved to Template/Plugin/KohaDates.t
- Koha_template_plugin_Branches.t  has been moved to Template/Plugin/Branches.t
- Reports/Guided.t, ReportsGuided.t and Reports_Guided.t have been
  merged

Test plan:
Confirm that all the modified tests still pass

Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Brendan Gallagher <bredan@bywatersolutions.com>
2016-04-22 00:54:35 +00:00

55 lines
2 KiB
Perl

use Modern::Perl;
use MARC::Record;
use C4::Biblio;
use t::lib::TestBuilder;
use Test::More tests => 7;
BEGIN {
use_ok('C4::Items');
}
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $library = $builder->build({
source => 'Branch',
});
my ( $biblionumber, $bibitemnum ) = get_biblio();
my ( $item_bibnum, $item_bibitemnum, $itemnumber );
( $item_bibnum, $item_bibitemnum, $itemnumber ) =
AddItem( { homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }, $biblionumber );
my $deleted = DelItem( { biblionumber => $biblionumber, itemnumber => $itemnumber } );
is( $deleted, 1, "DelItem should return 1 if the item has been deleted" );
my $deleted_item = GetItem($itemnumber);
is( $deleted_item->{itemnumber}, undef, "DelItem with biblionumber parameter - the item should be deleted." );
( $item_bibnum, $item_bibitemnum, $itemnumber ) =
AddItem( { homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }, $biblionumber );
$deleted = DelItem( { biblionumber => $biblionumber, itemnumber => $itemnumber } );
is( $deleted, 1, "DelItem should return 1 if the item has been deleted" );
$deleted_item = GetItem($itemnumber);
is( $deleted_item->{itemnumber}, undef, "DelItem without biblionumber parameter - the item should be deleted." );
$deleted = DelItem( { itemnumber => $itemnumber + 1} );
is ( $deleted, 0, "DelItem should return 0 if no item has been deleted" );
$deleted = DelItem( { itemnumber => $itemnumber + 1, biblionumber => $biblionumber } );
is ( $deleted, 0, "DelItem should return 0 if no item has been deleted" );
# Helper method to set up a Biblio.
sub get_biblio {
my $bib = MARC::Record->new();
$bib->append_fields(
MARC::Field->new( '100', ' ', ' ', a => 'Moffat, Steven' ),
MARC::Field->new( '245', ' ', ' ', a => 'Silence in the library' ),
);
my ( $bibnum, $bibitemnum ) = AddBiblio( $bib, '' );
return ( $bibnum, $bibitemnum );
}