[Koha-bugs] [Bug 17944] Remove the sql code from itemtypes.pl administrative perl script

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Mon May 8 16:46:23 CEST 2017


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17944

--- Comment #49 from Jonathan Druart <jonathan.druart at bugs.koha-community.org> ---
Comment on attachment 63220
  --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=63220
Bug 17944 - Removed SQl query from itemtypes.pl and replaced it with
can_be_deleted method in Koha/ItemType.pm

Review of attachment 63220:
 --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=17944&attachment=63220)
-----------------------------------------------------------------

::: admin/itemtypes.pl
@@ +139,5 @@
>      $op          = 'list';
> +
> + } elsif ( $op eq 'delete_confirm' ) {
> +    my $ItemType = Koha::ItemType->new();
> +    my $overalltotal = $ItemType->can_be_deleted();

You are not retrieving any item type here, ->can_be_deleted will only return 0.
You need to call Koha::ItemType->find($id); to retrieve the item type object
you want from the DB.

@@ +154,2 @@
>      my $itemtype = Koha::ItemTypes->find($itemtype_code);
> +    my $deleted = eval{ $itemtype->delete };;

Unnecessary change.

::: t/db_dependent/Koha/ItemTypes.t
@@ +139,5 @@
> +is( $item_type->can_be_deleted, 0, 'An item type that is used by an item cannot be deleted' );
> +
> +my $biblio = $builder->build_object({ class => 'Koha::Biblioitems', value => { itemtype => $item_type->itemtype }});
> +
> +is ( $item_type->can_be_deleted, 0, 'An item that is used by an item and a biblioitem cannot be deleted' );

This second try does not test what you want, see my previous comment:
"""
The last test says 'An item type that is used by a biblioitem cannot be
deleted'. But actually you are testing that "an item that is used by AN item
AND A biblioitem cannot be deleted'.
You should delete the item to make it test what you want to test.
"""

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list