Bugzilla – Attachment 76727 Details for
Bug 20978
Add Koha::Account::add_credit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20978: (QA follow-up) Do not delete existing data on tests
Bug-20978-QA-follow-up-Do-not-delete-existing-data.patch (text/plain), 4.20 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-07-06 12:19:31 UTC
(
hide
)
Description:
Bug 20978: (QA follow-up) Do not delete existing data on tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-07-06 12:19:31 UTC
Size:
4.20 KB
patch
obsolete
>From ca025ade60da7734a5abdaa13829555c5f5f0b28 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 6 Jul 2018 09:11:32 -0300 >Subject: [PATCH] Bug 20978: (QA follow-up) Do not delete existing data on > tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Account.t | 51 +++++++++++++++++++++++++++++------ > 1 file changed, 43 insertions(+), 8 deletions(-) > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >index e5cb2154b1..5d5a081589 100755 >--- a/t/db_dependent/Koha/Account.t >+++ b/t/db_dependent/Koha/Account.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 3; > > use Koha::Account; > use Koha::Account::Lines; >@@ -83,15 +83,49 @@ subtest 'outstanding_debits() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'outstanding_credits() tests' => sub { >+ >+ plan tests => 7; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $account = $patron->account; >+ >+ my @generated_lines; >+ push @generated_lines, $account->add_credit({ amount => 1 }); >+ push @generated_lines, $account->add_credit({ amount => 2 }); >+ push @generated_lines, $account->add_credit({ amount => 3 }); >+ push @generated_lines, $account->add_credit({ amount => 4 }); >+ >+ my $lines = $account->outstanding_credits(); >+ >+ is( $lines->total_outstanding, -10, 'Outstandig credits total is correctly calculated' ); >+ >+ my $i = 0; >+ foreach my $line ( @{ $lines->as_list } ) { >+ my $fetched_line = Koha::Account::Lines->find( $generated_lines[$i]->id ); >+ is_deeply( $line->unblessed, $fetched_line->unblessed, "Fetched line matches the generated one ($i)" ); >+ $i++; >+ } >+ >+ my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); >+ $lines = $patron_2->account->outstanding_credits(); >+ is( $lines->total_outstanding, 0, "Total if no outstanding credits is 0" ); >+ is( $lines->count, 0, "With no outstanding credits, we get back a Lines object with 0 lines" ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'add_credit() tests' => sub { > >- plan tests => 13; >+ plan tests => 15; > > $schema->storage->txn_begin; > > # delete logs and statistics >- $schema->resultset('ActionLog')->search()->delete(); >- $schema->resultset('Statistic')->search()->delete(); >+ my $action_logs = $schema->resultset('ActionLog')->search()->count; >+ my $statistics = $schema->resultset('Statistic')->search()->count; > > my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); > my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); >@@ -106,13 +140,14 @@ subtest 'add_credit() tests' => sub { > description => 'Payment of 25', > library_id => $patron->branchcode, > note => 'not really important', >+ type => 'payment', > user_id => $patron->id > } > ); > > is( $account->balance, -25, 'Patron has a balance of -25' ); >- is( $schema->resultset('ActionLog')->count(), 0, 'No log was added' ); >- is( $schema->resultset('Statistic')->count(), 1, 'Action added to statistics' ); >+ is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No log was added' ); >+ is( $schema->resultset('Statistic')->count(), $statistics + 1, 'Action added to statistics' ); > is( $line_1->accounttype, $Koha::Account::account_type->{'payment'}, 'Account type is correctly set' ); > > # Enable logs >@@ -130,8 +165,8 @@ subtest 'add_credit() tests' => sub { > ); > > is( $account->balance, -62, 'Patron has a balance of -25' ); >- is( $schema->resultset('ActionLog')->count(), 1, 'Log was added' ); >- is( $schema->resultset('Statistic')->count(), 2, 'Action added to statistics' ); >+ is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' ); >+ is( $schema->resultset('Statistic')->count(), $statistics + 2, 'Action added to statistics' ); > is( $line_2->accounttype, $Koha::Account::account_type->{'payment'} . $sip_code, 'Account type is correctly set' ); > > # offsets have the credit_id set to accountlines_id, and debit_id is undef >-- >2.18.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20978
:
76240
|
76241
|
76242
|
76243
|
76244
|
76245
|
76278
|
76279
|
76280
|
76319
|
76320
|
76321
|
76396
|
76397
|
76398
|
76439
|
76440
|
76441
|
76515
|
76633
|
76634
|
76635
|
76636
|
76726
|
76727
|
76733