Bugzilla – Attachment 128814 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.44 KB, created by
David Nind
on 2021-12-21 00:36:59 UTC
(
hide
)
Description:
Bug 29741: Unit tests
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-12-21 00:36:59 UTC
Size:
2.44 KB
patch
obsolete
>From 2c9270a8b2dd532dc34f2ade66cd0963b2dc5fcd 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> > >Signed-off-by: David Nind <david@davidnind.com> >--- > 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.20.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 29741
:
128778
|
128779
|
128784
|
128814
|
128815
|
128816
|
128994
|
128995
|
128996