Bug 19004: Patrons.t should create its own data for enrollment fees.

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 <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Marcel de Rooy 2017-07-30 16:53:00 +02:00 committed by Jonathan Druart
parent 327495b5e0
commit 57427f7a10

View file

@ -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',