Bugzilla – Attachment 150843 Details for
Bug 33608
Allow to get statistics about found/recovered books
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33608: Correct indentation in Stats.t
Bug-33608-Correct-indentation-in-Statst.patch (text/plain), 11.65 KB, created by
Marcel de Rooy
on 2023-05-09 11:24:55 UTC
(
hide
)
Description:
Bug 33608: Correct indentation in Stats.t
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-05-09 11:24:55 UTC
Size:
11.65 KB
patch
obsolete
>From 03a9b48d313c104ffc80ce1c73c01056788a039f Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 8 May 2023 08:22:46 +0000 >Subject: [PATCH] Bug 33608: Correct indentation in Stats.t >Content-Type: text/plain; charset=utf-8 > >Test plan: >Run t/db_dependent/Stats.t >Run git diff -w HEAD~1.. t/db_dependent/Stats.t, proving that we >only did whitespace changes. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Stats.t | 264 ++++++++++++++++++++--------------------- > 1 file changed, 132 insertions(+), 132 deletions(-) > >diff --git a/t/db_dependent/Stats.t b/t/db_dependent/Stats.t >index 9571b65f7a..a7733c126b 100755 >--- a/t/db_dependent/Stats.t >+++ b/t/db_dependent/Stats.t >@@ -30,140 +30,140 @@ my $dbh = C4::Context->dbh; > > subtest 'UpdateStats' => sub { > plan tests => 16; >-is (UpdateStats () ,undef, "UpdateStats returns undef if no params"); >- >-my $params = { >- branch => "BRA", >- itemnumber => 31, >- borrowernumber => 5, >- amount =>5.1, >- other => "bla", >- itemtype => "BK", >- location => "LOC", >- ccode => "CODE", >-}; >-my $return_error; >- >-# returns undef and croaks if type is not allowed >-$params -> {type} = "bla"; >-eval {UpdateStats($params)}; >-$return_error = $@; >-isnt ($return_error,'',"UpdateStats returns undef and croaks if type is not allowed"); >- >-delete $params->{type}; >-# returns undef and croaks if type is missing >-eval {UpdateStats($params)}; >-$return_error = $@; >-isnt ($return_error,'',"UpdateStats returns undef and croaks if no type given"); >- >-$params -> {type} = undef; >-# returns undef and croaks if type is undef >-eval {UpdateStats($params)}; >-$return_error = $@; >-isnt ($return_error,'',"UpdateStats returns undef and croaks if type is undef"); >- >-# returns undef and croaks if mandatory params are missing >-my @allowed_circulation_types = qw (renew issue localuse return onsite_checkout recall); >-my @allowed_accounts_types = qw (writeoff payment); >-my @circulation_mandatory_keys = qw (branch borrowernumber itemnumber ccode itemtype); #don't check type here >-my @accounts_mandatory_keys = qw (branch borrowernumber amount); #don't check type here >- >-my @missing_errors = (); >-foreach my $key (@circulation_mandatory_keys) { >- my $value = $params->{$key}; >- delete $params->{$key}; >- foreach my $type (@allowed_circulation_types) { >- $params->{type} = $type; >- eval {UpdateStats($params)}; >- $return_error = $@; >- push @missing_errors, "key:$key for type:$type" unless $return_error; >+ is (UpdateStats () ,undef, "UpdateStats returns undef if no params"); >+ >+ my $params = { >+ branch => "BRA", >+ itemnumber => 31, >+ borrowernumber => 5, >+ amount =>5.1, >+ other => "bla", >+ itemtype => "BK", >+ location => "LOC", >+ ccode => "CODE", >+ }; >+ my $return_error; >+ >+ # returns undef and croaks if type is not allowed >+ $params -> {type} = "bla"; >+ eval {UpdateStats($params)}; >+ $return_error = $@; >+ isnt ($return_error,'',"UpdateStats returns undef and croaks if type is not allowed"); >+ >+ delete $params->{type}; >+ # returns undef and croaks if type is missing >+ eval {UpdateStats($params)}; >+ $return_error = $@; >+ isnt ($return_error,'',"UpdateStats returns undef and croaks if no type given"); >+ >+ $params -> {type} = undef; >+ # returns undef and croaks if type is undef >+ eval {UpdateStats($params)}; >+ $return_error = $@; >+ isnt ($return_error,'',"UpdateStats returns undef and croaks if type is undef"); >+ >+ # returns undef and croaks if mandatory params are missing >+ my @allowed_circulation_types = qw (renew issue localuse return onsite_checkout recall); >+ my @allowed_accounts_types = qw (writeoff payment); >+ my @circulation_mandatory_keys = qw (branch borrowernumber itemnumber ccode itemtype); #don't check type here >+ my @accounts_mandatory_keys = qw (branch borrowernumber amount); #don't check type here >+ >+ my @missing_errors = (); >+ foreach my $key (@circulation_mandatory_keys) { >+ my $value = $params->{$key}; >+ delete $params->{$key}; >+ foreach my $type (@allowed_circulation_types) { >+ $params->{type} = $type; >+ eval {UpdateStats($params)}; >+ $return_error = $@; >+ push @missing_errors, "key:$key for type:$type" unless $return_error; >+ } >+ $params->{$key} = $value; > } >- $params->{$key} = $value; >-} >-foreach my $key (@accounts_mandatory_keys) { >- my $value = $params->{$key}; >- delete $params->{$key}; >- foreach my $type (@allowed_accounts_types) { >- $params->{type} = $type; >- eval {UpdateStats($params)}; >- $return_error = $@; >- push @missing_errors, "key:$key for type:$type" unless $return_error; >+ foreach my $key (@accounts_mandatory_keys) { >+ my $value = $params->{$key}; >+ delete $params->{$key}; >+ foreach my $type (@allowed_accounts_types) { >+ $params->{type} = $type; >+ eval {UpdateStats($params)}; >+ $return_error = $@; >+ push @missing_errors, "key:$key for type:$type" unless $return_error; >+ } >+ $params->{$key} = $value; >+ > } >- $params->{$key} = $value; >- >-} >-is (join (", ", @missing_errors),'',"UpdateStats returns undef and croaks if mandatory params are missing"); >- >-# returns undef and croaks if forbidden params are given >-$params -> {type} = "return"; >-$params -> {newparam} = "true"; >-eval {UpdateStats($params)}; >-$return_error = $@; >-isnt ($return_error,'',"UpdateStats returns undef and croaks if a forbidden param is given"); >-delete $params->{newparam}; >- >-# save the params in the right database fields >-$dbh->do(q|DELETE FROM statistics|); >-$params = { >- branch => "BRA", >- itemnumber => 31, >- borrowernumber => 5, >- amount =>5.1, >- other => "bla", >- itemtype => "BK", >- location => "LOC", >- ccode => "CODE", >- type => "return" >-}; >-UpdateStats ($params); >-my $sth = $dbh->prepare("SELECT * FROM statistics"); >-$sth->execute(); >-my $line = ${ $sth->fetchall_arrayref( {} ) }[0]; >-is ($params->{branch}, $line->{branch}, "UpdateStats save branch param in branch field of statistics table"); >-is ($params->{type}, $line->{type}, "UpdateStats save type param in type field of statistics table"); >-is ($params->{borrowernumber}, $line->{borrowernumber}, "UpdateStats save borrowernumber param in borrowernumber field of statistics table"); >-cmp_ok($params->{amount},'==', $line->{value}, "UpdateStats save amount param in value field of statistics table"); >-is ($params->{other}, $line->{other}, "UpdateStats save other param in other field of statistics table"); >-is ($params->{itemtype}, $line->{itemtype}, "UpdateStats save itemtype param in itemtype field of statistics table"); >-is ($params->{location}, $line->{location}, "UpdateStats save location param in location 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", >- 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, >- 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." ); >+ is (join (", ", @missing_errors),'',"UpdateStats returns undef and croaks if mandatory params are missing"); >+ >+ # returns undef and croaks if forbidden params are given >+ $params -> {type} = "return"; >+ $params -> {newparam} = "true"; >+ eval {UpdateStats($params)}; >+ $return_error = $@; >+ isnt ($return_error,'',"UpdateStats returns undef and croaks if a forbidden param is given"); >+ delete $params->{newparam}; >+ >+ # save the params in the right database fields >+ $dbh->do(q|DELETE FROM statistics|); >+ $params = { >+ branch => "BRA", >+ itemnumber => 31, >+ borrowernumber => 5, >+ amount =>5.1, >+ other => "bla", >+ itemtype => "BK", >+ location => "LOC", >+ ccode => "CODE", >+ type => "return" >+ }; >+ UpdateStats ($params); >+ my $sth = $dbh->prepare("SELECT * FROM statistics"); >+ $sth->execute(); >+ my $line = ${ $sth->fetchall_arrayref( {} ) }[0]; >+ is ($params->{branch}, $line->{branch}, "UpdateStats save branch param in branch field of statistics table"); >+ is ($params->{type}, $line->{type}, "UpdateStats save type param in type field of statistics table"); >+ is ($params->{borrowernumber}, $line->{borrowernumber}, "UpdateStats save borrowernumber param in borrowernumber field of statistics table"); >+ cmp_ok($params->{amount},'==', $line->{value}, "UpdateStats save amount param in value field of statistics table"); >+ is ($params->{other}, $line->{other}, "UpdateStats save other param in other field of statistics table"); >+ is ($params->{itemtype}, $line->{itemtype}, "UpdateStats save itemtype param in itemtype field of statistics table"); >+ is ($params->{location}, $line->{location}, "UpdateStats save location param in location 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", >+ 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, >+ 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." ); > }; > > $schema->storage->txn_rollback; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33608
:
150840
|
150841
|
150842
|
150843
|
150844
|
150845
|
150846
|
151051
|
151052
|
151053
|
151054
|
151055
|
151056
|
151057
|
151913
|
151915
|
151916
|
151917
|
151918
|
151919
|
151920
|
151921
|
151922
|
153653
|
153654
|
153655
|
153656
|
153657
|
153658
|
153659
|
153660
|
153661
|
153698
|
153699
|
153700
|
153701
|
153702
|
153703
|
153704
|
153705
|
153706
|
153707
|
153708
|
153709
|
153710
|
153711
|
153712
|
153713
|
153765
|
157440
|
157441
|
157442
|
157443
|
157444
|
157445
|
157446
|
157447
|
157448
|
157449