|
Lines 4-18
Link Here
|
| 4 |
# This needs to be extended! Your help is appreciated.. |
4 |
# This needs to be extended! Your help is appreciated.. |
| 5 |
|
5 |
|
| 6 |
use Modern::Perl; |
6 |
use Modern::Perl; |
| 7 |
use Test::More tests => 6; |
7 |
use Test::More tests => 7; |
| 8 |
|
8 |
|
| 9 |
use Koha::Database; |
|
|
| 10 |
use Koha::Patrons; |
| 11 |
use Koha::DateUtils; |
| 12 |
use t::lib::TestBuilder; |
| 13 |
use t::lib::Mocks; |
9 |
use t::lib::Mocks; |
|
|
10 |
use t::lib::TestBuilder; |
| 11 |
|
| 14 |
use C4::SIP::ILS::Patron; |
12 |
use C4::SIP::ILS::Patron; |
|
|
13 |
use Koha::Account::Lines; |
| 14 |
use Koha::Database; |
| 15 |
use Koha::DateUtils; |
| 15 |
use Koha::Patron::Attributes; |
16 |
use Koha::Patron::Attributes; |
|
|
17 |
use Koha::Patrons; |
| 16 |
|
18 |
|
| 17 |
my $schema = Koha::Database->new->schema; |
19 |
my $schema = Koha::Database->new->schema; |
| 18 |
$schema->storage->txn_begin; |
20 |
$schema->storage->txn_begin; |
|
Lines 182-185
subtest "update_lastseen tests" => sub {
Link Here
|
| 182 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({dt => dt_from_string(), dateonly => 1}),'Last seen updated to today if tracking patrons'); |
184 |
is( output_pref({str => $seen_patron->lastseen(), dateonly => 1}), output_pref({dt => dt_from_string(), dateonly => 1}),'Last seen updated to today if tracking patrons'); |
| 183 |
}; |
185 |
}; |
| 184 |
|
186 |
|
|
|
187 |
subtest "fine_items tests" => sub { |
| 188 |
|
| 189 |
plan tests => 12; |
| 190 |
|
| 191 |
my $patron = $builder->build( |
| 192 |
{ |
| 193 |
source => 'Borrower', |
| 194 |
} |
| 195 |
); |
| 196 |
|
| 197 |
my $fee1 = $builder->build( |
| 198 |
{ |
| 199 |
source => 'Accountline', |
| 200 |
value => { |
| 201 |
borrowernumber => $patron->{borrowernumber}, |
| 202 |
amountoutstanding => 1, |
| 203 |
} |
| 204 |
} |
| 205 |
); |
| 206 |
|
| 207 |
my $fee2 = $builder->build( |
| 208 |
{ |
| 209 |
source => 'Accountline', |
| 210 |
value => { |
| 211 |
borrowernumber => $patron->{borrowernumber}, |
| 212 |
amountoutstanding => 1, |
| 213 |
} |
| 214 |
} |
| 215 |
); |
| 216 |
|
| 217 |
my $sip_patron = C4::SIP::ILS::Patron->new( $patron->{cardnumber} ); |
| 218 |
|
| 219 |
my $all_fine_items = $sip_patron->fine_items; |
| 220 |
is( @$all_fine_items, 2, "Got all fine items" ); |
| 221 |
|
| 222 |
# Should return only the first fine item |
| 223 |
my $fine_items = $sip_patron->fine_items(1,1); |
| 224 |
is( @$fine_items, 1, "Got one fine item" ); |
| 225 |
is( $fine_items->[0]->{barcode}, $all_fine_items->[0]->{barcode}, "Got correct fine item"); |
| 226 |
|
| 227 |
# Should return only the second fine item |
| 228 |
$fine_items = $sip_patron->fine_items(2,2); |
| 229 |
is( @$fine_items, 1, "Got one fine item" ); |
| 230 |
is( $fine_items->[0]->{barcode}, $all_fine_items->[1]->{barcode}, "Got correct fine item"); |
| 231 |
|
| 232 |
# Should return all fine items |
| 233 |
$fine_items = $sip_patron->fine_items(1,2); |
| 234 |
is( @$fine_items, 2, "Got two fine items" ); |
| 235 |
is( $fine_items->[0]->{barcode}, $all_fine_items->[0]->{barcode}, "Got correct first fine item"); |
| 236 |
is( $fine_items->[1]->{barcode}, $all_fine_items->[1]->{barcode}, "Got correct second fine item"); |
| 237 |
|
| 238 |
# Check an invalid end boundary |
| 239 |
$fine_items = $sip_patron->fine_items(1,99); |
| 240 |
is( @$fine_items, 2, "Got two fine items" ); |
| 241 |
is( $fine_items->[0]->{barcode}, $all_fine_items->[0]->{barcode}, "Got correct first fine item"); |
| 242 |
is( $fine_items->[1]->{barcode}, $all_fine_items->[1]->{barcode}, "Got correct second fine item"); |
| 243 |
|
| 244 |
# Check an invalid start boundary |
| 245 |
$fine_items = $sip_patron->fine_items(98,99); |
| 246 |
is( @$fine_items, 0, "Got zero fine items" ); |
| 247 |
}; |
| 248 |
|
| 185 |
$schema->storage->txn_rollback; |
249 |
$schema->storage->txn_rollback; |
| 186 |
- |
|
|