|
Lines 2-8
Link Here
|
| 2 |
|
2 |
|
| 3 |
use Modern::Perl; |
3 |
use Modern::Perl; |
| 4 |
|
4 |
|
| 5 |
use Test::More tests => 3; |
5 |
use Test::More tests => 4; |
| 6 |
use Test::MockModule; |
6 |
use Test::MockModule; |
| 7 |
|
7 |
|
| 8 |
use C4::Biblio; |
8 |
use C4::Biblio; |
|
Lines 74-79
$dbh->do(q|
Link Here
|
| 74 |
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') |
74 |
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') |
| 75 |
|, {}, $quick_slip_content); |
75 |
|, {}, $quick_slip_content); |
| 76 |
|
76 |
|
|
|
77 |
my $checkin_slip_content = <<EOS; |
| 78 |
Checked in today: |
| 79 |
<checkedin> |
| 80 |
Title: <<biblio.title>> |
| 81 |
Barcode: <<items.barcode>> |
| 82 |
</checkedin> |
| 83 |
EOS |
| 84 |
|
| 85 |
$dbh->do(q| |
| 86 |
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') |
| 87 |
|, {}, $checkin_slip_content); |
| 88 |
|
| 77 |
my ( $title1, $title2 ) = ( 'My title 1', 'My title 2' ); |
89 |
my ( $title1, $title2 ) = ( 'My title 1', 'My title 2' ); |
| 78 |
my ( $barcode1, $barcode2 ) = ('BC0101', 'BC0202' ); |
90 |
my ( $barcode1, $barcode2 ) = ('BC0101', 'BC0202' ); |
| 79 |
my $record = MARC::Record->new; |
91 |
my $record = MARC::Record->new; |
|
Lines 108-113
$module->mock( 'userenv', sub { { branch => $branchcode } } );
Link Here
|
| 108 |
my $today = dt_from_string; |
120 |
my $today = dt_from_string; |
| 109 |
my $yesterday = dt_from_string->subtract_duration( DateTime::Duration->new( days => 1 ) ); |
121 |
my $yesterday = dt_from_string->subtract_duration( DateTime::Duration->new( days => 1 ) ); |
| 110 |
|
122 |
|
|
|
123 |
subtest 'Check-in slip' => sub { |
| 124 |
plan tests => 2; |
| 125 |
|
| 126 |
subtest 'Empty slip' => sub { |
| 127 |
plan tests => 1; |
| 128 |
|
| 129 |
my $today_daily = $today->clone->set( hour => 23, minute => 59 ); |
| 130 |
my ( $date_due, $issue_date ); |
| 131 |
$date_due = $today_daily; |
| 132 |
$issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); |
| 133 |
AddIssue( $borrower, $barcode1, $date_due, undef, $issue_date ); |
| 134 |
|
| 135 |
my $slip = CheckInSlip($borrowernumber, $branchcode ); |
| 136 |
my $empty_slip = <<EOS; |
| 137 |
Checked in today: |
| 138 |
|
| 139 |
EOS |
| 140 |
is( $slip->{content}, $empty_slip, 'No checked in returns an empty slip' ); |
| 141 |
|
| 142 |
AddReturn( $barcode1, $branchcode ); |
| 143 |
}; |
| 144 |
|
| 145 |
subtest 'Daily returns' => sub { |
| 146 |
plan tests => 3; |
| 147 |
my $slip = CheckInSlip($borrowernumber, $branchcode ); |
| 148 |
my $expected_slip = <<EOS; |
| 149 |
Checked in today: |
| 150 |
|
| 151 |
Title: $title1 |
| 152 |
Barcode: $barcode1 |
| 153 |
|
| 154 |
EOS |
| 155 |
is( $slip->{content}, $expected_slip, 'CheckInSlip should return a slip with one check-in' ); |
| 156 |
|
| 157 |
my $today_daily = $today->clone->set( hour => 23, minute => 59 ); |
| 158 |
my ( $date_due, $issue_date ); |
| 159 |
$date_due = $today_daily; |
| 160 |
$issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); |
| 161 |
AddIssue( $borrower, $barcode1, $date_due, undef, $issue_date ); |
| 162 |
AddReturn( $barcode1, $branchcode ); |
| 163 |
|
| 164 |
my $slip = CheckInSlip($borrowernumber, $branchcode ); |
| 165 |
my $expected_slip = <<EOS; |
| 166 |
Checked in today: |
| 167 |
|
| 168 |
Title: $title1 |
| 169 |
Barcode: $barcode1 |
| 170 |
|
| 171 |
|
| 172 |
Title: $title1 |
| 173 |
Barcode: $barcode1 |
| 174 |
|
| 175 |
EOS |
| 176 |
is( $slip->{content}, $expected_slip, 'CheckInSlip should return a slip with 2 same check-in' ); |
| 177 |
|
| 178 |
my $today_daily = $today->clone->set( hour => 01, minute => 59 ); |
| 179 |
my ( $date_due, $issue_date ); |
| 180 |
$date_due = $today_daily; |
| 181 |
$issue_date = $today_daily->clone->subtract_duration( DateTime::Duration->new( minutes => 1 ) ); |
| 182 |
AddIssue( $borrower, $barcode2, $date_due, undef, $issue_date ); |
| 183 |
AddReturn( $barcode2, $branchcode ); |
| 184 |
|
| 185 |
my $slip = CheckInSlip($borrowernumber, $branchcode ); |
| 186 |
my $expected_slip = <<EOS; |
| 187 |
Checked in today: |
| 188 |
|
| 189 |
Title: $title1 |
| 190 |
Barcode: $barcode1 |
| 191 |
|
| 192 |
|
| 193 |
Title: $title1 |
| 194 |
Barcode: $barcode1 |
| 195 |
|
| 196 |
|
| 197 |
Title: $title2 |
| 198 |
Barcode: $barcode2 |
| 199 |
|
| 200 |
EOS |
| 201 |
is( $slip->{content}, $expected_slip, 'CheckInSlip should return a slip with 3 check-in' ); |
| 202 |
|
| 203 |
}; |
| 204 |
|
| 205 |
}; |
| 206 |
|
| 111 |
subtest 'Issue slip' => sub { |
207 |
subtest 'Issue slip' => sub { |
| 112 |
plan tests => 3; |
208 |
plan tests => 3; |
| 113 |
|
209 |
|
| 114 |
- |
|
|