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

(-)a/t/db_dependent/Koha/Recalls.t (-10 / +49 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 20;
20
use Test::More tests => 23;
21
use t::lib::Dates;
21
use t::lib::Dates;
22
use t::lib::TestBuilder;
22
use t::lib::TestBuilder;
23
use t::lib::Mocks;
23
use t::lib::Mocks;
Lines 45-50 my $biblio1 = $item1->biblio; Link Here
45
my $branch1 = $item1->holdingbranch;
45
my $branch1 = $item1->holdingbranch;
46
my $itemtype1 = $item1->effective_itemtype;
46
my $itemtype1 = $item1->effective_itemtype;
47
my $item2 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
47
my $item2 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
48
my $item3 = $builder->build_sample_item({ biblionumber => $biblio1->biblionumber });
48
my $biblio2 = $item1->biblio;
49
my $biblio2 = $item1->biblio;
49
my $branch2 = $item1->holdingbranch;
50
my $branch2 = $item1->holdingbranch;
50
my $itemtype2 = $item1->effective_itemtype;
51
my $itemtype2 = $item1->effective_itemtype;
Lines 53-72 my $category1 = $builder->build({ source => 'Category' })->{ categorycode }; Link Here
53
my $patron1 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch1 } });
54
my $patron1 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch1 } });
54
my $patron2 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch2 } });
55
my $patron2 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch2 } });
55
my $patron3 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch1 } });
56
my $patron3 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch1 } });
57
my $patron4 = $builder->build_object({ class => 'Koha::Patrons', value => { categorycode => $category1, branchcode => $branch2 } });
56
t::lib::Mocks::mock_userenv({ patron => $patron1 });
58
t::lib::Mocks::mock_userenv({ patron => $patron1 });
57
59
58
Koha::CirculationRules->set_rules({
60
Koha::CirculationRules->set_rules(
59
    branchcode => undef,
61
    {
60
    categorycode => undef,
62
        branchcode   => undef,
61
    itemtype => undef,
63
        categorycode => undef,
62
    rules => {
64
        itemtype     => undef,
63
        'recall_due_date_interval' => undef,
65
        rules        => {
64
        'recalls_allowed' => 10,
66
            'issuelength'              => 7,
67
            'recall_due_date_interval' => undef,
68
            'recalls_allowed'          => 10,
69
        }
65
    }
70
    }
66
});
71
);
67
72
68
C4::Circulation::AddIssue( $patron3, $item1->barcode );
73
C4::Circulation::AddIssue( $patron3, $item1->barcode );
69
C4::Circulation::AddIssue( $patron3, $item2->barcode );
74
C4::Circulation::AddIssue( $patron3, $item2->barcode );
75
C4::Circulation::AddIssue( $patron4, $item3->barcode );
70
76
71
C4::Members::Messaging::SetMessagingPreference(
77
C4::Members::Messaging::SetMessagingPreference(
72
    {
78
    {
Lines 106-111 ok( !defined $recall, "Can't add a recall without specifying a biblio" ); Link Here
106
});
112
});
107
ok( !defined $recall, "Can't add a recall without specifying a biblio" );
113
ok( !defined $recall, "Can't add a recall without specifying a biblio" );
108
114
115
my $initial_checkout_due_date = Koha::Checkouts->find( $item2->checkout->issue_id )->date_due;
109
( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
116
( $recall, $due_interval, $due_date ) = Koha::Recalls->add_recall({
110
    patron => $patron2,
117
    patron => $patron2,
111
    biblio => $biblio1,
118
    biblio => $biblio1,
Lines 114-121 ok( !defined $recall, "Can't add a recall without specifying a biblio" ); Link Here
114
    expirationdate => undef,
121
    expirationdate => undef,
115
    interface => 'COMMANDLINE',
122
    interface => 'COMMANDLINE',
116
});
123
});
124
my $checkout_due_date_after_recall = Koha::Checkouts->find( $item2->checkout->issue_id )->date_due;
117
is( $recall->pickup_library_id, $branch2, "No pickup branch specified so patron branch used" );
125
is( $recall->pickup_library_id, $branch2, "No pickup branch specified so patron branch used" );
118
is( $due_interval, 5, "Recall due date interval defaults to 5 if not specified" );
126
is( $due_interval, 5, "Recall due date interval defaults to 5 if not specified" );
127
ok(
128
    $checkout_due_date_after_recall lt $initial_checkout_due_date,
129
    "Checkout due date has been moved backwards"
130
);
119
131
120
Koha::CirculationRules->set_rule({
132
Koha::CirculationRules->set_rule({
121
    branchcode => undef,
133
    branchcode => undef,
Lines 154-159 is( Link Here
154
);
166
);
155
is( t::lib::Dates::compare( $due_date, $expected_due_date ), 0, "Due date correctly returned" );
167
is( t::lib::Dates::compare( $due_date, $expected_due_date ), 0, "Due date correctly returned" );
156
168
169
Koha::CirculationRules->set_rule(
170
    {
171
        branchcode   => undef,
172
        categorycode => undef,
173
        itemtype     => undef,
174
        rule_name    => 'recall_due_date_interval',
175
        rule_value   => 10,
176
    }
177
);
178
$initial_checkout_due_date = Koha::Checkouts->find( $item3->checkout->issue_id )->date_due;
179
my $recall2;
180
( $recall2, $due_interval, $due_date ) = Koha::Recalls->add_recall(
181
    {
182
        patron         => $patron2,
183
        biblio         => $biblio1,
184
        branchcode     => $branch1,
185
        item           => $item3,
186
        expirationdate => undef,
187
        interface      => 'COMMANDLINE',
188
    }
189
);
190
$checkout_due_date_after_recall = Koha::Checkouts->find( $item3->checkout->issue_id )->date_due;
191
is( $due_interval, 10, "Recall due date interval increased above checkout due" );
192
ok(
193
    $checkout_due_date_after_recall eq $initial_checkout_due_date,
194
    "Checkout due date has not been moved forward"
195
);
196
157
my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;
197
my $messages_count = Koha::Notice::Messages->search({ borrowernumber => $patron3->borrowernumber, letter_code => 'RETURN_RECALLED_ITEM' })->count;
158
is( $messages_count, 6, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" );
198
is( $messages_count, 6, "RETURN_RECALLED_ITEM notice successfully sent to checkout borrower" );
159
199
160
- 

Return to bug 32696