Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 8; |
22 |
use Test::More tests => 9; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
25 |
use C4::Biblio; |
25 |
use C4::Biblio; |
Lines 29-34
use Koha::Items;
Link Here
|
29 |
use Koha::Database; |
29 |
use Koha::Database; |
30 |
use Koha::DateUtils; |
30 |
use Koha::DateUtils; |
31 |
use Koha::Old::Items; |
31 |
use Koha::Old::Items; |
|
|
32 |
use Koha::AuthorisedValueCategories; |
33 |
use Koha::AuthorisedValues; |
32 |
|
34 |
|
33 |
use List::MoreUtils qw(all); |
35 |
use List::MoreUtils qw(all); |
34 |
|
36 |
|
Lines 691-693
subtest 'Tests for itemtype' => sub {
Link Here
|
691 |
|
693 |
|
692 |
$schema->storage->txn_rollback; |
694 |
$schema->storage->txn_rollback; |
693 |
}; |
695 |
}; |
694 |
- |
696 |
|
|
|
697 |
subtest '_fetch_authorised_values' => sub { |
698 |
plan tests => 1; |
699 |
|
700 |
$schema->storage->txn_begin; |
701 |
|
702 |
# Delete all Authorised Values of 'Countries' category |
703 |
Koha::AuthorisedValues->search({category => 'Countries'})->delete; |
704 |
Koha::AuthorisedValueCategories->search({category_name => 'Countries'})->delete; |
705 |
|
706 |
# Create 'Countries' category and authorised value |
707 |
my $cat = $builder->build_object({ class => 'Koha::AuthorisedValueCategories'}); |
708 |
my $country = $builder->build_object({ class => 'Koha::AuthorisedValues', value => { category => $cat->category_name } }); |
709 |
|
710 |
# Create a new biblio framework |
711 |
my $fw = $builder->build_object({ class => 'Koha::BiblioFrameworks' }); |
712 |
|
713 |
# Add a Marc subfield with kohafield setted to 'items.itemnote' |
714 |
$builder->build_object({class => 'Koha::MarcSubfieldStructures', value => {frameworkcode => $fw->frameworkcode, authorised_value => $cat->category_name, kohafield => 'items.itemnotes'}}); |
715 |
|
716 |
# Create biblio and item |
717 |
my $biblio = $builder->build_sample_biblio({frameworkcode => $fw->frameworkcode}); |
718 |
my $item = $builder->build_sample_item({biblionumber => $biblio->biblionumber, itemnotes => $country->authorised_value}); |
719 |
|
720 |
# Fetch authorised values |
721 |
my $avs = $item->_fetch_authorised_values(); |
722 |
|
723 |
is($avs->{itemnotes}->{lib}, $country->lib, 'Fetched auhtorised value is ok'); |
724 |
|
725 |
$schema->storage->txn_rollback; |
726 |
} |