Bugzilla – Attachment 144840 Details for
Bug 32529
Holds in processing should block item deletion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32529: Regression tests
Bug-32529-Regression-tests.patch (text/plain), 4.24 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-12-26 18:31:54 UTC
(
hide
)
Description:
Bug 32529: Regression tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-12-26 18:31:54 UTC
Size:
4.24 KB
patch
obsolete
>From be92cef78b98ede26e07019e6b2e9a2bb14f9de9 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 26 Dec 2022 15:26:22 -0300 >Subject: [PATCH] Bug 32529: Regression tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Item.t | 80 +++++++++++++++++++++++++++++++------- > 1 file changed, 67 insertions(+), 13 deletions(-) > >diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t >index 21ac0bae986..04d7465e795 100755 >--- a/t/db_dependent/Koha/Item.t >+++ b/t/db_dependent/Koha/Item.t >@@ -845,8 +845,6 @@ subtest 'deletion' => sub { > > AddReturn( $item->barcode, $library->branchcode ); > >- # book_reserved is tested in t/db_dependent/Reserves.t >- > # not_same_branch > t::lib::Mocks::mock_preference('IndependentBranches', 1); > my $item_2 = $builder->build_sample_item({ library => $library_2->branchcode }); >@@ -885,17 +883,6 @@ subtest 'deletion' => sub { > > } > >- { # last_item_for_hold >- C4::Reserves::AddReserve({ branchcode => $patron->branchcode, borrowernumber => $patron->borrowernumber, biblionumber => $item->biblionumber }); >- is( >- @{$item->safe_to_delete->messages}[0]->message, >- 'last_item_for_hold', >- 'Item cannot be deleted if a biblio-level is placed on the biblio and there is only 1 item attached to the biblio' >- ); >- # With another item attached to the biblio, the item can be deleted >- $builder->build_sample_item({ biblionumber => $item->biblionumber }); >- } >- > ok( > $item->safe_to_delete, > 'Koha::Item->safe_to_delete shows item safe to delete' >@@ -909,6 +896,73 @@ subtest 'deletion' => sub { > "Koha::Item->safe_delete should delete item if safe_to_delete returns true" > ); > >+ subtest 'holds tests' => sub { >+ >+ plan tests => 9; >+ >+ # to avoid noise >+ t::lib::Mocks::mock_preference( 'IndependentBranches', 0 ); >+ >+ $schema->storage->txn_begin; >+ >+ my $item = $builder->build_sample_item; >+ >+ my $processing = $builder->build_object( { class => 'Koha::Holds', value => { itemnumber => $item->id, itemnumber => $item->id, found => 'P' } } ); >+ my $safe_to_delete = $item->safe_to_delete; >+ >+ ok( !$safe_to_delete, 'Cannot delete' ); >+ is( >+ @{ $safe_to_delete->messages }[0]->message, >+ 'book_reserved', >+ 'Koha::Item->safe_to_delete reports a in processing hold blocks deletion' >+ ); >+ >+ $processing->delete; >+ >+ my $in_transit = $builder->build_object( { class => 'Koha::Holds', value => { itemnumber => $item->id, itemnumber => $item->id, found => 'T' } } ); >+ $safe_to_delete = $item->safe_to_delete; >+ >+ ok( !$safe_to_delete, 'Cannot delete' ); >+ is( >+ @{ $safe_to_delete->messages }[0]->message, >+ 'book_reserved', >+ 'Koha::Item->safe_to_delete reports a in transit hold blocks deletion' >+ ); >+ >+ $in_transit->delete; >+ >+ my $waiting = $builder->build_object( { class => 'Koha::Holds', value => { itemnumber => $item->id, itemnumber => $item->id, found => 'W' } } ); >+ $safe_to_delete = $item->safe_to_delete; >+ >+ ok( !$safe_to_delete, 'Cannot delete' ); >+ is( >+ @{ $safe_to_delete->messages }[0]->message, >+ 'book_reserved', >+ 'Koha::Item->safe_to_delete reports a waiting hold blocks deletion' >+ ); >+ >+ $waiting->delete; >+ >+ # Add am unfilled biblio-level hold to catch the 'last_item_for_hold' use case >+ $builder->build_object( { class => 'Koha::Holds', value => { biblionumber => $item->biblionumber, itemnumber => undef, found => undef } } ); >+ >+ $safe_to_delete = $item->safe_to_delete; >+ >+ ok( !$safe_to_delete ); >+ >+ is( >+ @{ $safe_to_delete->messages}[0]->message, >+ 'last_item_for_hold', >+ 'Item cannot be deleted if a biblio-level is placed on the biblio and there is only 1 item attached to the biblio' >+ ); >+ >+ my $extra_item = $builder->build_sample_item({ biblionumber => $item->biblionumber }); >+ >+ ok( $item->safe_to_delete ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ > $schema->storage->txn_rollback; > }; > >-- >2.34.1
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 32529
:
144839
|
144840
|
144841
|
144848
|
144849
|
144850
|
144874
|
144875
|
144876