Bugzilla – Attachment 48022 Details for
Bug 15783
C4::Koha::AddAuthorisedValue can be replaced with Koha::AuthorisedValue->new->store
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15783: AddAuthorisedValue - Remove the subroutine
Bug-15783-AddAuthorisedValue---Remove-the-subrouti.patch (text/plain), 5.60 KB, created by
Kyle M Hall (khall)
on 2016-02-12 19:29:45 UTC
(
hide
)
Description:
Bug 15783: AddAuthorisedValue - Remove the subroutine
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-02-12 19:29:45 UTC
Size:
5.60 KB
patch
obsolete
>From f82be35c70ce77b36a2dae547f25558338a852ee Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 10 Feb 2016 10:32:52 +0000 >Subject: [PATCH] Bug 15783: AddAuthorisedValue - Remove the subroutine >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plan: > prove t/db_dependent/Koha.t >should return green > > git grep AddAuthorisedValue >should not return any results > >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > C4/Koha.pm | 21 ------------------- > t/db_dependent/Koha.t | 58 +++++++++++++++++++++++++++++++++++++++++++-------- > 2 files changed, 49 insertions(+), 30 deletions(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 7171f16..3ca1b68 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -67,7 +67,6 @@ BEGIN { > &GetAuthorisedValueByCode > &GetKohaImageurlFromAuthorisedValues > &GetAuthValCode >- &AddAuthorisedValue > &GetNormalizedUPC > &GetNormalizedISBN > &GetNormalizedEAN >@@ -1432,26 +1431,6 @@ sub GetKohaAuthorisedValueLib { > return $value; > } > >-=head2 AddAuthorisedValue >- >- AddAuthorisedValue($category, $authorised_value, $lib, $lib_opac, $imageurl); >- >-Create a new authorised value. >- >-=cut >- >-sub AddAuthorisedValue { >- my ($category, $authorised_value, $lib, $lib_opac, $imageurl) = @_; >- >- my $dbh = C4::Context->dbh; >- my $query = qq{ >- INSERT INTO authorised_values (category, authorised_value, lib, lib_opac, imageurl) >- VALUES (?,?,?,?,?) >- }; >- my $sth = $dbh->prepare($query); >- $sth->execute($category, $authorised_value, $lib, $lib_opac, $imageurl); >-} >- > =head2 display_marc_indicators > > my $display_form = C4::Koha::display_marc_indicators($field); >diff --git a/t/db_dependent/Koha.t b/t/db_dependent/Koha.t >index c013434..301db69 100644 >--- a/t/db_dependent/Koha.t >+++ b/t/db_dependent/Koha.t >@@ -3,10 +3,10 @@ > # This is to test C4/Koha > # It requires a working Koha database with the sample data > >-use strict; >-use warnings; >+use Modern::Perl; > use C4::Context; > use Koha::DateUtils qw(dt_from_string); >+use Koha::AuthorisedValue; > > use Test::More tests => 10; > use DateTime::Format::MySQL; >@@ -33,8 +33,15 @@ subtest 'Authorized Values Tests' => sub { > > > # Insert an entry into authorised_value table >- my $insert_success = AddAuthorisedValue($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl}); >- ok($insert_success, "Insert data in database"); >+ my $insert_success = Koha::AuthorisedValue->new( >+ { category => $data->{category}, >+ authorised_value => $data->{authorised_value}, >+ lib => $data->{lib}, >+ lib_opac => $data->{lib_opac}, >+ imageurl => $data->{imageurl} >+ } >+ )->store; >+ ok( $insert_success, "Insert data in database" ); > > > # Tests >@@ -64,11 +71,34 @@ subtest 'Authorized Values Tests' => sub { > SKIP: { > eval { require Test::Deep; import Test::Deep; }; > skip "Test::Deep required to run the GetAuthorisedValues() tests.", 2 if $@; >- AddAuthorisedValue('BUG10656', 'ZZZ', 'Z_STAFF', 'A_PUBLIC', ''); >- AddAuthorisedValue('BUG10656', 'AAA', 'A_STAFF', 'Z_PUBLIC', ''); >+ Koha::AuthorisedValue->new( >+ { category => 'BUG10656', >+ authorised_value => 'ZZZ', >+ lib => 'Z_STAFF', >+ lib_opac => 'A_PUBLIC', >+ imageurl => '' >+ } >+ )->store; >+ Koha::AuthorisedValue->new( >+ { category => 'BUG10656', >+ authorised_value => 'AAA', >+ lib => 'A_STAFF', >+ lib_opac => 'Z_PUBLIC', >+ imageurl => '' >+ } >+ )->store; >+ > # the next one sets lib_opac to NULL; in that case, the staff > # display value is meant to be used. >- AddAuthorisedValue('BUG10656', 'DDD', 'D_STAFF', undef, ''); >+ Koha::AuthorisedValue->new( >+ { category => 'BUG10656', >+ authorised_value => 'DDD', >+ lib => 'D_STAFF', >+ lib_opac => undef, >+ imageurl => '' >+ } >+ )->store; >+ > my $authvals = GetAuthorisedValues('BUG10656'); > cmp_deeply( > $authvals, >@@ -301,7 +331,12 @@ subtest 'GetFrameworksLoop() tests' => sub { > subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ > plan tests => 7; > >- my $insertGroup = AddAuthorisedValue('ITEMTYPECAT', 'Qwertyware'); >+ my $insertGroup = Koha::AuthorisedValue->new( >+ { category => 'ITEMTYPECAT', >+ authorised_value => 'Quertyware', >+ } >+ )->store; >+ > ok($insertGroup, "Create group Qwertyware"); > > my $query = "INSERT into itemtypes (itemtype, description, searchcategory, hideinopac) values (?,?,?,?)"; >@@ -319,7 +354,12 @@ subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{ > is_deeply(\@results,\@expected,'GetItemTypesByCategory: valid category returns itemtypes'); > > # add more data since GetItemTypesCategorized's search is more subtle >- $insertGroup = AddAuthorisedValue('ITEMTYPECAT', 'Veryheavybook'); >+ $insertGroup = Koha::AuthorisedValue->new( >+ { category => 'ITEMTYPECAT', >+ authorised_value => 'Varyheavybook', >+ } >+ )->store; >+ > $insertSth->execute('BKghjklo4', 'Another hidden book', 'Veryheavybook', 1); > > my $hrCat = GetItemTypesCategorized(); >-- >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 15783
:
47840
|
47841
|
47889
|
47890
|
48021
| 48022