Bugzilla – Attachment 63925 Details for
Bug 17944
Remove the sql code from itemtypes.pl administrative perl script
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17944: QA follow-up
Bug-17944-QA-follow-up.patch (text/plain), 4.02 KB, created by
Marcel de Rooy
on 2017-06-02 08:58:58 UTC
(
hide
)
Description:
Bug 17944: QA follow-up
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-06-02 08:58:58 UTC
Size:
4.02 KB
patch
obsolete
>From c3a3d3dc6c0580706a1385b8fcba5fb9f2a27538 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 9 May 2017 15:56:32 -0300 >Subject: [PATCH] Bug 17944: QA follow-up >Content-Type: text/plain; charset=utf-8 > >- Remove an unused use statement >- Fix pod >- Use snake_case >- Fix test "An itemtype cannot be deleted if and only if there is >biblioitem linked with it" > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/ItemType.pm | 9 +++++---- > admin/itemtypes.pl | 8 ++++---- > t/db_dependent/Koha/ItemTypes.t | 12 ++++-------- > 3 files changed, 13 insertions(+), 16 deletions(-) > >diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm >index 0b84e80..24be0d2 100644 >--- a/Koha/ItemType.pm >+++ b/Koha/ItemType.pm >@@ -23,7 +23,6 @@ use C4::Koha; > use C4::Languages; > use Koha::Database; > use Koha::Localizations; >-use Koha::Exceptions; > > use base qw(Koha::Object); > >@@ -91,8 +90,10 @@ sub translated_descriptions { > } > > >+ > =head3 can_be_deleted >-my $overalltotal = Koha::ItemType->can_be_deleted(); >+ >+my $can_be_deleted = Koha::ItemType->can_be_deleted(); > > Counts up the number of biblioitems and items with itemtype (code) and hands back the combined number of biblioitems and items with the itemtype > >@@ -100,8 +101,8 @@ Counts up the number of biblioitems and items with itemtype (code) and hands bac > > sub can_be_deleted { > my ($self) = @_; >- my $nb_items = Koha::Items->search( { 'itype' => $self->itemtype} )->count; >- my $nb_biblioitems = Koha::Biblioitems->search( { 'itemtype' => $self->itemtype} )->count; >+ my $nb_items = Koha::Items->search( { itype => $self->itemtype } )->count; >+ my $nb_biblioitems = Koha::Biblioitems->search( { itemtype => $self->itemtype } )->count; > return $nb_items + $nb_biblioitems == 0 ? 1 : 0; > } > >diff --git a/admin/itemtypes.pl b/admin/itemtypes.pl >index 756910d..09e564e 100755 >--- a/admin/itemtypes.pl >+++ b/admin/itemtypes.pl >@@ -139,13 +139,13 @@ if ( $op eq 'add_form' ) { > $op = 'list'; > > } elsif ( $op eq 'delete_confirm' ) { >- my $ItemType = Koha::ItemTypes->find($itemtype_code); >- my $overalltotal = $ItemType->can_be_deleted(); >- if ($overalltotal == 0) { >+ my $itemtype = Koha::ItemTypes->find($itemtype_code); >+ my $can_be_deleted = $itemtype->can_be_deleted(); >+ if ($can_be_deleted == 0) { > push @messages, { type => 'error', code => 'cannot_be_deleted'}; > $op = 'list'; > } else { >- $template->param( itemtype => $ItemType, ); >+ $template->param( itemtype => $itemtype, ); > } > > } elsif ( $op eq 'delete_confirmed' ) { >diff --git a/t/db_dependent/Koha/ItemTypes.t b/t/db_dependent/Koha/ItemTypes.t >index 082d733..ac239b3 100755 >--- a/t/db_dependent/Koha/ItemTypes.t >+++ b/t/db_dependent/Koha/ItemTypes.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 26; >+use Test::More tests => 24; > use Data::Dumper; > use Koha::Database; > use t::lib::Mocks; >@@ -135,16 +135,12 @@ my $item_type = $builder->build_object({ class => 'Koha::ItemTypes' }); > is( $item_type->can_be_deleted, 1, 'An item type that is not used can be deleted'); > > my $item = $builder->build_object({ class => 'Koha::Items', value => { itype => $item_type->itemtype }}); >- > is( $item_type->can_be_deleted, 0, 'An item type that is used by an item cannot be deleted' ); >+$item->delete; > >-my $biblio = $builder->build_object({ class => 'Koha::Biblioitems', value => { itemtype => $item_type->itemtype }}); >- >+my $biblioitem = $builder->build_object({ class => 'Koha::Biblioitems', value => { itemtype => $item_type->itemtype }}); > is ( $item_type->can_be_deleted, 0, 'An item type that is used by an item and a biblioitem cannot be deleted' ); >- >-is ( $item->delete, 1, 'An item has been deleted' ); >- >-is ( $biblio->delete, 1, 'A biblioitem has been deleted' ); >+$biblioitem->delete; > > is ( $item_type->can_be_deleted, 1, 'The item type that was being used by the removed item and biblioitem can now be deleted' ); > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17944
:
59391
|
59564
|
59565
|
59655
|
59656
|
59657
|
59715
|
59716
|
59717
|
59718
|
59953
|
59954
|
62499
|
62500
|
62501
|
62502
|
62503
|
62504
|
62505
|
63045
|
63152
|
63220
|
63259
|
63307
|
63308
|
63309
|
63310
|
63924
| 63925