Bugzilla – Attachment 171463 Details for
Bug 37892
Patron category 'can be a guarantee' means that same category cannot be a guarantor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37892: Unit tests
Bug-37892-Unit-tests.patch (text/plain), 4.19 KB, created by
Olivier Vezina
on 2024-09-13 14:15:32 UTC
(
hide
)
Description:
Bug 37892: Unit tests
Filename:
MIME Type:
Creator:
Olivier Vezina
Created:
2024-09-13 14:15:32 UTC
Size:
4.19 KB
patch
obsolete
>From 6e1d1afea41016210ebcbee3a9731c982a9820f5 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 11 Sep 2024 14:04:17 +0000 >Subject: [PATCH] Bug 37892: Unit tests > >These patches will alter the checks for a patron that prevent a category with >'can_be_guarantee' from being a guarantor. Two patrons in the same category should be >allowed to have a guarantee/guarantor relationship > >The tests below assume you are using the KTD sample data. Update borrowernumbers if not. > >To test: > 0 - Apply tests patch > 1 - Set the 'Patron' category as 'Can be a guarantee' > 2 - Add a relationship between two patrons of the same category > This is restricted from the staff interface > perl -e 'use Koha::Patrons; my $p = Koha::Patrons->find(5)->add_guarantor({ guarantor_id => 23, relationship => 'father'});' > 3 - Note there is no warning or exception. This should be allowed. > 4 - Checkout an item to Edna (borrowernumber 5) > 5 - Set 'TrackLastPatronActivityTriggers' to 'Checking in an item' > 6 - Try to check the item in, KABOOM > 7 - Set 'TrackLastPatronActivityTriggers' to 'Checking out an item' > 8 - Try to issue an item to Enda, KABOOM > 9 - prove -v t/db_dependent/Koha/Patron.t, fail >10 - Apply second patch >11 - prove -v t/db_dependent/Koha/Patron.t, one more test passes, but then fail >12 - Apply third patch >13 - prove -v t/db_dependent/Koha/Patron.t, pass! >14 - restart_all >15 - Checkout to Enda, OK! >16 - Checkin from Edna, OK! >17 - Find two more patrons in the category and attempt to link them >18 - 'Guarantor cannot be a guarantee' >19 - Apply fourth patch >20 - You can add a guarantor from the same category in interface >21 - Try to add a guarantor to the guarantor assigned in 20 >22 - Confirm you cannot add a guarantor - "Guarantor cannot be a guarantee" > >Signed-off-by: Olivier V <olivier.vezina@inLibro.com> >--- > t/db_dependent/Koha/Patron.t | 47 +++++++++++++++++++++++++++++++++++- > 1 file changed, 46 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index bf4aeef097..ea026bfb5f 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 35; >+use Test::More tests => 36; > use Test::Exception; > use Test::Warn; > use Time::Fake; >@@ -410,6 +410,51 @@ subtest 'add_guarantor() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'guarantor checks on patron creation / update tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ t::lib::Mocks::mock_preference( 'borrowerRelationship', 'guarantor' ); >+ my $category = $builder->build_object( >+ { class => 'Koha::Patron::Categories', value => { can_be_guarantee => 1, category_type => 'A' } } ); >+ >+ my $guarantor = >+ $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $category->categorycode } } ); >+ my $guarantee = >+ $builder->build_object( { class => 'Koha::Patrons', value => { categorycode => $category->categorycode } } ); >+ >+ subtest 'patron update tests' => sub { >+ plan tests => 4; >+ ok( >+ $guarantee->add_guarantor( { guarantor_id => $guarantor->borrowernumber, relationship => 'guarantor' } ), >+ "Relationship is added, no problem" >+ ); >+ is( $guarantor->guarantee_relationships->count, 1, 'Relationship added' ); >+ ok( $guarantor->surname("Duck")->store(), "Updating guarantor is okay" ); >+ ok( $guarantee->surname("Duck")->store(), "Updating guarantee is okay" ); >+ }; >+ >+ subtest 'patron update tests' => sub { >+ plan tests => 1; >+ >+ my $new_guarantee = $builder->build_object( >+ { class => 'Koha::Patrons', value => { categorycode => $category->categorycode } } ); >+ my $new_guarantee_hash = $new_guarantee->unblessed; >+ $new_guarantee->delete(); >+ >+ delete $new_guarantee_hash->{borrowernumber}; >+ >+ ok( >+ Koha::Patron->new($new_guarantee_hash)->store( { guarantors => [$guarantor] } ), >+ "We can add the new patron and indicate guarantor" >+ ); >+ }; >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'relationships_debt() tests' => sub { > > plan tests => 168; >-- >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 37892
:
171334
|
171335
|
171336
|
171337
|
171451
|
171463
|
171464
|
171465
|
171466
|
171467
|
171472
|
171475
|
171476
|
171477
|
171478
|
171479
|
171480
|
171546
|
171547
|
171548
|
171549
|
171550
|
171663
|
171664
|
171665
|
171824
|
171825
|
171826
|
172896
|
172897
|
172898