Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 71; |
20 |
use Test::More tests => 72; |
21 |
use Test::MockModule; |
21 |
use Test::MockModule; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
Lines 31-42
use C4::Biblio;
Link Here
|
31 |
use C4::Circulation; |
31 |
use C4::Circulation; |
32 |
use C4::Items; |
32 |
use C4::Items; |
33 |
use C4::Members; |
33 |
use C4::Members; |
|
|
34 |
use C4::Message; |
34 |
use C4::Reserves; |
35 |
use C4::Reserves; |
35 |
use Koha::Caches; |
36 |
use Koha::Caches; |
36 |
use Koha::DateUtils; |
37 |
use Koha::DateUtils; |
37 |
use Koha::Holds; |
38 |
use Koha::Holds; |
38 |
use Koha::Libraries; |
39 |
use Koha::Libraries; |
39 |
use Koha::Patron::Categories; |
40 |
use Koha::Patron::Categories; |
|
|
41 |
use Koha::Patron::Message::Preference; |
42 |
use Koha::Patrons; |
40 |
|
43 |
|
41 |
BEGIN { |
44 |
BEGIN { |
42 |
require_ok('C4::Reserves'); |
45 |
require_ok('C4::Reserves'); |
Lines 713-718
$cache->clear_from_cache("MarcStructure-1-$frameworkcode");
Link Here
|
713 |
$cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode"); |
716 |
$cache->clear_from_cache("default_value_for_mod_marc-$frameworkcode"); |
714 |
$cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); |
717 |
$cache->clear_from_cache("MarcSubfieldStructure-$frameworkcode"); |
715 |
|
718 |
|
|
|
719 |
subtest '_koha_notify_reserve tests' => sub { |
720 |
plan tests => 4; |
721 |
|
722 |
my $library = $builder->build( { source => 'Branch' } ); |
723 |
my $patron = $builder->build( { source => 'Borrower', value => { branchcode => $library->{branchcode} } } ); |
724 |
my $attribute = Koha::Patron::Message::Attributes->find({ |
725 |
message_name => 'Hold_Filled', |
726 |
}); |
727 |
Koha::Patron::Message::Preference->new({ |
728 |
borrowernumber => $patron->{'borrowernumber'}, |
729 |
message_attribute_id => $attribute->message_attribute_id, |
730 |
days_in_advance => 0, |
731 |
wants_digest => 0, |
732 |
message_transport_types => ['email'], |
733 |
})->store; |
734 |
my $biblio_1 = $builder->build( { source => 'Biblio' } ); |
735 |
my $item_1 = $builder->build( |
736 |
{ source => 'Item', |
737 |
value => { |
738 |
homebranch => $library->{branchcode}, |
739 |
holdingbranch => $library->{branchcode}, |
740 |
notforloan => 0, |
741 |
itemlost => 0, |
742 |
withdrawn => 0, |
743 |
biblionumber => $biblio_1->{biblionumber} |
744 |
} |
745 |
} |
746 |
); |
747 |
my $reserve_id = AddReserve( |
748 |
$library->{branchcode}, |
749 |
$patron->{'borrowernumber'}, |
750 |
$biblio_1->{'biblionumber'}, |
751 |
undef, |
752 |
'1', |
753 |
undef, |
754 |
undef, |
755 |
'', |
756 |
$title, |
757 |
$item_1->{'itemnumber'}, |
758 |
'W' |
759 |
); |
760 |
|
761 |
my $old_message = C4::Message->find_last_message($patron, 'HOLD', 'email'); |
762 |
$old_message->{'message_id'} = 0 unless $old_message; |
763 |
is(C4::Reserves::_koha_notify_reserve($reserve_id), '', |
764 |
"_koha_notify_reserve called."); |
765 |
my $new_message = C4::Message->find_last_message($patron, 'HOLD', 'email'); |
766 |
ok($old_message->{'message_id'} != $new_message->{'message_id'}, "New message has appeared."); |
767 |
is($new_message->{'letter_code'}, 'HOLD', "New message letter code is HOLD."); |
768 |
is($new_message->{'borrowernumber'}, $patron->{'borrowernumber'}, "New message is to our test patron."); |
769 |
}; |
770 |
|
716 |
# we reached the finish |
771 |
# we reached the finish |
717 |
$schema->storage->txn_rollback(); |
772 |
$schema->storage->txn_rollback(); |
718 |
|
773 |
|
719 |
- |
|
|