|
Lines 19-25
Link Here
|
| 19 |
use Modern::Perl; |
19 |
use Modern::Perl; |
| 20 |
|
20 |
|
| 21 |
use Data::Dumper; # REMOVEME with diag |
21 |
use Data::Dumper; # REMOVEME with diag |
| 22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 4; |
| 23 |
use Test::MockModule; |
23 |
use Test::MockModule; |
| 24 |
use Test::MockTime qw( set_fixed_time ); |
24 |
use Test::MockTime qw( set_fixed_time ); |
| 25 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
|
Lines 94-99
$dbh->do(q|
Link Here
|
| 94 |
INSERT INTO letter( module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES ('circulation', 'ISSUEQSLIP', '', 'Issue Quick Slip', 0, 'Issue Quick Slip', ?, 'email') |
94 |
INSERT INTO letter( module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES ('circulation', 'ISSUEQSLIP', '', 'Issue Quick Slip', 0, 'Issue Quick Slip', ?, 'email') |
| 95 |
|, {}, $quick_slip_content); |
95 |
|, {}, $quick_slip_content); |
| 96 |
|
96 |
|
|
|
97 |
my $checkin_slip_content = <<EOS; |
| 98 |
Checked in today: |
| 99 |
<checkedin> |
| 100 |
Title: <<biblio.title>> |
| 101 |
Barcode: <<items.barcode>> |
| 102 |
</checkedin> |
| 103 |
EOS |
| 104 |
|
| 105 |
$dbh->do(q| |
| 106 |
INSERT INTO letter( module, code, branchcode, name, is_html, title, content, message_transport_type) VALUES ('circulation', 'CHECKINSLIP', '', 'Printed check-in slip', '0', 'Items returned today', ?, 'print') |
| 107 |
|, {}, $checkin_slip_content); |
| 108 |
|
| 97 |
my ( $title1, $title2 ) = ( 'My title 1', 'My title 2' ); |
109 |
my ( $title1, $title2 ) = ( 'My title 1', 'My title 2' ); |
| 98 |
my ( $barcode1, $barcode2 ) = ('BC0101', 'BC0202' ); |
110 |
my ( $barcode1, $barcode2 ) = ('BC0101', 'BC0202' ); |
| 99 |
my $record = MARC::Record->new; |
111 |
my $record = MARC::Record->new; |
|
Lines 128-133
$module->mock( 'userenv', sub { { branch => $branchcode } } );
Link Here
|
| 128 |
my $today = dt_from_string; |
140 |
my $today = dt_from_string; |
| 129 |
my $yesterday = dt_from_string->subtract_duration( DateTime::Duration->new( days => 1 ) ); |
141 |
my $yesterday = dt_from_string->subtract_duration( DateTime::Duration->new( days => 1 ) ); |
| 130 |
|
142 |
|
|
|
143 |
subtest 'Check-in slip' => sub { |
| 144 |
plan tests => 2; |
| 145 |
|
| 146 |
subtest 'Empty slip' => sub { |
| 147 |
plan tests => 1; |
| 148 |
|
| 149 |
my $today_daily = $today->clone->set( hour => 23, minute => 59 ); |
| 150 |
my ( $date_due, $issue_date ); |
| 151 |
$date_due = $today_daily; |
| 152 |
$issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); |
| 153 |
AddIssue( $borrower, $barcode1, $date_due, undef, $issue_date ); |
| 154 |
|
| 155 |
my $slip = CheckInSlip($borrowernumber, $branchcode ); |
| 156 |
my $empty_slip = <<EOS; |
| 157 |
Checked in today: |
| 158 |
|
| 159 |
EOS |
| 160 |
is( $slip->{content}, $empty_slip, 'No checked in returns an empty slip' ); |
| 161 |
|
| 162 |
AddReturn( $barcode1, $branchcode ); |
| 163 |
}; |
| 164 |
|
| 165 |
subtest 'Daily returns' => sub { |
| 166 |
plan tests => 3; |
| 167 |
my $slip = CheckInSlip($borrowernumber, $branchcode ); |
| 168 |
my $expected_slip = <<EOS; |
| 169 |
Checked in today: |
| 170 |
|
| 171 |
Title: $title1 |
| 172 |
Barcode: $barcode1 |
| 173 |
|
| 174 |
EOS |
| 175 |
is( $slip->{content}, $expected_slip, 'CheckInSlip should return a slip with one check-in' ); |
| 176 |
|
| 177 |
my $today_daily = $today->clone->set( hour => 23, minute => 59 ); |
| 178 |
my ( $date_due, $issue_date ); |
| 179 |
$date_due = $today_daily; |
| 180 |
$issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); |
| 181 |
AddIssue( $borrower, $barcode1, $date_due, undef, $issue_date ); |
| 182 |
AddReturn( $barcode1, $branchcode ); |
| 183 |
|
| 184 |
$slip = CheckInSlip($borrowernumber, $branchcode ); |
| 185 |
$expected_slip = <<EOS; |
| 186 |
Checked in today: |
| 187 |
|
| 188 |
Title: $title1 |
| 189 |
Barcode: $barcode1 |
| 190 |
|
| 191 |
|
| 192 |
Title: $title1 |
| 193 |
Barcode: $barcode1 |
| 194 |
|
| 195 |
EOS |
| 196 |
is( $slip->{content}, $expected_slip, 'CheckInSlip should return a slip with 2 same check-in' ); |
| 197 |
|
| 198 |
$today_daily = $today->clone->set( hour => 01, minute => 59 ); |
| 199 |
$date_due = $today_daily; |
| 200 |
$issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); |
| 201 |
AddIssue( $borrower, $barcode2, $date_due, undef, $issue_date ); |
| 202 |
AddReturn( $barcode2, $branchcode ); |
| 203 |
|
| 204 |
$slip = CheckInSlip($borrowernumber, $branchcode ); |
| 205 |
$expected_slip = <<EOS; |
| 206 |
Checked in today: |
| 207 |
|
| 208 |
Title: $title1 |
| 209 |
Barcode: $barcode1 |
| 210 |
|
| 211 |
|
| 212 |
Title: $title1 |
| 213 |
Barcode: $barcode1 |
| 214 |
|
| 215 |
|
| 216 |
Title: $title2 |
| 217 |
Barcode: $barcode2 |
| 218 |
|
| 219 |
EOS |
| 220 |
is( $slip->{content}, $expected_slip, 'CheckInSlip should return a slip with 3 check-in' ); |
| 221 |
|
| 222 |
}; |
| 223 |
|
| 224 |
}; |
| 225 |
|
| 131 |
subtest 'Issue slip' => sub { |
226 |
subtest 'Issue slip' => sub { |
| 132 |
plan tests => 3; |
227 |
plan tests => 3; |
| 133 |
|
228 |
|
| 134 |
- |
|
|