Lines 19-28
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 9; |
22 |
use Test::More tests => 10; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
25 |
use C4::Circulation; |
25 |
use C4::Circulation; |
|
|
26 |
use Koha::AuthorisedValues; |
27 |
use Koha::AuthorisedValueCategories; |
26 |
use Koha::Checkouts; |
28 |
use Koha::Checkouts; |
27 |
use Koha::Database; |
29 |
use Koha::Database; |
28 |
use Koha::DateUtils qw( dt_from_string ); |
30 |
use Koha::DateUtils qw( dt_from_string ); |
Lines 141-146
subtest 'patron' => sub {
Link Here
|
141 |
); |
143 |
); |
142 |
}; |
144 |
}; |
143 |
|
145 |
|
|
|
146 |
subtest 'store' => sub { |
147 |
plan tests => 1; |
148 |
|
149 |
subtest 'validate checkout_type' => sub { |
150 |
plan tests => 3; |
151 |
|
152 |
# This should exist on clean installations, but just make sure... |
153 |
unless ( Koha::AuthorisedValueCategories->search( { |
154 |
category_name => 'CHECKOUT_TYPE' |
155 |
} )->count ) { |
156 |
$builder->build_object( { |
157 |
class=> 'Koha::AuthorisedValueCategories', |
158 |
value => { category_name => 'CHECKOUT_TYPE' } |
159 |
} ); |
160 |
} |
161 |
|
162 |
my $av = $builder->build_object( { |
163 |
class=> 'Koha::AuthorisedValues', |
164 |
value => { category => 'CHECKOUT_TYPE' } |
165 |
} ); |
166 |
|
167 |
my $patron = $builder->build_object( { |
168 |
class=> 'Koha::Patrons', |
169 |
value => { branchcode => $library->{branchcode} } |
170 |
} ); |
171 |
my $item = $builder->build_object( { class=> 'Koha::Items' } ); |
172 |
my $checkout = Koha::Checkout->new( |
173 |
{ borrowernumber => $patron->borrowernumber, |
174 |
itemnumber => $item->itemnumber, |
175 |
branchcode => $library->{branchcode}, |
176 |
} |
177 |
)->store; |
178 |
|
179 |
ok( $checkout->issue_id > 0, |
180 |
'store() was successful with undef checkout_type' ); |
181 |
|
182 |
$checkout->set({ checkout_type => $av->authorised_value })->store; |
183 |
is( $checkout->checkout_type, $av->authorised_value, |
184 |
'store() was successful with a valid checkout_type' ); |
185 |
|
186 |
throws_ok { |
187 |
$checkout->set({ checkout_type => 'NON_EXISTENT' })->store |
188 |
} 'Koha::Exceptions::Object::FKConstraint', |
189 |
'store() throws an exception with an invalid checkout_type'; |
190 |
|
191 |
$checkout->delete; |
192 |
}; |
193 |
}; |
194 |
|
144 |
$retrieved_checkout_1->delete; |
195 |
$retrieved_checkout_1->delete; |
145 |
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); |
196 |
is( Koha::Checkouts->search->count, $nb_of_checkouts + 1, 'Delete should have deleted the checkout' ); |
146 |
|
197 |
|
147 |
- |
|
|