Bugzilla – Attachment 128778 Details for
Bug 29741
Add Koha::Patron->safe_to_delete
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29741: Unit tests
Bug-29741-Unit-tests.patch (text/plain), 2.40 KB, created by
Tomás Cohen Arazi (tcohen)
on 2021-12-20 17:22:24 UTC
(
hide
)
Description:
Bug 29741: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2021-12-20 17:22:24 UTC
Size:
2.40 KB
patch
obsolete
>From 4057c1b23c6f0db714bab3b21deebe730c99f0ed Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 20 Dec 2021 14:17:31 -0300 >Subject: [PATCH] Bug 29741: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > t/db_dependent/Koha/Patron.t | 51 +++++++++++++++++++++++++++++++++++- > 1 file changed, 50 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 2929349661..f0724766fc 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 => 10; >+use Test::More tests => 11; > use Test::Exception; > use Test::Warn; > >@@ -846,3 +846,52 @@ subtest 'article_requests() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'safe_to_delete() tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ >+ ## Make it the anonymous >+ t::lib::Mocks::mock_preference( 'AnonymousPatron', $patron->id ); >+ >+ is( $patron->safe_to_delete, 'is_anonymous_patron', 'Cannot delete, it is the anonymous patron' ); >+ # cleanup >+ t::lib::Mocks::mock_preference( 'AnonymousPatron', 0 ); >+ >+ ## Make it have a checkout >+ my $checkout = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { borrowernumber => $patron->id } >+ } >+ ); >+ >+ is( $patron->safe_to_delete, 'has_checkouts', 'Cannot delete, has checkouts' ); >+ # cleanup >+ $checkout->delete; >+ >+ ## Make it have a guarantee >+ t::lib::Mocks::mock_preference( 'borrowerRelationship', 'parent' ); >+ $builder->build_object({ class => 'Koha::Patrons' }) >+ ->add_guarantor({ guarantor_id => $patron->id, relationship => 'parent' }); >+ >+ is( $patron->safe_to_delete, 'has_guarantees', 'Cannot delete, has guarantees' ); >+ # cleanup >+ $patron->guarantee_relationships->delete; >+ >+ ## Make it have debt >+ my $debit = $patron->account->add_debit({ amount => 10, interface => 'intranet', type => 'MANUAL' }); >+ >+ is( $patron->safe_to_delete, 'has_debt', 'Cannot delete, has debt' ); >+ # cleanup >+ $patron->account->pay({ amount => 10, debits => [ $debit ] }); >+ >+ ## Happy case :-D >+ is( $patron->safe_to_delete, 'ok', 'Can delete, all conditions met' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.32.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 29741
:
128778
|
128779
|
128784
|
128814
|
128815
|
128816
|
128994
|
128995
|
128996