Bugzilla – Attachment 58066 Details for
Bug 17702
Create configuration for account credit types
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17702: Add tests
Bug-17702-Add-tests.patch (text/plain), 4.19 KB, created by
Josef Moravec
on 2016-12-09 12:36:09 UTC
(
hide
)
Description:
Bug 17702: Add tests
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2016-12-09 12:36:09 UTC
Size:
4.19 KB
patch
obsolete
>From a9c3d45807c17ab9b00ed3706c4b7e10e38cf85b Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Fri, 2 Dec 2016 10:43:17 +0000 >Subject: [PATCH] Bug 17702: Add tests > >Test plan: > prove t/db_dependent/Koha/AccountTypes.t >--- > t/db_dependent/Koha/AccountTypes.t | 99 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 99 insertions(+) > create mode 100644 t/db_dependent/Koha/AccountTypes.t > >diff --git a/t/db_dependent/Koha/AccountTypes.t b/t/db_dependent/Koha/AccountTypes.t >new file mode 100644 >index 0000000..95bd97b >--- /dev/null >+++ b/t/db_dependent/Koha/AccountTypes.t >@@ -0,0 +1,99 @@ >+#!/usr/bin/perl >+ >+# Copyright 2016 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 => 8; >+ >+#use Koha::Account::CreditType; >+use Koha::Account::CreditTypes; >+#use Koha::Account::DebitType; >+use Koha::Account::DebitTypes; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+use Try::Tiny; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $number_of_credit_types = Koha::Account::CreditTypes->search->count; >+my $number_of_debit_types = Koha::Account::DebitTypes->search->count; >+my $new_credit_type_1 = Koha::Account::CreditType->new({ >+ type_code => '1CODE', >+ description => 'my description 1', >+ can_be_deleted => 0, >+ can_be_added_manually => 1, >+})->store; >+ >+my $new_credit_type_2 = Koha::Account::CreditType->new({ >+ type_code => '2CODE', >+ description => 'my description 2', >+ can_be_deleted => 1, >+ can_be_added_manually => 1, >+})->store; >+ >+my $new_debit_type_1 = Koha::Account::DebitType->new({ >+ type_code => '3CODE', >+ description => 'my description 3', >+ can_be_deleted => 0, >+ can_be_added_manually => 1, >+ default_amount => 0.45, >+})->store; >+ >+my $new_debit_type_2 = Koha::Account::DebitType->new({ >+ type_code => '4CODE', >+ description => 'my description 4', >+ can_be_deleted => 1, >+ can_be_added_manually => 1, >+})->store; >+ >+is( Koha::Account::CreditTypes->search->count, $number_of_credit_types + 2, 'The 2 credit types should have been added' ); >+is( Koha::Account::DebitTypes->search->count, $number_of_debit_types + 2, 'The 2 debit types should have been added' ); >+ >+my $retrieved_credit_type_1 = Koha::Account::CreditTypes->find( $new_credit_type_1->type_code ); >+is( $retrieved_credit_type_1->description, $new_credit_type_1->description, 'Find a credit type by type_code should return the correct one' ); >+ >+my $retrieved_debit_type_1 = Koha::Account::DebitTypes->find( $new_debit_type_1->type_code ); >+is( $retrieved_debit_type_1->description, $new_debit_type_1->description, 'Find a debit type by type_code should return the correct one' ); >+ >+my $retrieved_credit_type_2 = Koha::Account::CreditTypes->find( $new_credit_type_2->type_code ); >+my $retrieved_debit_type_2 = Koha::Account::DebitTypes->find( $new_debit_type_2->type_code ); >+ >+try { >+ $retrieved_credit_type_1->delete; >+} catch { >+ ok( $_->isa('Koha::Exceptions::CannotDeleteDefault'), 'The first credit type should not be deleted' ); >+}; >+$retrieved_credit_type_2->delete; >+is( Koha::Account::CreditTypes->search->count, $number_of_credit_types + 1, 'The second credit type should be deleted' ); >+ >+try { >+ $retrieved_debit_type_1->delete; >+} catch { >+ ok( $_->isa('Koha::Exceptions::CannotDeleteDefault'), 'The first debit type should not be deleted' ); >+}; >+$retrieved_debit_type_2->delete; >+is( Koha::Account::DebitTypes->search->count, $number_of_debit_types + 1, 'The second debit type should be deleted' ); >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >2.1.4
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 17702
:
57856
|
57857
|
57858
|
58066
|
85874
|
85875
|
85876
|
85877
|
98564
|
98659
|
98660
|
99306
|
99307
|
99322
|
99454