Lines 55-66
subtest 'library' => sub {
Link Here
|
55 |
}; |
55 |
}; |
56 |
|
56 |
|
57 |
subtest 'accountlines' => sub { |
57 |
subtest 'accountlines' => sub { |
58 |
plan tests => 3; |
58 |
plan tests => 5; |
59 |
|
59 |
|
60 |
$schema->storage->txn_begin; |
60 |
$schema->storage->txn_begin; |
61 |
|
61 |
|
62 |
my $register = |
62 |
my $register = |
63 |
$builder->build_object( { class => 'Koha::Cash::Registers' } ); |
63 |
$builder->build_object( { class => 'Koha::Cash::Registers' } ); |
|
|
64 |
|
65 |
my $accountlines = $register->accountlines; |
66 |
is( ref($accountlines), 'Koha::Account::Lines', |
67 |
'Koha::Cash::Register->accountlines should always return a Koha::Account::Lines set' |
68 |
); |
69 |
is( $accountlines->count, 0, |
70 |
'Koha::Cash::Register->accountlines should always return the correct number of accountlines' |
71 |
); |
72 |
|
64 |
my $accountline1 = $builder->build_object( |
73 |
my $accountline1 = $builder->build_object( |
65 |
{ |
74 |
{ |
66 |
class => 'Koha::Account::Lines', |
75 |
class => 'Koha::Account::Lines', |
Lines 74-80
subtest 'accountlines' => sub {
Link Here
|
74 |
} |
83 |
} |
75 |
); |
84 |
); |
76 |
|
85 |
|
77 |
my $accountlines = $register->accountlines; |
86 |
$accountlines = $register->accountlines; |
78 |
is( ref($accountlines), 'Koha::Account::Lines', |
87 |
is( ref($accountlines), 'Koha::Account::Lines', |
79 |
'Koha::Cash::Register->accountlines should return a set of Koha::Account::Lines' |
88 |
'Koha::Cash::Register->accountlines should return a set of Koha::Account::Lines' |
80 |
); |
89 |
); |
Lines 146-152
subtest 'branch_default' => sub {
Link Here
|
146 |
}; |
155 |
}; |
147 |
|
156 |
|
148 |
subtest 'cashup' => sub { |
157 |
subtest 'cashup' => sub { |
149 |
plan tests => 3; |
158 |
plan tests => 4; |
150 |
|
159 |
|
151 |
$schema->storage->txn_begin; |
160 |
$schema->storage->txn_begin; |
152 |
|
161 |
|
Lines 200-208
subtest 'cashup' => sub {
Link Here
|
200 |
is( $last_cashup, undef, 'undef is returned when no cashup exists' ); |
209 |
is( $last_cashup, undef, 'undef is returned when no cashup exists' ); |
201 |
}; |
210 |
}; |
202 |
|
211 |
|
203 |
subtest 'outstanding_accountlines' => sub { |
212 |
subtest 'cashups' => sub { |
204 |
plan tests => 4; |
213 |
plan tests => 4; |
205 |
|
214 |
|
|
|
215 |
my $cashups = $register->cashups; |
216 |
is( ref($cashups), 'Koha::Cash::Register::Actions', |
217 |
'Koha::Cash::Register->cashups should always return a Koha::Cash::Register::Actions set' |
218 |
); |
219 |
is( $cashups->count, 0, |
220 |
'Koha::Cash::Register->cashups should always return the correct number of cashups' |
221 |
); |
222 |
|
223 |
my $cashup3 = |
224 |
$register->add_cashup( |
225 |
{ manager_id => $patron->id, amount => '6.00' } ); |
226 |
|
227 |
$cashups = $register->cashups; |
228 |
is( ref($cashups), 'Koha::Cash::Register::Actions', |
229 |
'Koha::Cash::Register->cashups should return a Koha::Cash::Register::Actions set' |
230 |
); |
231 |
is( $cashups->count, 1, |
232 |
'Koha::Cash::Register->cashups should return the correct number of cashups' |
233 |
); |
234 |
|
235 |
$cashup3->delete; |
236 |
}; |
237 |
|
238 |
subtest 'outstanding_accountlines' => sub { |
239 |
plan tests => 6; |
240 |
|
241 |
my $accountlines = $register->outstanding_accountlines; |
242 |
is( ref($accountlines), 'Koha::Account::Lines', |
243 |
'Koha::Cash::Register->outstanding_accountlines should always return a Koha::Account::Lines set' |
244 |
); |
245 |
is( $accountlines->count, 0, |
246 |
'Koha::Cash::Register->outstanding_accountlines should always return the correct number of accountlines' |
247 |
); |
248 |
|
206 |
# add_cashup should not happen simultaneously with any other action |
249 |
# add_cashup should not happen simultaneously with any other action |
207 |
# that results in an accountline attached to the same cash register. |
250 |
# that results in an accountline attached to the same cash register. |
208 |
# In testing, we need to sleep for a second after each action that |
251 |
# In testing, we need to sleep for a second after each action that |
Lines 222-232
subtest 'cashup' => sub {
Link Here
|
222 |
); |
265 |
); |
223 |
sleep 1; |
266 |
sleep 1; |
224 |
|
267 |
|
225 |
my $accountlines = $register->outstanding_accountlines; |
268 |
$accountlines = $register->outstanding_accountlines; |
226 |
is( $accountlines->count, 2, 'No cashup, all accountlines returned' ); |
269 |
is( $accountlines->count, 2, 'No cashup, all accountlines returned' ); |
227 |
|
270 |
|
228 |
my $cashup3 = |
271 |
my $cashup3 = $register->add_cashup({manager_id => $patron->id, amount => '2.50'}); |
229 |
$register->add_cashup( { manager_id => $patron->id, amount => '2.50' } ); |
|
|
230 |
sleep 1; |
272 |
sleep 1; |
231 |
|
273 |
|
232 |
$accountlines = $register->outstanding_accountlines; |
274 |
$accountlines = $register->outstanding_accountlines; |
233 |
- |
|
|