Bugzilla – Attachment 70156 Details for
Bug 19826
Introduce Koha::Acquisition::Budget(s) and Koha::Acquisition::Fund(s)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19826: Add tests
Bug-19826-Add-tests.patch (text/plain), 4.99 KB, created by
Jonathan Druart
on 2017-12-26 15:34:54 UTC
(
hide
)
Description:
Bug 19826: Add tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-12-26 15:34:54 UTC
Size:
4.99 KB
patch
obsolete
>From 17abed13e4868ef6cc78516dfc390c578da44de1 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 26 Dec 2017 12:33:39 -0300 >Subject: [PATCH] Bug 19826: Add tests > >--- > Koha/Acquisition/Budgets.pm | 2 ++ > t/db_dependent/Koha/Acquisition/Budgets.t | 54 +++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Acquisition/Funds.t | 49 ++++++++++++++++++++++++++++ > 3 files changed, 105 insertions(+) > create mode 100644 t/db_dependent/Koha/Acquisition/Budgets.t > create mode 100644 t/db_dependent/Koha/Acquisition/Funds.t > >diff --git a/Koha/Acquisition/Budgets.pm b/Koha/Acquisition/Budgets.pm >index e9cae2227b..2a50f1d9bb 100644 >--- a/Koha/Acquisition/Budgets.pm >+++ b/Koha/Acquisition/Budgets.pm >@@ -19,6 +19,8 @@ use Modern::Perl; > > use Koha::Database; > >+use Koha::Acquisition::Budget; >+ > use base qw(Koha::Objects); > > =head1 NAME >diff --git a/t/db_dependent/Koha/Acquisition/Budgets.t b/t/db_dependent/Koha/Acquisition/Budgets.t >new file mode 100644 >index 0000000000..e5aedefdad >--- /dev/null >+++ b/t/db_dependent/Koha/Acquisition/Budgets.t >@@ -0,0 +1,54 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 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 => 4; >+ >+use Koha::Acquisition::Budgets; >+use Koha::Database; >+use Koha::DateUtils qw( dt_from_string ); >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $nb_of_budgets= Koha::Acquisition::Budgets->search->count; >+my $now = dt_from_string; >+my $new_budget = Koha::Acquisition::Budget->new({ >+ budget_period_startdate => $now, >+ budget_period_enddate => $now, >+ budget_period_active => 1, >+ budget_period_description => 'a new budget', >+ budget_period_total => 1000, >+})->store; >+ >+like( $new_budget->budget_period_id, qr|^\d+$|, 'Adding a new budget should have set the budget_period_id'); >+is( Koha::Acquisition::Budgets->search->count, $nb_of_budgets + 1, 'The budget should have been added' ); >+ >+my $retrieved_budget = Koha::Acquisition::Budgets->find( $new_budget->budget_period_id); >+is( $retrieved_budget->budget_period_description, $new_budget->budget_period_description, 'Find a budget by budget_period_id should return the correct budget' ); >+ >+$retrieved_budget->delete; >+is( Koha::Acquisition::Budgets->search->count, $nb_of_budgets, 'Delete should have deleted the budget' ); >+ >+$schema->storage->txn_rollback; >+ >diff --git a/t/db_dependent/Koha/Acquisition/Funds.t b/t/db_dependent/Koha/Acquisition/Funds.t >new file mode 100644 >index 0000000000..a4ce604e6d >--- /dev/null >+++ b/t/db_dependent/Koha/Acquisition/Funds.t >@@ -0,0 +1,49 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 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 => 4; >+ >+use Koha::Acquisition::Funds; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $nb_of_funds = Koha::Acquisition::Funds->search->count; >+my $new_fund = Koha::Acquisition::Fund->new({ >+ budget_code => 'my_budget_code_for_test', >+ budget_name => 'my_budget_name_for_test', >+})->store; >+ >+like( $new_fund_1->budget_id, qr|^\d+$|, 'Adding a new fund should have set the budget_id'); >+is( Koha::Acquisition::Funds->search->count, $nb_of_funds + 1, 'The fund should have been added' ); >+ >+my $retrieved_fund_1 = Koha::Acquisition::Funds->find( $new_fund_1->budget_id ); >+is( $retrieved_fund_1->fund_name, $new_fund_1->fund_name, 'Find a fund by budget_id should return the correct fund' ); >+ >+$retrieved_fund_1->delete; >+is( Koha::Acquisition::Funds->search->count, $nb_of_funds + 1, 'Delete should have deleted the fund' ); >+ >+$schema->storage->txn_rollback; >+ >-- >2.11.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 19826
:
69848
|
69849
|
69891
|
69918
|
69919
|
70063
|
70064
|
70119
|
70120
|
70156
|
70157