Bugzilla – Attachment 94336 Details for
Bug 23049
Replace MANUAL_INV authorised value with a dedicated table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23049: Add tests
Bug-23049-Add-tests.patch (text/plain), 6.33 KB, created by
Martin Renvoize (ashimema)
on 2019-10-16 18:07:20 UTC
(
hide
)
Description:
Bug 23049: Add tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2019-10-16 18:07:20 UTC
Size:
6.33 KB
patch
obsolete
>From 3bf84fba99beb1d8e29da0607cdad6492d87d7cd Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 10 Oct 2019 17:14:47 +0100 >Subject: [PATCH] Bug 23049: Add tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Test plan: > prove t/db_dependent/Koha/Account/DebitType.t > prove t/db_dependent/Koha/Account/DebitTypes.t > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > t/db_dependent/Koha/Account/DebitType.t | 95 ++++++++++++++++++++++++ > t/db_dependent/Koha/Account/DebitTypes.t | 84 +++++++++++++++++++++ > 2 files changed, 179 insertions(+) > create mode 100644 t/db_dependent/Koha/Account/DebitType.t > create mode 100644 t/db_dependent/Koha/Account/DebitTypes.t > >diff --git a/t/db_dependent/Koha/Account/DebitType.t b/t/db_dependent/Koha/Account/DebitType.t >new file mode 100644 >index 0000000000..366a37319c >--- /dev/null >+++ b/t/db_dependent/Koha/Account/DebitType.t >@@ -0,0 +1,95 @@ >+#!/usr/bin/perl >+ >+# Copyright 2019 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 => 7; >+ >+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_debit_types = Koha::Account::DebitTypes->search->count; >+ >+my $new_debit_type_1 = Koha::Account::DebitType->new( >+ { >+ code => '3CODE', >+ description => 'my description 3', >+ can_be_added_manually => 1, >+ default_amount => 0.45, >+ } >+)->store; >+ >+my $new_debit_type_2 = Koha::Account::DebitType->new( >+ { >+ code => '4CODE', >+ description => 'my description 4', >+ can_be_added_manually => 1, >+ } >+)->store; >+ >+is( >+ Koha::Account::DebitTypes->search->count, >+ $number_of_debit_types + 2, >+ '2 debit types added successfully' >+); >+ >+my $retrieved_debit_type_1 = >+ Koha::Account::DebitTypes->find( $new_debit_type_1->code ); >+is( >+ $retrieved_debit_type_1->description, >+ $new_debit_type_1->description, >+ 'Find a debit type by code should return the correct one (non-system)' >+); >+ok( !$retrieved_debit_type_1->is_system, >+ 'Non-system debit type identified correctly by "is_system"' ); >+ >+my $retrieved_debit_type_system = Koha::Account::DebitTypes->find('OVERDUE'); >+is( $retrieved_debit_type_system->code, >+ 'OVERDUE', >+ 'Find a debit type by code should return the correct one (system)' ); >+ok( $retrieved_debit_type_system->is_system, >+ 'System debit type identified correctly by "is_system"' ); >+ >+try { >+ $retrieved_debit_type_system->delete; >+} >+catch { >+ ok( >+ $_->isa('Koha::Exceptions::CannotDeleteDefault'), >+ 'A system debit type cannot be deleted' >+ ); >+}; >+$retrieved_debit_type_1->delete; >+is( >+ Koha::Account::DebitTypes->search->count, >+ $number_of_debit_types + 1, >+ 'A non-system debit type can be deleted' >+); >+ >+$schema->storage->txn_rollback; >+ >+1; >diff --git a/t/db_dependent/Koha/Account/DebitTypes.t b/t/db_dependent/Koha/Account/DebitTypes.t >new file mode 100644 >index 0000000000..fee8eadb04 >--- /dev/null >+++ b/t/db_dependent/Koha/Account/DebitTypes.t >@@ -0,0 +1,84 @@ >+#!/usr/bin/perl >+ >+# Copyright 2019 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 => 3; >+ >+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_debit_types = Koha::Account::DebitTypes->search->count; >+ >+my $new_debit_type_1 = Koha::Account::DebitType->new( >+ { >+ code => '3CODE', >+ description => 'my description 3', >+ can_be_added_manually => 1, >+ default_amount => 0.45, >+ } >+)->store; >+ >+my $new_debit_type_2 = Koha::Account::DebitType->new( >+ { >+ code => '4CODE', >+ description => 'my description 4', >+ can_be_added_manually => 1, >+ } >+)->store; >+ >+my $defaults = Koha::Account::DebitType::defaults; >+my $number_of_system_types = scalar @{$defaults}; >+my $retrieved_debit_types_all = Koha::Account::DebitTypes->search(); >+try { >+ $retrieved_debit_types_all->delete; >+} >+catch { >+ ok( >+ $_->isa('Koha::Exceptions::CannotDeleteDefault'), >+ 'A system debit type cannot be deleted via the set' >+ ); >+}; >+is( >+ Koha::Account::DebitTypes->search->count, >+ $number_of_debit_types + 2, >+ 'System debit types cannot be deleted as a set' >+); >+ >+my $retrieved_debit_types_limited = Koha::Account::DebitTypes->search( >+ { >+ code => { 'in' => [ $new_debit_type_1->code, $new_debit_type_2->code ] } >+ } >+); >+$retrieved_debit_types_limited->delete; >+is( Koha::Account::DebitTypes->search->count, >+ $number_of_debit_types, 'Non-system debit types can be deleted as a set' ); >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >2.20.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 23049
:
93513
|
93514
|
93515
|
93516
|
93518
|
93519
|
93520
|
93521
|
93522
|
93523
|
93529
|
93557
|
93564
|
93565
|
93567
|
93568
|
93569
|
93570
|
93571
|
93572
|
93573
|
93574
|
93575
|
93576
|
93577
|
93578
|
93579
|
93960
|
93961
|
93962
|
93963
|
93964
|
93965
|
93966
|
93967
|
93968
|
93969
|
93970
|
93972
|
93973
|
93974
|
93975
|
93976
|
93977
|
93978
|
93979
|
93989
|
93990
|
93991
|
93992
|
93993
|
93994
|
93995
|
93996
|
93997
|
93998
|
93999
|
94000
|
94001
|
94002
|
94003
|
94004
|
94005
|
94006
|
94007
|
94008
|
94073
|
94074
|
94075
|
94076
|
94077
|
94078
|
94079
|
94080
|
94081
|
94082
|
94083
|
94084
|
94085
|
94086
|
94087
|
94088
|
94089
|
94090
|
94091
|
94092
|
94093
|
94111
|
94112
|
94113
|
94114
|
94115
|
94116
|
94117
|
94118
|
94119
|
94120
|
94121
|
94122
|
94123
|
94124
|
94125
|
94126
|
94127
|
94128
|
94129
|
94130
|
94131
|
94132
|
94133
|
94134
|
94135
|
94136
|
94137
|
94138
|
94139
|
94140
|
94141
|
94142
|
94143
|
94144
|
94145
|
94146
|
94147
|
94148
|
94149
|
94150
|
94151
|
94152
|
94165
|
94307
|
94308
|
94309
|
94310
|
94311
|
94312
|
94313
|
94314
|
94315
|
94316
|
94317
|
94318
|
94319
|
94320
|
94321
|
94323
|
94324
|
94325
|
94326
|
94327
|
94328
|
94329
|
94331
|
94332
|
94333
|
94334
|
94335
|
94336
|
94337
|
94338
|
94339
|
94340
|
94341
|
94342
|
94343
|
94344
|
94345
|
94346
|
94347
|
94348
|
94349
|
94350
|
94351
|
94352
|
94648