|
Lines 19-27
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 7; |
22 |
use Test::More tests => 8; |
|
|
23 |
use Test::Exception; |
| 23 |
|
24 |
|
| 24 |
use C4::Circulation; |
25 |
use C4::Circulation; |
|
|
26 |
use Koha::AuthorisedValues; |
| 27 |
use Koha::AuthorisedValueCategories; |
| 25 |
use Koha::Checkouts; |
28 |
use Koha::Checkouts; |
| 26 |
use Koha::Database; |
29 |
use Koha::Database; |
| 27 |
use Koha::DateUtils qw( dt_from_string ); |
30 |
use Koha::DateUtils qw( dt_from_string ); |
|
Lines 122-127
subtest 'patron' => sub {
Link Here
|
| 122 |
); |
125 |
); |
| 123 |
}; |
126 |
}; |
| 124 |
|
127 |
|
|
|
128 |
subtest 'store' => sub { |
| 129 |
plan tests => 1; |
| 130 |
|
| 131 |
subtest 'validate checkout_type' => sub { |
| 132 |
plan tests => 3; |
| 133 |
|
| 134 |
# This should exist on clean installations, but just make sure... |
| 135 |
unless ( Koha::AuthorisedValueCategories->search( { |
| 136 |
category_name => 'CHECKOUT_TYPE' |
| 137 |
} )->count ) { |
| 138 |
$builder->build_object( { |
| 139 |
class=> 'Koha::AuthorisedValueCategories', |
| 140 |
value => { category_name => 'CHECKOUT_TYPE' } |
| 141 |
} ); |
| 142 |
} |
| 143 |
|
| 144 |
my $av = $builder->build_object( { |
| 145 |
class=> 'Koha::AuthorisedValues', |
| 146 |
value => { category => 'CHECKOUT_TYPE' } |
| 147 |
} ); |
| 148 |
|
| 149 |
my $patron = $builder->build_object( { |
| 150 |
class=> 'Koha::Patrons', |
| 151 |
value => { branchcode => $library->{branchcode} } |
| 152 |
} ); |
| 153 |
my $item = $builder->build_object( { class=> 'Koha::Items' } ); |
| 154 |
my $checkout = Koha::Checkout->new( |
| 155 |
{ borrowernumber => $patron->borrowernumber, |
| 156 |
itemnumber => $item->itemnumber, |
| 157 |
branchcode => $library->{branchcode}, |
| 158 |
} |
| 159 |
)->store; |
| 160 |
|
| 161 |
ok( $checkout->issue_id > 0, |
| 162 |
'store() was successful with undef checkout_type' ); |
| 163 |
|
| 164 |
$checkout->set({ checkout_type => $av->authorised_value })->store; |
| 165 |
is( $checkout->checkout_type, $av->authorised_value, |
| 166 |
'store() was successful with a valid checkout_type' ); |
| 167 |
|
| 168 |
throws_ok { |
| 169 |
$checkout->set({ checkout_type => 'NON_EXISTENT' })->store |
| 170 |
} 'Koha::Exceptions::Object::FKConstraint', |
| 171 |
'store() throws an exception with an invalid checkout_type'; |
| 172 |
|
| 173 |
$checkout->delete; |
| 174 |
}; |
| 175 |
}; |
| 176 |
|
| 125 |
$retrieved_checkout_1->delete; |
177 |
$retrieved_checkout_1->delete; |
| 126 |
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); |
178 |
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); |
| 127 |
|
179 |
|
| 128 |
- |
|
|