Bug 10676: Add unit tests - GetItemsInfo

To test:
  prove t/db_dependent/Items.t

Signed-off-by: Pierre-Marc Thibault <pierre-marc.thibault@inLibro.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 4e139a237b)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
(cherry picked from commit 97f41c827f)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Katrin Fischer 2019-01-04 11:42:08 +00:00 committed by Lucas Gass
parent 3e33394757
commit a62ab43562
1 changed files with 20 additions and 1 deletions

View File

@ -29,6 +29,7 @@ use Koha::Library;
use Koha::DateUtils;
use Koha::MarcSubfieldStructures;
use Koha::Caches;
use Koha::AuthorisedValues;
use t::lib::Mocks;
use t::lib::TestBuilder;
@ -243,7 +244,7 @@ subtest 'GetHiddenItemnumbers tests' => sub {
subtest 'GetItemsInfo tests' => sub {
plan tests => 4;
plan tests => 7;
$schema->storage->txn_begin;
@ -258,6 +259,16 @@ subtest 'GetItemsInfo tests' => sub {
source => 'Itemtype',
});
Koha::AuthorisedValues->delete;
my $av1 = Koha::AuthorisedValue->new(
{
category => 'RESTRICTED',
authorised_value => '1',
lib => 'Restricted Access',
lib_opac => 'Restricted Access OPAC',
}
)->store();
# Add a biblio
my ($biblionumber, $biblioitemnumber) = get_biblio();
# Add an item
@ -266,6 +277,7 @@ subtest 'GetItemsInfo tests' => sub {
homebranch => $library1->{branchcode},
holdingbranch => $library2->{branchcode},
itype => $itemtype->{itemtype},
restricted => 1,
},
$biblionumber
);
@ -280,12 +292,19 @@ subtest 'GetItemsInfo tests' => sub {
my @results = GetItemsInfo( $biblionumber );
ok( @results, 'GetItemsInfo returns results');
is( $results[0]->{ home_branch_opac_info }, "homebranch OPAC info",
'GetItemsInfo returns the correct home branch OPAC info notice' );
is( $results[0]->{ holding_branch_opac_info }, "holdingbranch OPAC info",
'GetItemsInfo returns the correct holding branch OPAC info notice' );
is( exists( $results[0]->{ onsite_checkout } ), 1,
'GetItemsInfo returns a onsite_checkout key' );
is( $results[0]->{ restricted }, 1,
'GetItemsInfo returns a restricted value code' );
is( $results[0]->{ restrictedvalue }, "Restricted Access",
'GetItemsInfo returns a restricted value description (staff)' );
is( $results[0]->{ restrictedvalueopac }, "Restricted Access OPAC",
'GetItemsInfo returns a restricted value description (OPAC)' );
$schema->storage->txn_rollback;
};