Bugzilla – Attachment 130253 Details for
Bug 29780
Add Koha::Old::Holds->anonymize
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29780: Unit tests
Bug-29780-Unit-tests.patch (text/plain), 3.48 KB, created by
Martin Renvoize
on 2022-02-08 08:03:53 UTC
(
hide
)
Description:
Bug 29780: Unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2022-02-08 08:03:53 UTC
Size:
3.48 KB
patch
obsolete
>From 80ed65d02931133b984031f69c7510e8913af42d Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 3 Jan 2022 10:36:55 -0300 >Subject: [PATCH] Bug 29780: Unit tests > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Koha/Old/Holds.t | 87 +++++++++++++++++++++++++++++++++ > 1 file changed, 87 insertions(+) > create mode 100755 t/db_dependent/Koha/Old/Holds.t > >diff --git a/t/db_dependent/Koha/Old/Holds.t b/t/db_dependent/Koha/Old/Holds.t >new file mode 100755 >index 0000000000..fc1f5592cd >--- /dev/null >+++ b/t/db_dependent/Koha/Old/Holds.t >@@ -0,0 +1,87 @@ >+#!/usr/bin/perl >+ >+# 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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+ >+use Koha::Database; >+use Koha::DateUtils qw(dt_from_string); >+use Koha::Old::Holds; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'anonymize() tests' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ is( $patron->old_holds->count, 0, 'Patron has no old holds' ); >+ is( $patron->old_holds->anonymize + 0, 0, 'Anonymizing an empty resultset returns 0' ); >+ >+ my $hold_1 = $builder->build_object( >+ { >+ class => 'Koha::Old::Holds', >+ value => >+ { borrowernumber => $patron->id, timestamp => dt_from_string() } >+ } >+ ); >+ my $hold_2 = $builder->build_object( >+ { >+ class => 'Koha::Old::Holds', >+ value => { >+ borrowernumber => $patron->id, >+ timestamp => dt_from_string()->subtract( days => 1 ) >+ } >+ } >+ ); >+ my $hold_3 = $builder->build_object( >+ { >+ class => 'Koha::Old::Holds', >+ value => { >+ borrowernumber => $patron->id, >+ timestamp => dt_from_string()->subtract( days => 2 ) >+ } >+ } >+ ); >+ my $hold_4 = $builder->build_object( >+ { >+ class => 'Koha::Old::Holds', >+ value => { >+ borrowernumber => $patron->id, >+ timestamp => dt_from_string()->subtract( days => 3 ) >+ } >+ } >+ ); >+ >+ is( $patron->old_holds->count, 4, 'Patron has 4 completed holds' ); >+ # filter them so only the older two are part of the resultset >+ my $holds = $patron->old_holds->search({ timestamp => { '<=' => dt_from_string()->subtract( days => 2 ) } }); >+ # Anonymize them >+ my $anonymized_count = $holds->anonymize(); >+ is( $anonymized_count, 2, 'update() tells 2 rows were updated' ); >+ >+ is( $patron->old_holds->count, 2, 'Patron has 2 completed holds' ); >+ >+ $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 29780
:
128964
|
128965
|
128966
|
128978
|
128979
|
130252
| 130253