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

(-)a/t/db_dependent/Reserves.t (-2 / +39 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
<<<<<<< HEAD
20
use Test::More tests => 64;
21
use Test::More tests => 64;
22
=======
23
use Test::More tests => 63;
24
>>>>>>> Bug 11999: Test improvements + check maxreserves
21
use Test::MockModule;
25
use Test::MockModule;
22
use Test::Warn;
26
use Test::Warn;
23
27
Lines 61-67 my $frameworkcode = q//; Link Here
61
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1);
65
t::lib::Mocks::mock_preference('ReservesNeedReturns', 1);
62
66
63
# Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached
67
# Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached
64
$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode);
68
$dbh->do(q|
69
    INSERT INTO marc_subfield_structure (frameworkcode, tagfield, tagsubfield, kohafield)
70
    VALUES ('', '521', 'a', 'biblioitems.agerestriction')
71
    ON DUPLICATE KEY UPDATE kohafield = VALUES(kohafield)
72
|);
65
my $cache = Koha::Caches->get_instance;
73
my $cache = Koha::Caches->get_instance;
66
$cache->clear_from_cache("MarcStructure-0-$frameworkcode");
74
$cache->clear_from_cache("MarcStructure-0-$frameworkcode");
67
$cache->clear_from_cache("MarcStructure-1-$frameworkcode");
75
$cache->clear_from_cache("MarcStructure-1-$frameworkcode");
Lines 1150-1156 subtest 'CheckReserves additional test' => sub { Link Here
1150
    is( $matched_reserve->{reserve_id},
1158
    is( $matched_reserve->{reserve_id},
1151
        $reserve1->reserve_id, "We got the Transit reserve" );
1159
        $reserve1->reserve_id, "We got the Transit reserve" );
1152
    is( scalar @$possible_reserves, 2, 'We do get both reserves' );
1160
    is( scalar @$possible_reserves, 2, 'We do get both reserves' );
1161
};
1162
1163
subtest 'check maxreserve test' => sub {
1164
1165
    plan tests => 2;
1166
1167
    t::lib::Mocks::mock_preference('maxreserves', 1);
1168
    # Create the items and patrons we need
1169
    my $biblio_1 = $builder->build_sample_biblio();
1170
    my $biblio_2 = $builder->build_sample_biblio();
1171
    my $itype = $builder->build_object({ class => "Koha::ItemTypes", value => { notforloan => 0 } });
1172
    my $item_1 = $builder->build_sample_item({ biblionumber => $biblio_1->biblionumber,notforloan => 0, itype => $itype->itemtype });
1173
    my $item_2 = $builder->build_sample_item({ biblionumber => $biblio_2->biblionumber, notforloan => 0, itype => $itype->itemtype });
1174
    my $patron = $builder->build_object({ class => "Koha::Patrons" });
1175
1176
1177
    # Place a hold on the title for both patrons
1178
    my $reserve = AddReserve(
1179
        {
1180
            branchcode     => $item_1->homebranch,
1181
            borrowernumber => $patron->borrowernumber,
1182
            biblionumber   => $biblio_1->biblionumber,
1183
            priority       => 1,
1184
            itemnumber     => $item_1->itemnumber,
1185
        }
1186
    );
1187
1188
    my $borrowernumber = $patron->borrowernumber;
1153
1189
1190
    is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblio_2->biblionumber)->{status} , 'tooManyReserves', "Reserving more than maxreserves is forbidden");
1191
    is( C4::Reserves::CanItemBeReserved($borrowernumber, $item_2->itemnumber, $item_2->homebranch)->{status} , 'tooManyReserves', "Reserving more than maxreserves is forbidden");
1154
};
1192
};
1155
1193
1156
sub count_hold_print_messages {
1194
sub count_hold_print_messages {
1157
- 

Return to bug 11999