Koha/t/db_dependent/Items/DelItem.t
Jonathan Druart 31c29fd31f Bug 21206: Replace C4::Items::GetItem
Note: This is here for information purpose, feel free to test it if you
wan to play with it.

TODO: C4::Reserves::_get_itype is not longer in use

No more GetItem must be returned by:
git grep GetItem|grep -v GetItemsAvailableToFillHoldRequestsForBib|grep
-v GetItemsForInventory|grep -v GetItemsInfo|grep -v
GetItemsLocationInfo|grep -v GetItemsInCollection|grep -v
GetItemCourseReservesInfo|grep -v GetItemnumbersFromOrder|grep -v
GetItemSearchField|grep -v GetItemTypesCategorized|grep -v
GetItemNumbersFromImportBatch|cut -d':' -f1|sort|uniq

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
2019-02-26 13:24:07 +00:00

43 lines
1.6 KiB
Perl

use Modern::Perl;
use MARC::Record;
use C4::Items;
use C4::Biblio;
use Koha::Items;
use t::lib::TestBuilder;
use Test::More tests => 6;
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $library = $builder->build({
source => 'Branch',
});
my $biblio = $builder->build_sample_biblio();
my ( $item_bibnum, $item_bibitemnum, $itemnumber );
( $item_bibnum, $item_bibitemnum, $itemnumber ) =
AddItem( { homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }, $biblio->biblionumber );
my $deleted = DelItem( { biblionumber => $biblio->biblionumber, itemnumber => $itemnumber } );
is( $deleted, 1, "DelItem should return 1 if the item has been deleted" );
my $deleted_item = Koha::Items->find($itemnumber);
is( $deleted_item, undef, "DelItem with biblionumber parameter - the item should be deleted." );
( $item_bibnum, $item_bibitemnum, $itemnumber ) =
AddItem( { homebranch => $library->{branchcode}, holdingbranch => $library->{branchcode} }, $biblio->biblionumber );
$deleted = DelItem( { biblionumber => $biblio->biblionumber, itemnumber => $itemnumber } );
is( $deleted, 1, "DelItem should return 1 if the item has been deleted" );
$deleted_item = Koha::Items->find($itemnumber);
is( $deleted_item, 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 => $biblio->biblionumber } );
is ( $deleted, 0, "DelItem should return 0 if no item has been deleted" );