Bugzilla – Attachment 101439 Details for
Bug 24276
Add functionality to apply defaults from the ACQ framework for mandatory fields when adding records from external sources
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24276: Add unit tests for mandatory parameter of FillWithDefaultValues
Bug-24276-Add-unit-tests-for-mandatory-parameter-o.patch (text/plain), 2.69 KB, created by
Bernardo Gonzalez Kriegel
on 2020-03-23 12:42:52 UTC
(
hide
)
Description:
Bug 24276: Add unit tests for mandatory parameter of FillWithDefaultValues
Filename:
MIME Type:
Creator:
Bernardo Gonzalez Kriegel
Created:
2020-03-23 12:42:52 UTC
Size:
2.69 KB
patch
obsolete
>From 6da4950cef72e21de002de07d8b3d4a3048d3db7 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 20 Dec 2019 08:20:23 +0000 >Subject: [PATCH] Bug 24276: Add unit tests for mandatory parameter of > FillWithDefaultValues > >Test plan: >Run t/db_dependent/Acquisition/FillWithDefaultValues.t > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> >Test pass >--- > .../Acquisition/FillWithDefaultValues.t | 25 +++++++++++++++++-- > 1 file changed, 23 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Acquisition/FillWithDefaultValues.t b/t/db_dependent/Acquisition/FillWithDefaultValues.t >index 0bba1be9dc..96969e0c7f 100755 >--- a/t/db_dependent/Acquisition/FillWithDefaultValues.t >+++ b/t/db_dependent/Acquisition/FillWithDefaultValues.t >@@ -1,5 +1,5 @@ > use Modern::Perl; >-use Test::More tests => 6; >+use Test::More tests => 12; > use Test::MockModule; > > use MARC::Record; >@@ -26,7 +26,7 @@ $biblio_module->mock( > > # default value for an existing field > '245' => { >- c => { defaultvalue => $default_author }, >+ c => { defaultvalue => $default_author, mandatory => 1 }, > mandatory => 0, > repeatable => 0, > tab => 0, >@@ -37,6 +37,11 @@ $biblio_module->mock( > '099' => { > x => { defaultvalue => $default_x }, > }, >+ '942' => { >+ c => { defaultvalue => 'BK', mandatory => 1 }, >+ d => { defaultvalue => '942d_val' }, >+ f => { defaultvalue => '942f_val' }, >+ }, > }; > } > ); >@@ -96,4 +101,20 @@ $record->field('008')->update( undef ); > C4::Acquisition::FillWithDefaultValues($record); > is( $record->field('008')->data, $default_x, 'Controlfield got default' ); > >+is( $record->subfield('942','d'), '942d_val', 'Check 942d' ); >+ >+# Now test only_mandatory parameter >+$record->delete_fields( $record->field('245') ); >+$record->delete_fields( $record->field('942') ); >+$record->append_fields( MARC::Field->new('942','','','f'=>'f val') ); >+# We deleted 245 and replaced 942. If we only apply mandatories, we should get >+# back 245c again and 942c but not 942d. 942f should be left alone. >+C4::Acquisition::FillWithDefaultValues($record, { only_mandatory => 1 }); >+@fields_245 = $record->field(245); >+is( scalar @fields_245, 1, 'Only one 245 expected' ); >+is( $record->subfield('245','c'), $default_author, '245c restored' ); >+is( $record->subfield('942','c'), 'BK', '942c also restored' ); >+is( $record->subfield('942','d'), undef, '942d should not be there' ); >+is( $record->subfield('942','f'), 'f val', '942f untouched' ); >+ > $schema->storage->txn_rollback; >-- >2.17.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 24276
:
96507
|
96508
|
96509
|
96510
|
96511
|
96512
|
96513
|
100376
|
100377
|
100378
|
101437
|
101438
|
101439
|
101505
|
101506
|
101507