Bugzilla – Attachment 153765 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: (QA follow-up) Restore older gt zero tests
Bug-33608-QA-follow-up-Restore-older-gt-zero-tests.patch (text/plain), 4.26 KB, created by
Martin Renvoize (ashimema)
on 2023-07-21 09:44:55 UTC
(
hide
)
Description:
Bug 33608: (QA follow-up) Restore older gt zero tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-07-21 09:44:55 UTC
Size:
4.26 KB
patch
obsolete
>From c0875270cc7e68a00d2153a347b34086a3b1a254 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 20 Jul 2023 06:04:46 +0000 >Subject: [PATCH] Bug 33608: (QA follow-up) Restore older gt zero tests > >See the Bugzilla report. I have been asked to restore the former >tests although I definitely think that they are wrong. Will address >that on bug 34308 separately. > >This currently has the side-effect of negative lost values being >interpreted as 'found'. (Do not use negative lost values!) >The added subtest still reflects that now. Added a few TODOs. > >Test plan: >[1] Prove t/db_dependent/Koha/Items.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Item.pm | 14 +++++++------- > t/db_dependent/Koha/Items.t | 19 ++++++++++++++++++- > 2 files changed, 25 insertions(+), 8 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 84ab3c6c38..5c09b103ea 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -131,7 +131,7 @@ sub store { > } > > # should be quite rare when adding item >- if ( $self->itemlost ) { >+ if ( $self->itemlost && $self->itemlost > 0 ) { # TODO BZ34308 > $self->_add_statistic('item_lost'); > } > >@@ -190,18 +190,18 @@ sub store { > $self->permanent_location( $self->location ); > } > >+ # TODO BZ 34308 (gt zero checks) > if ( exists $updated_columns{itemlost} >- && !$updated_columns{itemlost} >- && $pre_mod_item->itemlost ) >+ && ( !$updated_columns{itemlost} || $updated_columns{itemlost} <= 0 ) >+ && ( $pre_mod_item->itemlost && $pre_mod_item->itemlost > 0 ) ) > { > # item found > # reverse any list item charges if necessary > $self->_set_found_trigger($pre_mod_item); > $self->_add_statistic('item_found'); >- } >- elsif (exists $updated_columns{itemlost} >- && $updated_columns{itemlost} >- && !$pre_mod_item->itemlost ) >+ } elsif ( exists $updated_columns{itemlost} >+ && ( $updated_columns{itemlost} && $updated_columns{itemlost} > 0 ) >+ && ( !$pre_mod_item->itemlost || $pre_mod_item->itemlost <= 0 ) ) > { > # item lost > $self->_add_statistic('item_lost'); >diff --git a/t/db_dependent/Koha/Items.t b/t/db_dependent/Koha/Items.t >index 8464ab2ce5..013439d0ae 100755 >--- a/t/db_dependent/Koha/Items.t >+++ b/t/db_dependent/Koha/Items.t >@@ -33,6 +33,7 @@ use Koha::Item::Transfer::Limits; > use Koha::Items; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); >+use Koha::Statistics; > > use t::lib::TestBuilder; > use t::lib::Mocks; >@@ -68,7 +69,7 @@ my $retrieved_item_1 = Koha::Items->find( $new_item_1->itemnumber ); > is( $retrieved_item_1->barcode, $new_item_1->barcode, 'Find a item by id should return the correct item' ); > > subtest 'store' => sub { >- plan tests => 7; >+ plan tests => 8; > > my $biblio = $builder->build_sample_biblio; > my $today = dt_from_string->set( hour => 0, minute => 0, second => 0 ); >@@ -1363,6 +1364,22 @@ subtest 'store' => sub { > "Item modification logged" > ); > }; >+ >+ subtest 'itemlost / statistics' => sub { # TODO BZ 34308 (gt zero checks) >+ plan tests => 5; >+ >+ my $item = $builder->build_sample_item; >+ $item->itemlost(-1)->store; # weird value; >0 test not triggered ? >+ is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 0, 'No statistics added' ); >+ $item->itemlost(1)->store; >+ is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 1, 'statistics added' ); >+ $item->itemlost(2)->store; >+ is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 1, 'No statistics added, already lost' ); >+ $item->itemlost(-1)->store; # weird value; <=0 test triggered ? >+ is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 2, 'statistics added' ); >+ $item->itemlost(-2)->store; # weird value, but no status change >+ is( Koha::Statistics->search( { itemnumber => $item->id } )->count, 2, 'No statistics added, already *found*' ); >+ }; > }; > > subtest 'get_transfer' => sub { >-- >2.41.0
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