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

(-)a/t/db_dependent/Circulation.t (-1 / +48 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 94;
20
use Test::More tests => 95;
21
21
22
use DateTime;
22
use DateTime;
23
23
Lines 29-39 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;
35
use Koha::Database;
36
use Koha::Database;
36
use Koha::IssuingRules;
37
use Koha::IssuingRules;
38
use Koha::Patron::Message::Attributes;
39
use Koha::Patron::Message::Preferences;
37
use Koha::Subscriptions;
40
use Koha::Subscriptions;
38
41
39
my $schema = Koha::Database->schema;
42
my $schema = Koha::Database->schema;
Lines 1480-1485 subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { Link Here
1480
            }
1483
            }
1481
        }
1484
        }
1482
    );
1485
    );
1486
    
1483
    my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } );
1487
    my $biblioitem_2 = $builder->build( { source => 'Biblioitem' } );
1484
    my $item_2 = $builder->build(
1488
    my $item_2 = $builder->build(
1485
        {
1489
        {
Lines 1585-1590 subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { Link Here
1585
    );
1589
    );
1586
    is( $debarments->[0]->{expiration}, $expected_expiration );
1590
    is( $debarments->[0]->{expiration}, $expected_expiration );
1587
};
1591
};
1592
    
1593
subtest 'SendCirculationAlert test' => sub {
1594
    plan tests => 4;
1595
1596
    my $library = $builder->build( { source => 'Branch' } );
1597
    my $patron  = $builder->build( { source => 'Borrower' } );
1598
    my $attribute = Koha::Patron::Message::Attributes->find({
1599
        message_name => 'Item_Checkout',
1600
    });
1601
    Koha::Patron::Message::Preference->new({
1602
        borrowernumber => $patron->{'borrowernumber'},
1603
        message_attribute_id => $attribute->message_attribute_id,
1604
        days_in_advance => 0,
1605
        wants_digest => 0,
1606
        message_transport_types => ['email'],
1607
    })->store;
1608
    my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } );
1609
    my $item_1 = $builder->build(
1610
        {   source => 'Item',
1611
            value  => {
1612
                homebranch    => $library->{branchcode},
1613
                holdingbranch => $library->{branchcode},
1614
                notforloan    => 0,
1615
                itemlost      => 0,
1616
                withdrawn     => 0,
1617
                biblionumber  => $biblioitem_1->{biblionumber}
1618
            }
1619
        }
1620
    );
1621
1622
    my $old_message = C4::Message->find_last_message($patron, 'CHECKOUT', 'email');
1623
    $old_message->{'message_id'} = 0 unless $old_message;
1624
    is(C4::Circulation::SendCirculationAlert({
1625
        type     => 'CHECKOUT',
1626
        item     => $item_1,
1627
        borrower => $patron,
1628
        branch   => $library->{'branchcode'},
1629
    }), undef, "SendCirculationAlert called.");
1630
    my $new_message = C4::Message->find_last_message($patron, 'CHECKOUT', 'email');
1631
    ok($old_message->{'message_id'} != $new_message->{'message_id'}, "New message has appeared.");
1632
    is($new_message->{'letter_code'}, 'CHECKOUT', "New message letter code is CHECKOUT.");
1633
    is($new_message->{'borrowernumber'}, $patron->{'borrowernumber'}, "New message is to our test patron.");
1634
};
1588
1635
1589
sub set_userenv {
1636
sub set_userenv {
1590
    my ( $library ) = @_;
1637
    my ( $library ) = @_;
(-)a/t/db_dependent/Reserves.t (-2 / +56 lines)
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
- 

Return to bug 18595