Bugzilla – Attachment 180993 Details for
Bug 32034
Library branch transfers should be in the action logs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32034: Add more tests
Bug-32034-Add-more-tests.patch (text/plain), 3.64 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-04-15 19:37:59 UTC
(
hide
)
Description:
Bug 32034: Add more tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-04-15 19:37:59 UTC
Size:
3.64 KB
patch
obsolete
>From d9de25f4bb0eca10fefe81abd5f5eca248a7805f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 15 Apr 2025 16:33:01 -0300 >Subject: [PATCH] Bug 32034: Add more tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Item/Transfer.t | 79 ++++++++++++++++++++++++++++- > 1 file changed, 78 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Item/Transfer.t b/t/db_dependent/Koha/Item/Transfer.t >index 92158644e2a..5c0c9c2c613 100755 >--- a/t/db_dependent/Koha/Item/Transfer.t >+++ b/t/db_dependent/Koha/Item/Transfer.t >@@ -21,11 +21,13 @@ use Modern::Perl; > > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); >+use Koha::Item::Transfers; > >+use t::lib::Mocks; > use t::lib::TestBuilder; > > use Test::NoWarnings; >-use Test::More tests => 8; >+use Test::More tests => 9; > use Test::Exception; > > my $schema = Koha::Database->new->schema; >@@ -314,3 +316,78 @@ subtest 'cancel tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'store() tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $library_a = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $library_b = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $item = $builder->build_sample_item( >+ { >+ homebranch => $library_a->branchcode, >+ holdingbranch => $library_b->branchcode, >+ } >+ ); >+ >+ # make sure there aren't transfer logs >+ $schema->resultset('ActionLog')->search( { module => 'TRANSFERS' } )->delete(); >+ is( $schema->resultset('ActionLog')->search( { module => 'TRANSFERS' } )->count(), 0, 'No transfer logs' ); >+ >+ # enable logging >+ t::lib::Mocks::mock_preference( 'TransfersLog', 1 ); >+ >+ # Add a new transfer entry >+ my $transfer = Koha::Item::Transfer->new( >+ { >+ itemnumber => $item->itemnumber, >+ frombranch => $library_b->branchcode, >+ tobranch => $library_a->branchcode, >+ datesent => \'NOW()', >+ datearrived => undef, >+ datecancelled => undef, >+ reason => 'Manual', >+ cancellation_reason => undef, >+ } >+ )->store(); >+ is( >+ $schema->resultset('ActionLog')->search( { module => 'TRANSFERS', action => 'CREATE' } )->count(), 1, >+ 'Logging enabled, log added on creation' >+ ); >+ >+ $transfer->reason('Reserve')->store(); >+ is( >+ $schema->resultset('ActionLog')->search( { module => 'TRANSFERS', action => 'UPDATE' } )->count(), 1, >+ 'Logging enabled, log added on update' >+ ); >+ >+ # enable logging >+ t::lib::Mocks::mock_preference( 'TransfersLog', 0 ); >+ $transfer = Koha::Item::Transfer->new( >+ { >+ itemnumber => $item->itemnumber, >+ frombranch => $library_b->branchcode, >+ tobranch => $library_a->branchcode, >+ datesent => \'NOW()', >+ datearrived => undef, >+ datecancelled => undef, >+ reason => 'Manual', >+ cancellation_reason => undef, >+ } >+ )->store(); >+ is( >+ $schema->resultset('ActionLog')->search( { module => 'TRANSFERS', action => 'CREATE' } )->count(), 1, >+ 'Logging disabled, log not generated on creation' >+ ); >+ >+ $transfer->reason('Reserve')->store(); >+ is( >+ $schema->resultset('ActionLog')->search( { module => 'TRANSFERS', action => 'UPDATE' } )->count(), 1, >+ 'Logging enabled, log not generated on update' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.49.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 32034
:
144543
|
144581
|
144582
|
180991
|
180992
|
180993
|
181265
|
181266
|
181267