From d191039317299aac3cbe81699a9c2af9f5ea11dc Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 5 Mar 2015 11:46:37 +0100 Subject: [PATCH] Bug 12768 [QA Followup] - Fix unit tests --- C4/Accounts.pm | 20 ++++++++++++++------ t/db_dependent/Circulation/Chargelostitem.t | 6 +++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/C4/Accounts.pm b/C4/Accounts.pm index 102c008..b57c7d0 100644 --- a/C4/Accounts.pm +++ b/C4/Accounts.pm @@ -467,12 +467,20 @@ sub manualinvoice { sub getcharges { my ( $borrowerno, $accountno ) = @_; - my $dbh = C4::Context->dbh; - my $query = ""; - my $sth = $dbh->prepare( - "SELECT * FROM accountlines WHERE borrowernumber=? AND accountno = ?" - ); - $sth->execute( $borrowerno, $accountno ); + my $dbh = C4::Context->dbh; + + my @params; + + my $query = "SELECT * FROM accountlines WHERE borrowernumber = ?"; + push( @params, $borrowerno ); + + if ( $accountno ) { + $query .= " AND accountno = ?"; + push( @params, $accountno ); + } + + my $sth = $dbh->prepare( $query ); + $sth->execute( @params ); my @results; while ( my $data = $sth->fetchrow_hashref ) { diff --git a/t/db_dependent/Circulation/Chargelostitem.t b/t/db_dependent/Circulation/Chargelostitem.t index e9d9694..06770c9 100644 --- a/t/db_dependent/Circulation/Chargelostitem.t +++ b/t/db_dependent/Circulation/Chargelostitem.t @@ -76,9 +76,9 @@ my $issues; $issues = C4::Circulation::GetIssues({biblionumber => $biblionumber1}); my $issue=$issues->[0]; $issue->{'processfee'} = $processfee; -my $accountlineId = C4::Accounts::chargelostitem($issue, 'test'); +C4::Accounts::chargelostitem($issue, 'test'); -my @accountline = C4::Accounts::getcharges($borrowernumber, $accountlineId); +my @accountline = C4::Accounts::getcharges($borrowernumber); is( scalar(@accountline), 1, 'accountline should have 1 row' ); is( int($accountline[0]->{amount}), $processfee, "The accountline amount should be precessfee value " ); @@ -86,4 +86,4 @@ is( $accountline[0]->{accounttype}, 'PF', "The accountline accounttype should be is( $accountline[0]->{borrowernumber}, $borrowernumber, "The accountline borrowernumber should be the exemple borrownumber" ); my $itemnumber = C4::Items::GetItemnumberFromBarcode('0101'); is( $accountline[0]->{itemnumber}, $itemnumber, "The accountline itemnumber should the linked with barcode '0101'" ); -is( $accountline[0]->{description}, 'test', "The accountline description should be 'test'" ); +is( $accountline[0]->{description}, 'test ' . $issue->{itemnumber}, "The accountline description should be 'test'" ); -- 1.7.10.4