From 56a686204546c91a1a23afb10932b62774bf0eb0 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 23 Oct 2017 13:19:42 -0300 Subject: [PATCH] Bug 19517: Prevent dateexpiry.t to fail randomly If categorycode is 'X', the test will fail Signed-off-by: Jonathan Druart --- t/db_dependent/Circulation/dateexpiry.t | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Circulation/dateexpiry.t b/t/db_dependent/Circulation/dateexpiry.t index dbb7e0bda6..c8b5f49c85 100644 --- a/t/db_dependent/Circulation/dateexpiry.t +++ b/t/db_dependent/Circulation/dateexpiry.t @@ -34,6 +34,8 @@ my $builder = t::lib::TestBuilder->new(); $ENV{ DEBUG } = 0; +my $patron_category = $builder->build({ source => 'Category', value => { categorycode => 'NOT_X', category_type => 'P', enrolmentfee => 0 } }); + subtest 'Tests for CanBookBeIssued related to dateexpiry' => sub { plan tests => 4; can_book_be_issued(); @@ -47,7 +49,10 @@ sub can_book_be_issued { my $item = $builder->build( { source => 'Item' } ); my $patron = $builder->build( { source => 'Borrower', - value => { dateexpiry => '9999-12-31' } + value => { + dateexpiry => '9999-12-31', + categorycode => $patron_category->{categorycode}, + } } ); $patron->{flags} = C4::Members::patronflags( $patron ); @@ -60,7 +65,10 @@ sub can_book_be_issued { $item = $builder->build( { source => 'Item' } ); $patron = $builder->build( { source => 'Borrower', - value => { dateexpiry => '0000-00-00' } + value => { + dateexpiry => '0000-00-00', + categorycode => $patron_category->{categorycode}, + } } ); $patron->{flags} = C4::Members::patronflags( $patron ); @@ -71,7 +79,10 @@ sub can_book_be_issued { $item = $builder->build( { source => 'Item' } ); $patron = $builder->build( { source => 'Borrower', - value => { dateexpiry => output_pref( { dt => $tomorrow, dateonly => 1, dateformat => 'sql' } ) }, + value => { + dateexpiry => output_pref( { dt => $tomorrow, dateonly => 1, dateformat => 'sql' } ), + categorycode => $patron_category->{categorycode}, + }, } ); $patron->{flags} = C4::Members::patronflags( $patron ); @@ -85,7 +96,12 @@ sub calc_date_due { # this triggers the compare between expiry and due date - my $patron = $builder->build( { source => 'Borrower' } ); + my $patron = $builder->build({ + source => 'Borrower', + value => { + categorycode => $patron_category->{categorycode}, + } + }); my $item = $builder->build( { source => 'Item' } ); my $branch = $builder->build( { source => 'Branch' } ); my $today = dt_from_string(); -- 2.11.0