Bugzilla – Attachment 171210 Details for
Bug 37115
Add the option to delete linked serials when deleting items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37115: Add unit tests
Bug-37115-Add-unit-tests.patch (text/plain), 5.45 KB, created by
Matt Blenkinsop
on 2024-09-09 15:39:24 UTC
(
hide
)
Description:
Bug 37115: Add unit tests
Filename:
MIME Type:
Creator:
Matt Blenkinsop
Created:
2024-09-09 15:39:24 UTC
Size:
5.45 KB
patch
obsolete
>From 28659382b0abd65e499c1d11a5f57f1677492ed3 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> >Date: Thu, 4 Jul 2024 10:14:21 +0000 >Subject: [PATCH] Bug 37115: Add unit tests > >prove t/db_dependent/Koha/Item.t >prove t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t >--- > .../Koha/BackgroundJobs/BatchDeleteItem.t | 43 ++++++++++++++- > t/db_dependent/Koha/Item.t | 52 ++++++++++++++++++- > 2 files changed, 93 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t b/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t >index ee40088c8c2..49bc760c7c6 100755 >--- a/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t >+++ b/t/db_dependent/Koha/BackgroundJobs/BatchDeleteItem.t >@@ -24,6 +24,8 @@ use JSON qw( encode_json ); > > use Koha::Database; > use Koha::BackgroundJob::BatchDeleteItem; >+use Koha::Serial; >+use Koha::Serial::Items; > > use t::lib::Mocks; > use t::lib::TestBuilder; >@@ -33,7 +35,7 @@ my $builder = t::lib::TestBuilder->new; > > subtest "process() tests" => sub { > >- plan tests => 2; >+ plan tests => 4; > > $schema->storage->txn_begin; > >@@ -99,5 +101,44 @@ subtest "process() tests" => sub { > > is( $counter, 1, 'Counter untouched with RealTimeHoldsQueue disabled' ); > >+ $biblio = $builder->build_sample_biblio; >+ my $item_with_serial = $builder->build_sample_item( { biblionumber => $biblio->id } ); >+ my $serial = >+ $builder->build_object( { class => 'Koha::Serials', value => { biblionumber => $biblio->biblionumber } } ); >+ my $serial_item = $builder->build_object( >+ { >+ class => 'Koha::Serial::Items', >+ value => { itemnumber => $item_with_serial->itemnumber, serialid => $serial->serialid } >+ } >+ ); >+ >+ $job = Koha::BackgroundJob::BatchDeleteItem->new( >+ { >+ status => 'new', >+ size => 2, >+ borrowernumber => undef, >+ type => 'batch_item_record_deletion', >+ data => encode_json { >+ record_ids => [ $item_with_serial->id ], >+ delete_biblios => 1, >+ delete_serial_issues => 1, >+ } >+ } >+ ); >+ >+ $job->process( >+ { >+ record_ids => [ $item_with_serial->id ], >+ delete_biblios => 1, >+ delete_serial_issues => 1, >+ } >+ ); >+ >+ my $serial_check = Koha::Serials->find( $serial->serialid ); >+ my $serial_item_check = Koha::Serial::Items->find( $serial_item->itemnumber ); >+ >+ is( $serial_check, undef, 'Serial deleted' ); >+ is( $serial_item_check, undef, 'Serial item deleted' ); >+ > $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index ab6d01c5d71..1d5cbb9780e 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -955,7 +955,7 @@ subtest 'store check barcodes' => sub { > }; > > subtest 'deletion' => sub { >- plan tests => 15; >+ plan tests => 16; > > $schema->storage->txn_begin; > >@@ -1131,6 +1131,56 @@ subtest 'deletion' => sub { > $schema->storage->txn_rollback; > }; > >+ subtest 'serial issues tests' => sub { >+ plan tests => 4; >+ >+ t::lib::Mocks::mock_preference( 'IndependentBranches', 0 ); >+ >+ $schema->storage->txn_begin; >+ >+ my $biblio = $builder->build_sample_biblio; >+ my $item_with_serial = $builder->build_sample_item( { biblionumber => $biblio->id } ); >+ my $serial = >+ $builder->build_object( { class => 'Koha::Serials', value => { biblionumber => $biblio->biblionumber } } ); >+ my $serial_item = $builder->build_object( >+ { >+ class => 'Koha::Serial::Items', >+ value => { itemnumber => $item_with_serial->itemnumber, serialid => $serial->serialid } >+ } >+ ); >+ >+ # Check serial issue is not deleted unless argument passed >+ $item_with_serial->safe_delete( { delete_serial_issues => 0 } ); >+ >+ my $serial_check = Koha::Serials->find( $serial->serialid ); >+ my $serial_item_check = Koha::Serial::Items->find( $serial_item->itemnumber ); >+ >+ is( $serial_check->serialid, $serial->serialid, 'Serial not deleted as the argument was not passed' ); >+ is( $serial_item_check, undef, 'Serial item deleted by cascade' ); >+ >+ $biblio = $builder->build_sample_biblio; >+ $item_with_serial = $builder->build_sample_item( { biblionumber => $biblio->id } ); >+ $serial = >+ $builder->build_object( { class => 'Koha::Serials', value => { biblionumber => $biblio->biblionumber } } ); >+ $serial_item = $builder->build_object( >+ { >+ class => 'Koha::Serial::Items', >+ value => { itemnumber => $item_with_serial->itemnumber, serialid => $serial->serialid } >+ } >+ ); >+ >+ # Check serial issue is deleted when argument passed >+ $item_with_serial->safe_delete( { delete_serial_issues => 1 } ); >+ >+ $serial_check = Koha::Serials->find( $serial->serialid ); >+ $serial_item_check = Koha::Serial::Items->find( $serial_item->itemnumber ); >+ >+ is( $serial_check, undef, 'Serial deleted' ); >+ is( $serial_item_check, undef, 'Serial item deleted by cascade' ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ > $schema->storage->txn_rollback; > }; > >-- >2.39.3 (Apple Git-146)
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 37115
:
167847
|
167848
|
168133
|
168134
|
168373
|
168374
|
168495
|
168496
|
168497
|
171208
|
171209
|
171210
|
171938
|
171939
|
171940
|
173256
|
173257
|
173258