|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 8; |
| 23 |
|
23 |
|
| 24 |
use C4::Biblio; |
24 |
use C4::Biblio; |
| 25 |
use C4::Circulation; |
25 |
use C4::Circulation; |
|
Lines 27-32
use C4::Circulation;
Link Here
|
| 27 |
use Koha::Items; |
27 |
use Koha::Items; |
| 28 |
use Koha::Database; |
28 |
use Koha::Database; |
| 29 |
use Koha::Old::Items; |
29 |
use Koha::Old::Items; |
|
|
30 |
use Koha::AuthorisedValueCategories; |
| 31 |
use Koha::AuthorisedValues; |
| 30 |
|
32 |
|
| 31 |
use List::MoreUtils qw(all); |
33 |
use List::MoreUtils qw(all); |
| 32 |
|
34 |
|
|
Lines 516-518
subtest 'Tests for itemtype' => sub {
Link Here
|
| 516 |
|
518 |
|
| 517 |
$schema->storage->txn_rollback; |
519 |
$schema->storage->txn_rollback; |
| 518 |
}; |
520 |
}; |
| 519 |
- |
521 |
|
|
|
522 |
subtest '_fetch_authorised_values' => sub { |
| 523 |
plan tests => 1; |
| 524 |
|
| 525 |
$schema->storage->txn_begin; |
| 526 |
|
| 527 |
# Delete all Authorised Values of 'Countries' category |
| 528 |
Koha::AuthorisedValues->search({category => 'Countries'})->delete; |
| 529 |
Koha::AuthorisedValueCategories->search({category_name => 'Countries'})->delete; |
| 530 |
|
| 531 |
# Create 'Countries' category and authorised value |
| 532 |
my $cat = $builder->build_object({ class => 'Koha::AuthorisedValueCategories'}); |
| 533 |
my $country = $builder->build_object({ class => 'Koha::AuthorisedValues', value => { category => $cat->category_name } }); |
| 534 |
|
| 535 |
# Create a new biblio framework |
| 536 |
my $fw = $builder->build_object({ class => 'Koha::BiblioFrameworks' }); |
| 537 |
|
| 538 |
# Add a Marc subfield with kohafield setted to 'items.itemnote' |
| 539 |
$builder->build_object({class => 'Koha::MarcSubfieldStructures', value => {frameworkcode => $fw->frameworkcode, authorised_value => $cat->category_name, kohafield => 'items.itemnotes'}}); |
| 540 |
|
| 541 |
# Create biblio and item |
| 542 |
my $biblio = $builder->build_sample_biblio({frameworkcode => $fw->frameworkcode}); |
| 543 |
my $item = $builder->build_sample_item({biblionumber => $biblio->biblionumber, itemnotes => $country->authorised_value}); |
| 544 |
|
| 545 |
# Fetch authorised values |
| 546 |
my $avs = $item->_fetch_authorised_values(); |
| 547 |
|
| 548 |
is($avs->{itemnotes}->{lib}, $country->lib, 'Fetched auhtorised value is ok'); |
| 549 |
|
| 550 |
$schema->storage->txn_rollback; |
| 551 |
} |