View | Details | Raw Unified | Return to bug 18595
Collapse All | Expand All

(-)a/t/db_dependent/Circulation.t (-1 / +46 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 112;
20
use Test::More tests => 113;
21
21
22
use DateTime;
22
use DateTime;
23
23
Lines 29-34 use C4::Biblio; Link Here
29
use C4::Items;
29
use C4::Items;
30
use C4::Log;
30
use C4::Log;
31
use C4::Members;
31
use C4::Members;
32
use C4::Message;
32
use C4::Reserves;
33
use C4::Reserves;
33
use C4::Overdues qw(UpdateFine CalcFine);
34
use C4::Overdues qw(UpdateFine CalcFine);
34
use Koha::DateUtils;
35
use Koha::DateUtils;
Lines 36-41 use Koha::Database; Link Here
36
use Koha::IssuingRules;
37
use Koha::IssuingRules;
37
use Koha::Checkouts;
38
use Koha::Checkouts;
38
use Koha::Patrons;
39
use Koha::Patrons;
40
use Koha::Patron::Message::Attributes;
41
use Koha::Patron::Message::Preferences;
39
use Koha::Subscriptions;
42
use Koha::Subscriptions;
40
use Koha::Account::Lines;
43
use Koha::Account::Lines;
41
use Koha::Account::Offsets;
44
use Koha::Account::Offsets;
Lines 2010-2016 subtest 'CanBookBeIssued | is_overdue' => sub { Link Here
2010
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->{barcode},$ten_days_go, undef, undef, undef);
2013
    my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->{barcode},$ten_days_go, undef, undef, undef);
2011
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
2014
    is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal");
2012
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
2015
    is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal");
2016
};
2017
2018
subtest 'SendCirculationAlert test' => sub {
2019
    plan tests => 4;
2020
2021
    my $library = $builder->build( { source => 'Branch' } );
2022
    my $patron  = $builder->build( { source => 'Borrower' } );
2023
    my $attribute = Koha::Patron::Message::Attributes->find({
2024
        message_name => 'Item_Checkout',
2025
    });
2026
    Koha::Patron::Message::Preference->new({
2027
        borrowernumber => $patron->{'borrowernumber'},
2028
        message_attribute_id => $attribute->message_attribute_id,
2029
        days_in_advance => undef,
2030
        wants_digest => 0,
2031
        message_transport_types => ['email'],
2032
    })->store;
2033
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
2034
    my $item_1 = $builder->build(
2035
        {   source => 'Item',
2036
            value  => {
2037
                homebranch    => $library->{branchcode},
2038
                holdingbranch => $library->{branchcode},
2039
                notforloan    => 0,
2040
                itemlost      => 0,
2041
                withdrawn     => 0,
2042
                biblionumber  => $biblioitem_1->{biblionumber}
2043
            }
2044
        }
2045
    );
2013
2046
2047
    my $old_message = C4::Message->find_last_message($patron, 'CHECKOUT', 'email');
2048
    $old_message->{'message_id'} = 0 unless $old_message;
2049
    is(C4::Circulation::SendCirculationAlert({
2050
        type     => 'CHECKOUT',
2051
        item     => $item_1,
2052
        borrower => $patron,
2053
        branch   => $library->{'branchcode'},
2054
    }), undef, "SendCirculationAlert called.");
2055
    my $new_message = C4::Message->find_last_message($patron, 'CHECKOUT', 'email');
2056
    ok($old_message->{'message_id'} != $new_message->{'message_id'}, "New message has appeared.");
2057
    is($new_message->{'letter_code'}, 'CHECKOUT', "New message letter code is CHECKOUT.");
2058
    is($new_message->{'borrowernumber'}, $patron->{'borrowernumber'}, "New message is to our test patron.");
2014
};
2059
};
2015
2060
2016
sub set_userenv {
2061
sub set_userenv {
(-)a/t/db_dependent/Reserves.t (-14 / +11 lines)
Lines 39-44 use Koha::Libraries; Link Here
39
use Koha::Notice::Templates;
39
use Koha::Notice::Templates;
40
use Koha::Patrons;
40
use Koha::Patrons;
41
use Koha::Patron::Categories;
41
use Koha::Patron::Categories;
42
use Koha::Patron::Message::Preference;
42
43
43
BEGIN {
44
BEGIN {
44
    require_ok('C4::Reserves');
45
    require_ok('C4::Reserves');
Lines 623-641 subtest '_koha_notify_reserve() tests' => sub { Link Here
623
624
624
    plan tests => 2;
625
    plan tests => 2;
625
626
626
    my $wants_hold_and_email = {
627
        wants_digest => '0',
628
        transports => {
629
            sms => 'HOLD',
630
            email => 'HOLD',
631
            },
632
        letter_code => 'HOLD'
633
    };
634
635
    my $mp = Test::MockModule->new( 'C4::Members::Messaging' );
636
637
    $mp->mock("GetMessagingPreferences",$wants_hold_and_email);
638
639
    $dbh->do('DELETE FROM letter');
627
    $dbh->do('DELETE FROM letter');
640
628
641
    my $email_hold_notice = $builder->build({
629
    my $email_hold_notice = $builder->build({
Lines 675-680 subtest '_koha_notify_reserve() tests' => sub { Link Here
675
            }
663
            }
676
        });
664
        });
677
665
666
    my $message_attr_id = Koha::Patron::Message::Attributes->find({
667
        message_name => 'Hold_Filled'
668
    })->message_attribute_id;
669
    Koha::Patron::Message::Preference->new({
670
        borrowernumber => $hold_borrower,
671
        message_attribute_id   => $message_attr_id,
672
        message_transport_types => ['sms', 'email'],
673
        wants_digest   => 0,
674
    })->store;
675
678
    ModReserveAffect($hold->{itemnumber}, $hold->{borrowernumber}, 0);
676
    ModReserveAffect($hold->{itemnumber}, $hold->{borrowernumber}, 0);
679
    my $sms_message_address = $schema->resultset('MessageQueue')->search({
677
    my $sms_message_address = $schema->resultset('MessageQueue')->search({
680
            letter_code     => 'HOLD',
678
            letter_code     => 'HOLD',
681
- 

Return to bug 18595