From c3dfa98d30205dd4206b7323912ea74ee3072c1d Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Sun, 30 Jul 2017 16:53:00 +0200 Subject: [PATCH] Bug 19004: Patrons.t should create its own data for enrollment fees. Content-Type: text/plain; charset=utf-8 If the patron categories J, K, YA would not exist, Patrons.t would fail. Test plan: [1] Remove one of these patron categories. [2] Run t/db_dependent/Koha/Patrons.t Signed-off-by: Marcel de Rooy --- t/db_dependent/Koha/Patrons.t | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t index 84c46ca..79c2231 100644 --- a/t/db_dependent/Koha/Patrons.t +++ b/t/db_dependent/Koha/Patrons.t @@ -32,6 +32,7 @@ use C4::Circulation; use Koha::Holds; use Koha::Patron; use Koha::Patrons; +use Koha::Patron::Categories; use Koha::Database; use Koha::DateUtils; use Koha::Virtualshelves; @@ -375,14 +376,13 @@ subtest "delete" => sub { subtest 'add_enrolment_fee_if_needed' => sub { plan tests => 4; - my $enrolmentfee_K = 5; - my $enrolmentfee_J = 10; - my $enrolmentfee_YA = 20; - - my $dbh = C4::Context->dbh; - $dbh->do(q|UPDATE categories set enrolmentfee=? where categorycode=?|, undef, $enrolmentfee_K, 'K'); - $dbh->do(q|UPDATE categories set enrolmentfee=? where categorycode=?|, undef, $enrolmentfee_J, 'J'); - $dbh->do(q|UPDATE categories set enrolmentfee=? where categorycode=?|, undef, $enrolmentfee_YA, 'YA'); + my $enrolmentfees = { K => 5, J => 10, YA => 20 }; + foreach( keys %{$enrolmentfees} ) { + ( Koha::Patron::Categories->find( $_ ) // $builder->build_object({ class => 'Koha::Patron::Categories', value => { categorycode => $_ } }) )->enrolmentfee( $enrolmentfees->{$_} )->store; + } + my $enrolmentfee_K = $enrolmentfees->{K}; + my $enrolmentfee_J = $enrolmentfees->{J}; + my $enrolmentfee_YA = $enrolmentfees->{YA}; my %borrower_data = ( firstname => 'my firstname', -- 2.1.4