Bugzilla – Attachment 189790 Details for
Bug 34069
Add ability to restore a recently deleted borrower from deletedborrowers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34069: Add unit tests
Bug-34069-Add-unit-tests.patch (text/plain), 2.66 KB, created by
Lucas Gass (lukeg)
on 2025-11-20 14:42:42 UTC
(
hide
)
Description:
Bug 34069: Add unit tests
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2025-11-20 14:42:42 UTC
Size:
2.66 KB
patch
obsolete
>From 3f44e71fb90dbe69cfbaf508e0b045eb1279d142 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Mon, 17 Nov 2025 20:57:50 +0000 >Subject: [PATCH] Bug 34069: Add unit tests > >--- > t/db_dependent/Koha/Old/Patron.t | 64 ++++++++++++++++++++++++++++++++ > 1 file changed, 64 insertions(+) > create mode 100755 t/db_dependent/Koha/Old/Patron.t > >diff --git a/t/db_dependent/Koha/Old/Patron.t b/t/db_dependent/Koha/Old/Patron.t >new file mode 100755 >index 00000000000..320c619559f >--- /dev/null >+++ b/t/db_dependent/Koha/Old/Patron.t >@@ -0,0 +1,64 @@ >+#!/usr/bin/perl >+ >+# Copyright 2025 Koha >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <https://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 2; >+use Test::Exception; >+use Test::MockModule; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+use Test::NoWarnings; >+ >+use Koha::Database; >+use Koha::Patrons; >+use Koha::Old::Patrons; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'restore_deleted_borrower' => sub { >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ #create a test patron >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ my $borrowernumber = $patron->borrowernumber; >+ my $cardnumber = $patron->cardnumber; >+ >+ #delete the created patron, using move = 1 to ensure they go to deleteborrowers >+ my $to_delete = Koha::Patrons->search( { borrowernumber => $borrowernumber } ); >+ $to_delete->delete( { move => 1 } ); >+ >+ #verify patron is in deletedborrowers >+ my $deleted_patron = Koha::Old::Patrons->search( { borrowernumber => $borrowernumber } )->next; >+ ok( $deleted_patron, 'Patron moved to deletedborrowers' ); >+ >+ #restore the deleted patron >+ my $restored = $deleted_patron->restore_deleted_borrower; >+ >+ #verify the patron is restored >+ ok( $restored, 'Restored patron exists' ); >+ is( $restored->borrowernumber, $borrowernumber, 'Borrowernumber matches' ); >+ is( $restored->cardnumber, $cardnumber, 'Cardnumber matches' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.39.5
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 34069
:
188299
|
188302
|
188988
|
188989
|
188990
|
189027
|
189028
|
189029
|
189030
|
189037
|
189066
|
189067
|
189370
|
189371
|
189372
|
189373
|
189374
|
189375
|
189376
|
189377
|
189642
|
189645
|
189718
|
189773
|
189774
|
189779
|
189780
|
189781
|
189782
|
189783
|
189784
|
189785
|
189786
|
189787
|
189788
|
189789
|
189790
|
189791
|
189792
|
189793
|
189794
|
189795
|
189940
|
189941
|
189942
|
189943
|
189944
|
189945
|
189946
|
189947
|
189948
|
189949
|
189950
|
189951
|
189952
|
189953
|
189954