Bug 26414: Tidy the tests

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-09-28 15:32:52 +02:00
parent b048d155bf
commit 3cd40f7baf
1 changed files with 29 additions and 24 deletions

View File

@ -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|
);
subtest 'Test for subfields 0' => sub {
plan tests => 1;
my $record2 = new_record();
my $frameworkcode2 = q||;
# 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'|
);
# 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);
# End Bug 26414
# 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],
],
q[subfieldtag 952\$0 is not working, should return 'Withdrawn']
);
};
sub insert_csv_profile {
my ( $params ) = @_;