View | Details | Raw Unified | Return to bug 24815
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Cash/Register.t (-6 / +52 lines)
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( { manager_id => $patron->id, amount => '6.00' } );
225
226
        $cashups = $register->cashups;
227
        is( ref($cashups), 'Koha::Cash::Register::Actions',
228
'Koha::Cash::Register->cashups should return a Koha::Cash::Register::Actions set'
229
        );
230
        is( $cashups->count, 1,
231
'Koha::Cash::Register->cashups should return the correct number of cashups'
232
        );
233
234
        $cashup3->delete;
235
    };
236
237
    subtest 'outstanding_accountlines' => sub {
238
        plan tests => 6;
239
240
        my $accountlines = $register->outstanding_accountlines;
241
        is( ref($accountlines), 'Koha::Account::Lines',
242
'Koha::Cash::Register->outstanding_accountlines should always return a Koha::Account::Lines set'
243
        );
244
        is( $accountlines->count, 0,
245
'Koha::Cash::Register->outstanding_accountlines should always return the correct number of accountlines'
246
        );
247
248
        # add_cashup should not happen simultaneously with any other action
249
        # that results in an accountline attached to the same cash register.
250
        # In testing, we need to sleep for a second after each action that
251
        # adds to the database. (We cannot use Time::Fake as timestamps are
252
        # being added at the DB level, not in perl.
206
        my $accountline1 = $builder->build_object(
253
        my $accountline1 = $builder->build_object(
207
            {
254
            {
208
                class => 'Koha::Account::Lines',
255
                class => 'Koha::Account::Lines',
Lines 216-222 subtest 'cashup' => sub { Link Here
216
            }
263
            }
217
        );
264
        );
218
265
219
        my $accountlines = $register->outstanding_accountlines;
266
        $accountlines = $register->outstanding_accountlines;
220
        is( $accountlines->count, 2, 'No cashup, all accountlines returned' );
267
        is( $accountlines->count, 2, 'No cashup, all accountlines returned' );
221
268
222
        my $cashup3 =
269
        my $cashup3 =
223
- 

Return to bug 24815