From 3f266981ec517750afa91768e854aa4012de9738 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 28 Sep 2020 15:32:52 +0200 Subject: [PATCH] Bug 26414: Tidy the tests --- t/db_dependent/Record/marcrecord2csv.t | 61 ++++++++++++++------------ 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/t/db_dependent/Record/marcrecord2csv.t b/t/db_dependent/Record/marcrecord2csv.t index 0dcdbab0b6..18358f9f6a 100755 --- a/t/db_dependent/Record/marcrecord2csv.t +++ b/t/db_dependent/Record/marcrecord2csv.t @@ -126,34 +126,39 @@ is( $csv_output, q[Title|AVs ], q|TT way: display first subfield a for first field 245 if indicator 1 == 1 for field 100 is set| ); - - -# Bug 26414 - Unable to export Withdrawn status using CSV profile -# Test that subfieldtag '0' works in the fieldtag '952' -my $record2 = new_record(); -my $frameworkcode2 = q||; -# We change the barcode of the second item record to prevent an error "duplicate entry" -my $field = $record->field('952'); -my $new_field = new MARC::Field('952', ' ', ' ', - 0 => '1', - p => '3010023918', -); -$field->replace_with($new_field); -# We create another record -my ( $biblionumber2, $biblioitemnumber2 ) = AddBiblio( $record2, $frameworkcode2 ); -# We add two item to two record to test fieldtag 952 and subfieldtag 9520 -my (undef, undef, $itemnumber2) = AddItemFromMarc($record2, $biblionumber); -my (undef, undef, $itemnumber) = AddItemFromMarc($record, $biblionumber); -$csv_content = q(Titre=245a|Nom de personne=100a|Statut « Élagué »=9520); -my $csv_profile_id_10 = insert_csv_profile( {csv_content => $csv_content } ); -$csv_output = C4::Record::marcrecord2csv( $biblionumber, $csv_profile_id_10, 1, $csv); -is($csv_output, q[Titre|"Nom de personne"|"Statut « Élagué »" -"The art of computer programming,The art of another title"|"Knuth, Donald Ervin"|Withdrawn;Withdrawn -], q|subfieldtag 952$0 is not working, should return 'Withdrawn'| -); - -# End Bug 26414 - +subtest 'Test for subfields 0' => sub { + plan tests => 1; + + my $record2 = new_record(); + my $frameworkcode2 = q||; + + # We change the barcode of the second item record to prevent an error "duplicate entry" + my $field = $record->field('952'); + my $new_field = new MARC::Field( + '952', ' ', ' ', + 0 => '1', + p => '3010023918', + ); + $field->replace_with($new_field); + + # We create another record + my ( $biblionumber2, $biblioitemnumber2 ) = AddBiblio( $record2, $frameworkcode2 ); + + # We add two item to two record to test fieldtag 952 and subfieldtag 9520 + my ( undef, undef, $itemnumber2 ) = AddItemFromMarc( $record2, $biblionumber ); + my ( undef, undef, $itemnumber ) = AddItemFromMarc( $record, $biblionumber ); + $csv_content = q(Titre=245a|Nom de personne=100a|Statut « Élagué »=9520); + my $csv_profile_id_10 = insert_csv_profile( { csv_content => $csv_content } ); + $csv_output = C4::Record::marcrecord2csv( $biblionumber, $csv_profile_id_10, 1, $csv ); + is_deeply( + [ split "\n", $csv_output ], + [ + q[Titre|"Nom de personne"|"Statut « Élagué »"], + q["The art of computer programming,The art of another title"|"Knuth, Donald Ervin"|Withdrawn;Withdrawn], + ], + "subfieldtag 952$0 is not working, should return 'Withdrawn'" + ); +}; sub insert_csv_profile { my ( $params ) = @_; -- 2.20.1