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

(-)a/t/db_dependent/Koha/ArticleRequest.t (-5 / +27 lines)
Lines 156-174 subtest 'complete() tests' => sub { Link Here
156
156
157
subtest 'cancel() tests' => sub {
157
subtest 'cancel() tests' => sub {
158
158
159
    plan tests => 4;
159
    plan tests => 11;
160
160
161
    $schema->storage->txn_begin;
161
    $schema->storage->txn_begin;
162
162
163
    my $amount = 11;
164
165
    my $patron_mock = Test::MockModule->new('Koha::Patron');
166
    $patron_mock->mock( 'article_request_fee', sub { return $amount; } );
167
168
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
169
    my $item   = $builder->build_sample_item;
170
163
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
171
    my $ar_mock = Test::MockModule->new('Koha::ArticleRequest');
164
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
172
    $ar_mock->mock( 'notify', sub { ok( 1, '->notify() called' ); } );
165
173
166
    my $ar = $builder->build_object(
174
    my $ar = Koha::ArticleRequest->new(
167
        {   class => 'Koha::ArticleRequests',
175
        {
168
            value => { status => Koha::ArticleRequest::Status::Requested }
176
            borrowernumber => $patron->id,
177
            biblionumber   => $item->biblionumber,
178
            itemnumber     => $item->id,
169
        }
179
        }
170
    );
180
    );
171
181
182
    $ar->request()->discard_changes;
183
184
    is( $ar->status, Koha::ArticleRequest::Status::Requested );
185
    is( $ar->itemnumber, $item->id, 'itemnumber set' );
186
    ok( defined $ar->debit_id, 'Fee linked' );
187
    is( $patron->account->balance, $amount, 'Outstanding fees with the right value' );
188
189
    my $payed_amount = 5;
190
    $patron->account->pay({ amount => $payed_amount, interface => 'intranet', lines => [ $ar->debit ] });
191
    is( $patron->account->balance, $amount - $payed_amount, 'Outstanding fees with the right value' );
192
172
    my $reason = "Hey, ho";
193
    my $reason = "Hey, ho";
173
    my $notes  = "Let's go!";
194
    my $notes  = "Let's go!";
174
195
Lines 178-182 subtest 'cancel() tests' => sub { Link Here
178
    is( $ar->cancellation_reason, $reason, 'Cancellation reason stored correctly' );
199
    is( $ar->cancellation_reason, $reason, 'Cancellation reason stored correctly' );
179
    is( $ar->notes, $notes, 'Notes stored correctly' );
200
    is( $ar->notes, $notes, 'Notes stored correctly' );
180
201
202
    is( abs $patron->account->balance, $payed_amount, 'The patron has been refunded the right value' );
203
181
    $schema->storage->txn_rollback;
204
    $schema->storage->txn_rollback;
182
};
205
};
183
- 

Return to bug 29759