Bugzilla – Attachment 167493 Details for
Bug 31109
Prevent overwriting bibliographic records in case of simultaneous modification
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31109: Unit tests for Koha::Util::Misc::digest
Bug-31109-Unit-tests-for-KohaUtilMiscdigest.patch (text/plain), 2.83 KB, created by
Roman Dolny
on 2024-06-05 19:27:14 UTC
(
hide
)
Description:
Bug 31109: Unit tests for Koha::Util::Misc::digest
Filename:
MIME Type:
Creator:
Roman Dolny
Created:
2024-06-05 19:27:14 UTC
Size:
2.83 KB
patch
obsolete
>From 49051128f95b6d11c70b7ad1750642297abe4119 Mon Sep 17 00:00:00 2001 >From: Janusz Kaczmarek <januszop@gmail.com> >Date: Mon, 3 Jun 2024 13:42:29 +0000 >Subject: [PATCH] Bug 31109: Unit tests for Koha::Util::Misc::digest > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >--- > t/Koha/Util/Misc.t | 68 ++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 68 insertions(+) > create mode 100755 t/Koha/Util/Misc.t > >diff --git a/t/Koha/Util/Misc.t b/t/Koha/Util/Misc.t >new file mode 100755 >index 0000000000..c313d29ed9 >--- /dev/null >+++ b/t/Koha/Util/Misc.t >@@ -0,0 +1,68 @@ >+#!/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 => 4; >+use Test::Warn; >+use MARC::Record; >+use MARC::Field; >+ >+BEGIN { >+ use_ok( 'Koha::Util::Misc', qw( digest ) ); >+} >+ >+subtest 'pass scalar' => sub { >+ plan tests => 3; >+ >+ my $str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit"; >+ my $digest_01 = digest($str); >+ is( digest($str), $digest_01, 'digest from string OK' ); >+ $str .= '.'; >+ my $digest_02 = digest($str); >+ isnt( digest($str), $digest_01, 'digest from modified string changed' ); >+ is( digest($str), $digest_02, 'digest from modified string OK' ); >+}; >+ >+subtest 'pass hash' => sub { >+ plan tests => 3; >+ >+ my $data = { a => 0, b => 7 }; >+ my $digest_01 = digest($data); >+ is( digest($data), $digest_01, 'digest from hash OK' ); >+ $data->{c} = '11'; >+ my $digest_02 = digest($data); >+ isnt( digest($data), $digest_01, 'digest from modified hash changed' ); >+ is( digest($data), $digest_02, 'digest from modified hash OK' ); >+}; >+ >+subtest 'pass MARC object' => sub { >+ plan tests => 3; >+ >+ my $rec = MARC::Record->new; >+ $rec->append_fields( MARC::Field->new( '003', 'DLC' ) ); >+ $rec->append_fields( MARC::Field->new( '245', '0', '0', a => 'Title of a book :' ) ); >+ my $digest_01 = digest($rec); >+ is( digest($rec), $digest_01, 'digest from MARC object OK' ); >+ $rec->field('245')->update( b => 'subtitle.' ); >+ my $digest_02 = digest($rec); >+ isnt( >+ digest($rec), $digest_01, >+ 'digest from modified MARC object changed' >+ ); >+ is( digest($rec), $digest_02, 'digest from modified MARC object OK' ); >+}; >-- >2.39.2
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 31109
:
139046
|
167192
|
167373
|
167374
|
167375
|
167415
|
167416
|
167417
|
167436
|
167437
|
167438
|
167439
|
167492
|
167493
|
167494
|
168352
|
168353
|
168354
|
168472
|
168473
|
168474