Bug 15783: AddAuthorisedValue - Remove the subroutine
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> Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com
This commit is contained in:
parent
adff231a67
commit
2ea901c641
2 changed files with 49 additions and 30 deletions
21
C4/Koha.pm
21
C4/Koha.pm
|
@ -65,7 +65,6 @@ BEGIN {
|
||||||
&GetKohaAuthorisedValueLib
|
&GetKohaAuthorisedValueLib
|
||||||
&GetAuthorisedValueByCode
|
&GetAuthorisedValueByCode
|
||||||
&GetAuthValCode
|
&GetAuthValCode
|
||||||
&AddAuthorisedValue
|
|
||||||
&GetNormalizedUPC
|
&GetNormalizedUPC
|
||||||
&GetNormalizedISBN
|
&GetNormalizedISBN
|
||||||
&GetNormalizedEAN
|
&GetNormalizedEAN
|
||||||
|
@ -1395,26 +1394,6 @@ sub GetKohaAuthorisedValueLib {
|
||||||
return $value;
|
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
|
=head2 display_marc_indicators
|
||||||
|
|
||||||
my $display_form = C4::Koha::display_marc_indicators($field);
|
my $display_form = C4::Koha::display_marc_indicators($field);
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
# This is to test C4/Koha
|
# This is to test C4/Koha
|
||||||
# It requires a working Koha database with the sample data
|
# It requires a working Koha database with the sample data
|
||||||
|
|
||||||
use strict;
|
use Modern::Perl;
|
||||||
use warnings;
|
|
||||||
use C4::Context;
|
use C4::Context;
|
||||||
use Koha::DateUtils qw(dt_from_string);
|
use Koha::DateUtils qw(dt_from_string);
|
||||||
|
use Koha::AuthorisedValue;
|
||||||
|
|
||||||
use Test::More tests => 10;
|
use Test::More tests => 10;
|
||||||
use DateTime::Format::MySQL;
|
use DateTime::Format::MySQL;
|
||||||
|
@ -33,7 +33,14 @@ subtest 'Authorized Values Tests' => sub {
|
||||||
|
|
||||||
|
|
||||||
# Insert an entry into authorised_value table
|
# Insert an entry into authorised_value table
|
||||||
my $insert_success = AddAuthorisedValue($data->{category}, $data->{authorised_value}, $data->{lib}, $data->{lib_opac}, $data->{imageurl});
|
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" );
|
ok( $insert_success, "Insert data in database" );
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,11 +70,34 @@ subtest 'Authorized Values Tests' => sub {
|
||||||
SKIP: {
|
SKIP: {
|
||||||
eval { require Test::Deep; import Test::Deep; };
|
eval { require Test::Deep; import Test::Deep; };
|
||||||
skip "Test::Deep required to run the GetAuthorisedValues() tests.", 2 if $@;
|
skip "Test::Deep required to run the GetAuthorisedValues() tests.", 2 if $@;
|
||||||
AddAuthorisedValue('BUG10656', 'ZZZ', 'Z_STAFF', 'A_PUBLIC', '');
|
Koha::AuthorisedValue->new(
|
||||||
AddAuthorisedValue('BUG10656', 'AAA', 'A_STAFF', 'Z_PUBLIC', '');
|
{ 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
|
# the next one sets lib_opac to NULL; in that case, the staff
|
||||||
# display value is meant to be used.
|
# 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');
|
my $authvals = GetAuthorisedValues('BUG10656');
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$authvals,
|
$authvals,
|
||||||
|
@ -300,7 +330,12 @@ subtest 'GetFrameworksLoop() tests' => sub {
|
||||||
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
|
subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
|
||||||
plan tests => 7;
|
plan tests => 7;
|
||||||
|
|
||||||
my $insertGroup = AddAuthorisedValue('ITEMTYPECAT', 'Qwertyware');
|
my $insertGroup = Koha::AuthorisedValue->new(
|
||||||
|
{ category => 'ITEMTYPECAT',
|
||||||
|
authorised_value => 'Quertyware',
|
||||||
|
}
|
||||||
|
)->store;
|
||||||
|
|
||||||
ok($insertGroup, "Create group Qwertyware");
|
ok($insertGroup, "Create group Qwertyware");
|
||||||
|
|
||||||
my $query = "INSERT into itemtypes (itemtype, description, searchcategory, hideinopac) values (?,?,?,?)";
|
my $query = "INSERT into itemtypes (itemtype, description, searchcategory, hideinopac) values (?,?,?,?)";
|
||||||
|
@ -318,7 +353,12 @@ subtest 'GetItemTypesByCategory GetItemTypesCategorized test' => sub{
|
||||||
is_deeply(\@results,\@expected,'GetItemTypesByCategory: valid category returns itemtypes');
|
is_deeply(\@results,\@expected,'GetItemTypesByCategory: valid category returns itemtypes');
|
||||||
|
|
||||||
# add more data since GetItemTypesCategorized's search is more subtle
|
# 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);
|
$insertSth->execute('BKghjklo4', 'Another hidden book', 'Veryheavybook', 1);
|
||||||
|
|
||||||
my $hrCat = GetItemTypesCategorized();
|
my $hrCat = GetItemTypesCategorized();
|
||||||
|
|
Loading…
Reference in a new issue