Bug 18882: (QA follow-up) Ensure stats with no or undef location are set to NULL in db
Confirm that only NULL or a string are in the location field of the statistics table. Test with two items, one with shelving location set, and one without it set. Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
9fd0555ae8
commit
8db65715fa
16
C4/Stats.pm
16
C4/Stats.pm
|
|
@ -118,14 +118,14 @@ sub UpdateStats {
|
|||
# get the parameters
|
||||
my $branch = $params->{branch};
|
||||
my $type = $params->{type};
|
||||
my $borrowernumber = exists $params->{borrowernumber} ? $params->{borrowernumber} :'';
|
||||
my $itemnumber = exists $params->{itemnumber} ? $params->{itemnumber} :'';
|
||||
my $amount = exists $params->{amount} ? $params->{amount} :'';
|
||||
my $other = exists $params->{other} ? $params->{other} :'';
|
||||
my $itemtype = exists $params->{itemtype} ? $params->{itemtype} :'';
|
||||
my $location = exists $params->{location} ? $params->{location} :'';
|
||||
my $accountno = exists $params->{accountno} ? $params->{accountno} :'';
|
||||
my $ccode = exists $params->{ccode} ? $params->{ccode} :'';
|
||||
my $borrowernumber = exists $params->{borrowernumber} ? $params->{borrowernumber} : '';
|
||||
my $itemnumber = exists $params->{itemnumber} ? $params->{itemnumber} : '';
|
||||
my $amount = exists $params->{amount} ? $params->{amount} : '';
|
||||
my $other = exists $params->{other} ? $params->{other} : '';
|
||||
my $itemtype = exists $params->{itemtype} ? $params->{itemtype} : '';
|
||||
my $location = exists $params->{location} ? $params->{location} : undef;
|
||||
my $accountno = exists $params->{accountno} ? $params->{accountno} : '';
|
||||
my $ccode = exists $params->{ccode} ? $params->{ccode} : '';
|
||||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $sth = $dbh->prepare(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use Modern::Perl;
|
||||
use C4::Stats;
|
||||
|
||||
use Test::More tests => 18;
|
||||
use Test::More tests => 20;
|
||||
|
||||
BEGIN {
|
||||
use_ok('C4::Stats');
|
||||
|
|
@ -125,6 +125,45 @@ is ($params->{location}, $line->{location}, "UpdateStats save locati
|
|||
is ($params->{accountno}, $line->{proccode}, "UpdateStats save accountno param in proccode field of statistics table");
|
||||
is ($params->{ccode}, $line->{ccode}, "UpdateStats save ccode param in ccode field of statistics table");
|
||||
|
||||
$dbh->do(q|DELETE FROM statistics|);
|
||||
$params = {
|
||||
branch => "BRA",
|
||||
itemnumber => 31,
|
||||
borrowernumber => 5,
|
||||
amount => 5.1,
|
||||
other => "bla",
|
||||
itemtype => "BK",
|
||||
accountno => 51,
|
||||
ccode => "CODE",
|
||||
type => "return"
|
||||
};
|
||||
UpdateStats($params);
|
||||
$sth = $dbh->prepare("SELECT * FROM statistics");
|
||||
$sth->execute();
|
||||
$line = ${ $sth->fetchall_arrayref( {} ) }[0];
|
||||
is( $line->{location}, undef,
|
||||
"UpdateStats sets location to NULL if no location is passed in." );
|
||||
|
||||
$dbh->do(q|DELETE FROM statistics|);
|
||||
$params = {
|
||||
branch => "BRA",
|
||||
itemnumber => 31,
|
||||
borrowernumber => 5,
|
||||
amount => 5.1,
|
||||
other => "bla",
|
||||
itemtype => "BK",
|
||||
location => undef,
|
||||
accountno => 51,
|
||||
ccode => "CODE",
|
||||
type => "return"
|
||||
};
|
||||
UpdateStats($params);
|
||||
$sth = $dbh->prepare("SELECT * FROM statistics");
|
||||
$sth->execute();
|
||||
$line = ${ $sth->fetchall_arrayref( {} ) }[0];
|
||||
is( $line->{location}, undef,
|
||||
"UpdateStats sets location to NULL if undef is passed in." );
|
||||
|
||||
#
|
||||
# Test TotalPaid
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in New Issue