Bugzilla – Attachment 39266 Details for
Bug 11700
C4::AuthoritiesMarc::merge enhancements/fixes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
[SIGNED_OFF] Bug 11700: Add unit tests for C4::AuthoritiesMarc::merge
SIGNEDOFF-Bug-11700-Add-unit-tests-for-C4Authoriti.patch (text/plain), 4.56 KB, created by
Bernardo Gonzalez Kriegel
on 2015-05-17 22:53:24 UTC
(
hide
)
Description:
[SIGNED_OFF] Bug 11700: Add unit tests for C4::AuthoritiesMarc::merge
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2015-05-17 22:53:24 UTC
Size:
4.56 KB
patch
obsolete
>From 457902288cc6d5a0816afc233f24c277f89d400e Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 19 Feb 2014 11:31:13 +0100 >Subject: [PATCH] [SIGNED_OFF] Bug 11700: Add unit tests for > C4::AuthoritiesMarc::merge > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >--- > t/db_dependent/AuthoritiesMarc.t | 78 +++++++++++++++++++++++++++++++++++++- > 1 file changed, 77 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/AuthoritiesMarc.t b/t/db_dependent/AuthoritiesMarc.t >index f432a5d..c342295 100755 >--- a/t/db_dependent/AuthoritiesMarc.t >+++ b/t/db_dependent/AuthoritiesMarc.t >@@ -6,7 +6,7 @@ > use strict; > use warnings; > >-use Test::More tests => 8; >+use Test::More tests => 15; > use Test::MockModule; > use Test::Warn; > use MARC::Record; >@@ -190,4 +190,80 @@ is_deeply( > 'test BuildSummary for UNIMARC' > ); > >+$module->unmock_all(); >+ >+use C4::Context; >+use C4::Biblio; >+ >+my $dbh = C4::Context->dbh; >+$dbh->{AutoCommit} = 0; >+$dbh->{RaiseError} = 1; >+ >+# Start testing C4::AuthoritiesMarc::merge >+ >+# Create authority type TEST_PERSO >+$dbh->do("INSERT INTO auth_types(authtypecode, authtypetext, auth_tag_to_report, summary) VALUES('TEST_PERSO', 'Personal Name', '109', 'Personal Names');"); >+$dbh->do("INSERT INTO auth_tag_structure (authtypecode, tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value) VALUES('TEST_PERSO', '109', 'HEADING--PERSONAL NAME', 'HEADING--PERSONAL NAME', 0, 0, NULL)"); >+$dbh->do("INSERT INTO auth_subfield_structure (authtypecode, tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory, tab, authorised_value, value_builder, seealso, isurl, hidden, linkid, kohafield, frameworkcode) VALUES ('TEST_PERSO', '109', 'a', 'Personal name', 'Personal name', 0, 0, 1, NULL, NULL, '', 0, 0, '', '', '')"); >+ >+my $auth1 = new MARC::Record; >+$auth1->append_fields(new MARC::Field('109', '0', '0', 'a' => 'George Orwell')); >+my $authid1 = AddAuthority($auth1, undef, 'TEST_PERSO'); >+my $auth2 = new MARC::Record; >+$auth2->append_fields(new MARC::Field('109', '0', '0', 'a' => 'G. Orwell')); >+my $authid2 = AddAuthority($auth2, undef, 'TEST_PERSO'); >+ >+$dbh->do("INSERT IGNORE INTO marc_subfield_structure(tagfield, tagsubfield, liblibrarian, libopac, repeatable, mandatory, kohafield, tab, authorised_value, authtypecode, value_builder, isurl, hidden, frameworkcode, seealso, link, defaultvalue) VALUES('609', 'a', 'Personal name', 'Personal name', 0, 0, '', 6, '', 'TEST_PERSO', '', NULL, 0, '', '', '', NULL)"); >+$dbh->do("UPDATE marc_subfield_structure SET authtypecode = 'TEST_PERSO' WHERE tagfield='609' AND tagsubfield='a' AND frameworkcode='';"); >+my $tagfields = $dbh->selectcol_arrayref("select distinct tagfield from marc_subfield_structure where authtypecode='TEST_PERSO'"); >+my $biblio1 = new MARC::Record; >+$biblio1->append_fields( >+ new MARC::Field('609', '0', '0', '9' => $authid1, 'a' => 'George Orwell') >+); >+my $biblionumber1 = AddBiblio($biblio1, ''); >+my $biblio2 = new MARC::Record; >+$biblio2->append_fields( >+ new MARC::Field('609', '0', '0', '9' => $authid2, 'a' => 'G. Orwell') >+); >+my $biblionumber2 = AddBiblio($biblio2, ''); >+ >+# Mock ZOOM objects >+my $zoom_connection = new Test::MockModule('ZOOM::Connection', no_auto => 1); >+$zoom_connection->mock('search', sub { >+ return _new ZOOM::ResultSet(shift, shift, [$biblionumber2]); >+}); >+my $zoom_resultset = new Test::MockModule('ZOOM::ResultSet', no_auto => 1); >+$zoom_resultset->mock('size', sub { >+ my $this = shift; >+ return scalar @{ $this->{_rs} }; >+}); >+$zoom_resultset->mock('record', sub { >+ my ($this, $which) = @_; >+ my $_rec = { biblionumber => $this->{_rs}->[$which] }; >+ return ZOOM::Record->_new($this, $which, $_rec); >+}); >+$zoom_resultset->mock('destroy', undef); >+my $zoom_record = new Test::MockModule('ZOOM::Record', no_auto => 1); >+$zoom_record->mock('raw', sub { >+ my $this = shift; >+ my $marcs = $dbh->selectcol_arrayref( >+ 'SELECT marc FROM biblioitems WHERE biblionumber = ?', {}, >+ $this->{_rec}->{biblionumber}); >+ return $marcs->[0]; >+}); >+ >+my @biblios = C4::AuthoritiesMarc::merge($authid2, undef, $authid1, undef); >+ >+is_deeply(\@biblios, [$biblionumber2]); >+$biblio1 = GetMarcBiblio($biblionumber1); >+is($biblio1->subfield('609', '9'), $authid1); >+is($biblio1->subfield('609', 'a'), 'George Orwell'); >+$biblio2 = GetMarcBiblio($biblionumber2); >+is($biblio2->subfield('609', '9'), $authid1); >+is($biblio2->subfield('609', 'a'), 'George Orwell'); >+ >+ok(defined(GetAuthority($authid1))); >+ok(!defined(GetAuthority($authid2))); >+# End testing C4::AuthoritiesMarc::merge >+ > $dbh->rollback; >-- >1.7.9.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 11700
:
25086
|
25413
|
25414
|
25426
|
27970
|
27971
|
27972
|
27973
|
28176
|
28177
|
35107
|
39264
|
39265
|
39266
|
39267
|
39268
|
39269
|
40968
|
40969
|
40970
|
40971
|
40972
|
45048
|
45049
|
45050
|
45051
|
45052
|
45053
|
46397
|
46398
|
46399
|
46400
|
46401
|
46402
|
56469
|
56470
|
56471
|
56472
|
56473
|
56474