|
Lines 21-26
use Modern::Perl;
Link Here
|
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 7; |
| 23 |
|
23 |
|
|
|
24 |
use C4::Circulation; |
| 24 |
use Koha::Checkouts; |
25 |
use Koha::Checkouts; |
| 25 |
use Koha::Database; |
26 |
use Koha::Database; |
| 26 |
use Koha::DateUtils qw( dt_from_string ); |
27 |
use Koha::DateUtils qw( dt_from_string ); |
|
Lines 94-103
subtest 'item' => sub {
Link Here
|
| 94 |
}; |
95 |
}; |
| 95 |
|
96 |
|
| 96 |
subtest 'patron' => sub { |
97 |
subtest 'patron' => sub { |
| 97 |
plan tests => 2; |
98 |
plan tests => 3; |
| 98 |
my $p = $new_checkout_1->patron; |
99 |
my $patron = $builder->build_object({class=>'Koha::Patrons', value => {branchcode => $library->{branchcode}}}); |
| 99 |
is( ref($p), 'Koha::Patron', 'Koha::Checkout->patron should return a Koha::Patron' ); |
100 |
|
| 100 |
is( $p->borrowernumber, $patron->{borrowernumber}, 'Koha::Checkout->patron should return the correct patron' ); |
101 |
my $item = $builder->build_object( { class=> 'Koha::Items' } ); |
|
|
102 |
my $checkout = Koha::Checkout->new( |
| 103 |
{ borrowernumber => $patron->borrowernumber, |
| 104 |
itemnumber => $item->itemnumber, |
| 105 |
branchcode => $library->{branchcode}, |
| 106 |
} |
| 107 |
)->store; |
| 108 |
|
| 109 |
my $p = $checkout->patron; |
| 110 |
is( ref($p), 'Koha::Patron', |
| 111 |
'Koha::Checkout->patron should return a Koha::Patron' ); |
| 112 |
is( $p->borrowernumber, $patron->borrowernumber, |
| 113 |
'Koha::Checkout->patron should return the correct patron' ); |
| 114 |
|
| 115 |
# Testing Koha::Old::Checkout->patron now |
| 116 |
my $issue_id = $checkout->issue_id; |
| 117 |
C4::Circulation::MarkIssueReturned( $p->borrowernumber, $checkout->itemnumber ); |
| 118 |
$p->delete; |
| 119 |
my $old_issue = Koha::Old::Checkouts->find($issue_id); |
| 120 |
is( $old_issue->patron, undef, |
| 121 |
'Koha::Checkout->patron should return undef if the patron record has been deleted' |
| 122 |
); |
| 101 |
}; |
123 |
}; |
| 102 |
|
124 |
|
| 103 |
$retrieved_checkout_1->delete; |
125 |
$retrieved_checkout_1->delete; |
| 104 |
- |
|
|