4 use Test::More tests => 3;
5 use t::lib::TestBuilder;
11 use_ok('Koha::Z3950Responder');
12 use_ok('Koha::Z3950Responder::Session');
15 my $builder = t::lib::TestBuilder->new;
16 my $schema = Koha::Database->new->schema;
18 $schema->storage->txn_begin;
20 # Clear the cache, before and after
21 Koha::Caches->get_instance->flush_all;
23 subtest 'add_item_status' => sub {
27 # This time we are sustituting some values
28 $builder->schema->resultset( 'AuthorisedValue' )->delete_all();
30 source => 'AuthorisedValue',
32 category => 'Z3950_STATUS',
33 authorised_value => 'AVAILABLE',
34 lib => "Free as a bird"
38 source => 'AuthorisedValue',
40 category => 'Z3950_STATUS',
41 authorised_value => 'DAMAGED',
42 lib => "Borked completely"
46 ## FIRST ITEM HAS ALL THE STATUSES ##
47 my $item_1 = $builder->build_sample_item(
49 onloan => '2017-07-07',
56 my $item_marc_1 = C4::Items::GetMarcItem( $item_1->biblionumber, $item_1->itemnumber );
57 my $item_field_1 = scalar $item_marc_1->field('952');
58 $builder->build({ source => 'Reserve', value=> { itemnumber => $item_1->itemnumber } });
61 source => 'Branchtransfer',
63 itemnumber => $item_1->itemnumber,
65 datecancelled => undef
71 ## SECOND ITEM HAS NO STATUSES ##
72 my $item_2 = $builder->build_sample_item;
73 my $item_marc_2 = C4::Items::GetMarcItem( $item_2->biblionumber, $item_2->itemnumber );
74 my $item_field_2 = scalar $item_marc_2->field('952');
77 # Create the responder
78 my $args={ PEER_NAME => 'PEER'};
79 my $zR = Koha::Z3950Responder->new({add_item_status_subfield => 'k'});
80 $zR->init_handler($args);
82 $args->{HANDLE}->add_item_status($item_field_1);
83 is($item_field_1->subfield('k'),"Checked Out, Lost, Not for Loan, Borked completely, Withdrawn, In Transit, On Hold","All statuses added in one field as expected");
85 $args->{HANDLE}->add_item_status($item_field_2);
86 is($item_field_2->subfield('k'),'Free as a bird',"Available status is 'Free as a bird' added as expected");
90 # Clear the cache, before and after
91 Koha::Caches->get_instance->flush_all;
93 $schema->storage->txn_rollback;