Bugzilla – Attachment 76243 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: Unit tests
Bug-20978-Unit-tests.patch (text/plain), 3.44 KB, created by
Tomás Cohen Arazi (tcohen)
on 2018-06-21 17:16:38 UTC
(
hide
)
Description:
Bug 20978: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2018-06-21 17:16:38 UTC
Size:
3.44 KB
patch
obsolete
>From 7e3263842b408749b066292ce134fc81e6db3f9a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 21 Jun 2018 13:03:13 -0300 >Subject: [PATCH] Bug 20978: Unit tests > >This patch adds unit tests for Koha::Account::add_credit. >--- > t/db_dependent/Koha/Account.t | 86 +++++++++++++++++++++++++++++++++++ > 1 file changed, 86 insertions(+) > create mode 100755 t/db_dependent/Koha/Account.t > >diff --git a/t/db_dependent/Koha/Account.t b/t/db_dependent/Koha/Account.t >new file mode 100755 >index 0000000000..8d28375701 >--- /dev/null >+++ b/t/db_dependent/Koha/Account.t >@@ -0,0 +1,86 @@ >+#!/usr/bin/perl >+ >+# Copyright 2018 Koha Development team >+# >+# This file is part of Koha >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses> >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+ >+use Koha::Account::Lines; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'add_credit() tests' => sub { >+ >+ plan tests => 9; >+ >+ $schema->storage->txn_begin; >+ >+ # delete logs and statistics >+ $schema->resultset('ActionLog')->search()->delete(); >+ $schema->resultset('Statistic')->search()->delete(); >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); >+ >+ is( $account->balance, 0, 'Patron has no balance' ); >+ >+ # Disable logs >+ t::lib::Mocks::mock_preference( 'FinesLog', 0 ); >+ >+ my $line_1 = $account->add_credit( >+ { amount => 25, >+ description => 'Payment of 25', >+ library_id => $patron->branchcode, >+ note => 'not really important', >+ 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( $line_1->accounttype, $Koha::Account::account_type->{'payment'}, 'Account type is correctly set' ); >+ >+ # Enable logs >+ t::lib::Mocks::mock_preference( 'FinesLog', 1 ); >+ >+ my $sip_code = "1"; >+ my $line_2 = $account->add_credit( >+ { amount => 37, >+ description => 'Payment of 37', >+ library_id => $patron->branchcode, >+ note => 'not really important', >+ user_id => $patron->id, >+ sip => $sip_code >+ } >+ ); >+ >+ 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( $line_2->accounttype, $Koha::Account::account_type->{'payment'} . $sip_code, 'Account type is correctly set' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+1; >-- >2.17.1
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