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

(-)a/t/db_dependent/Circulation.t (-19 / +24 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 120;
20
use Test::More tests => 121;
21
use Test::MockModule;
21
use Test::MockModule;
22
22
23
use Data::Dumper;
23
use Data::Dumper;
Lines 208-230 $dbh->do( Link Here
208
    .10, 1
208
    .10, 1
209
);
209
);
210
210
211
# Test C4::Circulation::ProcessOfflinePayment
212
my $sth = C4::Context->dbh->prepare("SELECT COUNT(*) FROM accountlines WHERE amount = '-123.45' AND accounttype = 'Pay'");
213
$sth->execute();
214
my ( $original_count ) = $sth->fetchrow_array();
215
216
C4::Context->dbh->do("INSERT INTO borrowers ( cardnumber, surname, firstname, categorycode, branchcode ) VALUES ( '99999999999', 'Hall', 'Kyle', ?, ? )", undef, $patron_category->{categorycode}, $library2->{branchcode} );
217
218
C4::Circulation::ProcessOfflinePayment({ cardnumber => '99999999999', amount => '123.45' });
219
220
$sth->execute();
221
my ( $new_count ) = $sth->fetchrow_array();
222
223
ok( $new_count == $original_count  + 1, 'ProcessOfflinePayment makes payment correctly' );
224
225
C4::Context->dbh->do("DELETE FROM accountlines WHERE borrowernumber IN ( SELECT borrowernumber FROM borrowers WHERE cardnumber = '99999999999' )");
226
C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'");
227
C4::Context->dbh->do("DELETE FROM accountlines");
228
{
211
{
229
# CanBookBeRenewed tests
212
# CanBookBeRenewed tests
230
    C4::Context->set_preference('ItemsDeniedRenewal','');
213
    C4::Context->set_preference('ItemsDeniedRenewal','');
Lines 2835-2840 subtest 'AddRenewal and AddIssuingCharge tests' => sub { Link Here
2835
    $schema->storage->txn_rollback;
2818
    $schema->storage->txn_rollback;
2836
};
2819
};
2837
2820
2821
subtest 'ProcessOfflinePayment() tests' => sub {
2822
2823
    plan tests => 4;
2824
2825
    $schema->storage->txn_begin;
2826
2827
    my $amount = 123;
2828
2829
    my $patron  = $builder->build_object({ class => 'Koha::Patrons' });
2830
    my $library = $builder->build_object({ class => 'Koha::Libraries' });
2831
    my $result  = C4::Circulation::ProcessOfflinePayment({ cardnumber => $patron->cardnumber, amount => $amount, branchcode => $library->id });
2832
2833
    is( $result, 'Success.', 'The right string is returned' );
2834
2835
    my $lines = $patron->account->lines;
2836
    is( $lines->count, 1, 'line created correctly');
2837
2838
    my $line = $lines->next;
2839
    is( $line->amount+0, $amount * -1, 'amount picked from params' );
2840
    is( $line->branchcode, $library->id, 'branchcode set correctly' );
2841
2842
    $schema->storage->txn_rollback;
2843
};
2838
2844
2839
sub set_userenv {
2845
sub set_userenv {
2840
    my ( $library ) = @_;
2846
    my ( $library ) = @_;
2841
- 

Return to bug 21788