Bugzilla – Attachment 60298 Details for
Bug 17627
Move C4::Koha::GetItemTypesByCategory to Koha::ItemTypes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17627: Move C4::Koha::GetItemTypesByCategory to Koha::ItemTypes
Bug-17627-Move-C4KohaGetItemTypesByCategory-to-Koh.patch (text/plain), 4.49 KB, created by
Nick Clemens (kidclamp)
on 2017-02-16 00:17:21 UTC
(
hide
)
Description:
Bug 17627: Move C4::Koha::GetItemTypesByCategory to Koha::ItemTypes
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-02-16 00:17:21 UTC
Size:
4.49 KB
patch
obsolete
>From 047a78c1b42ecbea3b23515b434343314cbc184c Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 15 Nov 2016 10:17:22 +0000 >Subject: [PATCH] Bug 17627: Move C4::Koha::GetItemTypesByCategory to > Koha::ItemTypes > >C4::Koha::GetItemTypesByCategory can be easily replaced with >Koha::ItemTypes->search({ searchcategory => ? }); > >So let's replace it where it is used. > >Test plan: >Make sure this patch does not break the test plan of bug 10937 > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > C4/Koha.pm | 20 +------------------- > opac/opac-search.pl | 3 ++- > t/db_dependent/Koha.t | 15 ++++++++------- > 3 files changed, 11 insertions(+), 27 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index b6e494a..2884267 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -42,7 +42,7 @@ BEGIN { > @EXPORT = qw( > &GetPrinters &GetPrinter > &GetItemTypes &getitemtypeinfo >- &GetItemTypesCategorized &GetItemTypesByCategory >+ &GetItemTypesCategorized > &getallthemes > &getFacets > &getnbpages >@@ -207,24 +207,6 @@ sub GetItemTypesCategorized { > return ($dbh->selectall_hashref($query,'itemtype')); > } > >-=head2 GetItemTypesByCategory >- >- @results = GetItemTypesByCategory( $searchcategory ); >- >-Returns the itemtype code of all itemtypes included in a searchcategory. >- >-=cut >- >-sub GetItemTypesByCategory { >- my ($category) = @_; >- my $count = 0; >- my @results; >- my $dbh = C4::Context->dbh; >- my $query = qq|SELECT itemtype FROM itemtypes WHERE searchcategory=?|; >- my $tmp=$dbh->selectcol_arrayref($query,undef,$category); >- return @$tmp; >-} >- > =head2 getitemtypeinfo > > $itemtype = &getitemtypeinfo($itemtype, [$interface]); >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 15e24b3..a84e9d3 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -479,7 +479,8 @@ my %is_nolimit = map { $_ => 1 } @nolimits; > if (@searchCategories > 0) { > my @tabcat; > foreach my $typecategory (@searchCategories) { >- push (@tabcat, GetItemTypesByCategory($typecategory)); >+ my @itemtypes = Koha::ItemTypes->search({ searchcategory => $typecategory }); >+ push @tabcat, $_->itemtype for @itemtypes; > } > > foreach my $itemtypeInCategory (@tabcat) { >diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t >index 3d5e203..feb4a1c 100644 >--- a/t/db_dependent/Koha.t >+++ b/t/db_dependent/Koha.t >@@ -13,7 +13,7 @@ use Test::More tests => 8; > use DateTime::Format::MySQL; > > BEGIN { >- use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesByCategory GetItemTypesCategorized)); >+ use_ok('C4::Koha', qw( :DEFAULT GetDailyQuote GetItemTypesCategorized)); > use_ok('C4::Members'); > } > >@@ -239,7 +239,7 @@ subtest 'ISBN tests' => sub { > > }; > >-subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ >+subtest 'GetItemTypesCategorized test' => sub{ > plan tests => 7; > > my $avc = Koha::AuthorisedValueCategories->find('ITEMTYPECAT'); >@@ -259,12 +259,13 @@ subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ > $insertSth->execute('BKghjklo3', 'Yet another type of book', 'Qwertyware', 0); > > # Azertyware should not exist. >- my @results = GetItemTypesByCategory('Azertyware'); >- is(scalar @results, 0, 'GetItemTypesByCategory: Invalid category returns nothing'); >+ my @itemtypes = Koha::ItemTypes->search({ searchcategory => 'Azertyware' }); >+ is( @itemtypes, 0, 'Search item types by searchcategory: Invalid category returns nothing'); > >- @results = GetItemTypesByCategory('Qwertyware'); >+ @itemtypes = Koha::ItemTypes->search({ searchcategory => 'Qwertyware' }); >+ my @got = map { $_->itemtype } @itemtypes; > my @expected = ( 'BKghjklo2', 'BKghjklo3' ); >- is_deeply(\@results,\@expected,'GetItemTypesByCategory: valid category returns itemtypes'); >+ is_deeply(\@got,\@expected,'Search item types by searchcategory: valid category returns itemtypes'); > > # add more data since GetItemTypesCategorized's search is more subtle > $insertGroup = Koha::AuthorisedValue->new( >@@ -285,7 +286,7 @@ subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ > ok(exists $hrCat->{Qwertyware}, 'GetItemTypesCategorized: partially visible category exists'); > > my @only = ( 'BKghjklo1', 'BKghjklo2', 'BKghjklo3', 'BKghjklo4', 'BKghjklo5', 'Qwertyware', 'Veryheavybook' ); >- @results = (); >+ my @results = (); > foreach my $key (@only) { > push @results, $key if exists $hrCat->{$key}; > } >-- >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 17627
:
57479
| 60298