From d32f1296795a4f2bae9c1ff5504c2b7133fa3c87 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 14 May 2019 13:21:55 +0100 Subject: [PATCH] Bug 22899: (QA follow-up) Change accessor name This patch changes pending_hold to has_pending_hold to signify that we're returning a boolean and not a Koha::Hold object. Signed-off-by: Martin Renvoize Signed-off-by: Nick Clemens (cherry picked from commit 5c81d986212b480d9b491e46b3fb4498c0eb2c2c) Signed-off-by: Martin Renvoize --- C4/Items.pm | 2 +- C4/XSLT.pm | 4 ++-- Koha/Item.pm | 6 +++--- koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc | 2 +- t/db_dependent/Items.t | 4 ++-- t/db_dependent/Koha/Item.t | 8 ++++---- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/C4/Items.pm b/C4/Items.pm index a0c1fee33e..0d213a1032 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -1008,7 +1008,7 @@ sub GetItemsInfo { holding.opac_info as holding_branch_opac_info, home.opac_info as home_branch_opac_info "; - $query .= ",IF(tmp_holdsqueue.itemnumber,1,0) AS pending_hold" if !C4::Context->preference('AllowItemsOnHoldCheckout'); + $query .= ",IF(tmp_holdsqueue.itemnumber,1,0) AS has_pending_hold" if !C4::Context->preference('AllowItemsOnHoldCheckout'); $query .= " FROM items LEFT JOIN branches AS holding ON items.holdingbranch = holding.branchcode diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 2d499cbc9c..6b30b49ecc 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -293,7 +293,7 @@ sub buildKohaItemsNamespace { my $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} ); if ( ( $item->{itype} && $itemtypes->{ $item->{itype} }->{notforloan} ) || $item->{notforloan} || $item->{onloan} || $item->{withdrawn} || $item->{itemlost} || $item->{damaged} || - (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") || $item->{pending_hold} ){ + (defined $transfertwhen && $transfertwhen ne '') || $item->{itemnotforloan} || (defined $reservestatus && $reservestatus eq "Waiting") || $item->{has_pending_hold} ){ if ( $item->{notforloan} < 0) { $status = "On order"; } @@ -318,7 +318,7 @@ sub buildKohaItemsNamespace { if (defined $reservestatus && $reservestatus eq "Waiting") { $status = 'Waiting'; } - if ($item->{pending_hold}) { + if ($item->{has_pending_hold}) { $status = 'Pending hold'; } } else { diff --git a/Koha/Item.pm b/Koha/Item.pm index bda145ad18..a5ca3ec6ae 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -315,15 +315,15 @@ sub add_to_rota { return $self; } -=head3 pending_hold +=head3 has_pending_hold - my $is_pending_hold = $item->pending_hold(); + my $is_pending_hold = $item->has_pending_hold(); This method checks the tmp_holdsqueue to see if this item has been selected for a hold, but not filled yet and returns true or false =cut -sub pending_hold { +sub has_pending_hold { my ( $self ) = @_; my $pending_hold = $self->_result->tmp_holdsqueues; return !C4::Context->preference('AllowItemsOnHoldCheckout') && $pending_hold->count ? 1: 0; diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc index 6b8dadcf4b..c15566a7be 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/item-status.inc @@ -89,7 +89,7 @@ On order [% END %] -[% IF item.pending_hold %] +[% IF item.has_pending_hold %] [% SET itemavailable = 0 %] Pending hold [% END %] diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index 9f67c99521..ec54b9d753 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -318,11 +318,11 @@ subtest 'GetItemsInfo tests' => sub { my $dbh = C4::Context->dbh; $dbh->do(q{INSERT INTO tmp_holdsqueue (biblionumber, itemnumber, surname, borrowernumber ) VALUES (?, ?, "Zorro", 42)}, undef, $item_bibnum, $itemnumber); @results = GetItemsInfo( $biblio->biblionumber ); - is( $results[0]->{ pending_hold }, "1", + is( $results[0]->{ has_pending_hold }, "1", 'Hold marked as pending/unavailable if not AllowItemsOnHoldCheckout' ); t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 ); @results = GetItemsInfo( $biblio->biblionumber ); - is( $results[0]->{ pending_hold }, undef, + is( $results[0]->{ has_pending_hold }, undef, 'Hold not marked as pending/unavailable if AllowItemsOnHoldCheckout' ); diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 0a6a029836..3641b9a0d2 100644 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -30,7 +30,7 @@ use t::lib::Mocks; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; -subtest 'pending_hold() tests' => sub { +subtest 'has_pending_hold() tests' => sub { plan tests => 3; @@ -43,10 +43,10 @@ subtest 'pending_hold() tests' => sub { # disable AllowItemsOnHoldCheckout as it ignores pending holds t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 ); $dbh->do("INSERT INTO tmp_holdsqueue (surname,borrowernumber,itemnumber) VALUES ('Clamp',42,$itemnumber)"); - ok( $item->pending_hold, "Yes, we have a pending hold"); + ok( $item->has_pending_hold, "Yes, we have a pending hold"); t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 1 ); - ok( !$item->pending_hold, "We don't consider a pending hold if hold items can be checked out"); + ok( !$item->has_pending_hold, "We don't consider a pending hold if hold items can be checked out"); t::lib::Mocks::mock_preference( 'AllowItemsOnHoldCheckout', 0 ); $dbh->do("DELETE FROM tmp_holdsqueue WHERE itemnumber=$itemnumber"); - ok( !$item->pending_hold, "We don't have a pending hold if nothing in the tmp_holdsqueue"); + ok( !$item->has_pending_hold, "We don't have a pending hold if nothing in the tmp_holdsqueue"); }; -- 2.39.5