|
Lines 19-26
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 5; |
22 |
use Test::More tests => 6; |
| 23 |
|
23 |
|
|
|
24 |
use C4::Circulation; |
| 24 |
use Koha::Patron; |
25 |
use Koha::Patron; |
| 25 |
use Koha::Patrons; |
26 |
use Koha::Patrons; |
| 26 |
use Koha::Database; |
27 |
use Koha::Database; |
|
Lines 51-56
my $new_patron_2 = Koha::Patron->new(
Link Here
|
| 51 |
} |
52 |
} |
| 52 |
)->store; |
53 |
)->store; |
| 53 |
|
54 |
|
|
|
55 |
C4::Context->_new_userenv('xxx'); |
| 56 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Midway Public Library', '', '', ''); |
| 57 |
|
| 54 |
is( Koha::Patrons->search->count, $nb_of_patrons + 2, 'The 2 patrons should have been added' ); |
58 |
is( Koha::Patrons->search->count, $nb_of_patrons + 2, 'The 2 patrons should have been added' ); |
| 55 |
|
59 |
|
| 56 |
my $retrieved_patron_1 = Koha::Patrons->find( $new_patron_1->borrowernumber ); |
60 |
my $retrieved_patron_1 = Koha::Patrons->find( $new_patron_1->borrowernumber ); |
|
Lines 98-103
subtest 'siblings' => sub {
Link Here
|
| 98 |
$retrieved_guarantee_1->delete; |
102 |
$retrieved_guarantee_1->delete; |
| 99 |
}; |
103 |
}; |
| 100 |
|
104 |
|
|
|
105 |
subtest 'has_overdues' => sub { |
| 106 |
plan tests => 3; |
| 107 |
|
| 108 |
my $biblioitem_1 = $builder->build( { source => 'Biblioitem' } ); |
| 109 |
my $item_1 = $builder->build( |
| 110 |
{ source => 'Item', |
| 111 |
value => { |
| 112 |
homebranch => $library->{branchcode}, |
| 113 |
holdingbranch => $library->{branchcode}, |
| 114 |
notforloan => 0, |
| 115 |
itemlost => 0, |
| 116 |
withdrawn => 0, |
| 117 |
biblionumber => $biblioitem_1->{biblionumber} |
| 118 |
} |
| 119 |
} |
| 120 |
); |
| 121 |
my $retrieved_patron = Koha::Patrons->find( $new_patron_1->borrowernumber ); |
| 122 |
is( $retrieved_patron->has_overdues, 0, ); |
| 123 |
|
| 124 |
my $tomorrow = DateTime->today( time_zone => C4::Context->tz() )->add( days => 1 ); |
| 125 |
my $issue = AddIssue( $new_patron_1->unblessed, $item_1->{barcode} ); |
| 126 |
is( $retrieved_patron->has_overdues, 0, ); |
| 127 |
AddReturn( $item_1->{barcode} ); |
| 128 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
| 129 |
$issue = AddIssue( $new_patron_1->unblessed, $item_1->{barcode}, $yesterday ); |
| 130 |
$retrieved_patron = Koha::Patrons->find( $new_patron_1->borrowernumber ); |
| 131 |
is( $retrieved_patron->has_overdues, 1, ); |
| 132 |
AddReturn( $item_1->{barcode} ); |
| 133 |
}; |
| 134 |
|
| 101 |
$retrieved_patron_1->delete; |
135 |
$retrieved_patron_1->delete; |
| 102 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
136 |
is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); |
| 103 |
|
137 |
|
| 104 |
- |
|
|