Bugzilla – Attachment 99027 Details for
Bug 6473
Test bug for Git-bz ✔ ❤ ★
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17510: update MMT-related unit tests
Bug-17510-update-MMT-related-unit-tests.patch (text/plain), 8.09 KB, created by
Andreas Roussos
on 2020-02-14 20:18:20 UTC
(
hide
)
Description:
Bug 17510: update MMT-related unit tests
Filename:
MIME Type:
Creator:
Andreas Roussos
Created:
2020-02-14 20:18:20 UTC
Size:
8.09 KB
patch
obsolete
>From 835a957c3e984ae9bcb1d9544647a4e2e68aa74e Mon Sep 17 00:00:00 2001 >From: Andreas Roussos <arouss1980@gmail.com> >Date: Fri, 14 Feb 2020 20:07:50 +0000 >Subject: [PATCH] Bug 17510: update MMT-related unit tests > >The unit tests related to MARC modification templates need to be >updated with extra tests specific to actions involving subfield 0. > >Test plan: >0) Apply the patch. >1) Run the updated unit tests, they should pass without any errors: > $ prove t/SimpleMARC.t > $ prove t/db_dependent/MarcModificationTemplates.t > >https://bugs.koha-community.org/show_bug.cgi?id=6473 >--- > t/SimpleMARC.t | 40 ++++++++- > t/db_dependent/MarcModificationTemplates.t | 135 ++++++++++++++++++++++++++++- > 2 files changed, 171 insertions(+), 4 deletions(-) > >diff --git a/t/SimpleMARC.t b/t/SimpleMARC.t >index d32ac88bf5..4fd8933b29 100644 >--- a/t/SimpleMARC.t >+++ b/t/SimpleMARC.t >@@ -74,13 +74,17 @@ subtest 'field_exists' => sub { > subtest 'read_field' => sub { > plan tests => 2; > subtest 'read subfield' => sub { >- plan tests => 5; >+ plan tests => 6; > my $record = new_record; > $record->append_fields( > MARC::Field->new( > 650, ' ', '0', > a => 'Computer algorithms.', > 9 => '463', >+ ), >+ MARC::Field->new( >+ 600, ' ', '0', >+ 0 => '123456', > ) > ); > >@@ -130,6 +134,20 @@ subtest 'read_field' => sub { > [], > 'There is no 3 650$a' > ); >+ is_deeply( >+ [ >+ read_field( >+ { >+ record => $record, >+ field => '600', >+ subfield => '0', >+ field_numbers => [1] >+ } >+ ) >+ ], >+ ['123456'], >+ 'first 600$0' >+ ); > }; > subtest 'read field' => sub { > plan tests => 4; >@@ -191,7 +209,7 @@ subtest 'read_field' => sub { > subtest 'update_field' => sub { > plan tests => 1; > subtest 'update subfield' => sub { >- plan tests => 5; >+ plan tests => 6; > my $record = new_record; > > update_field( >@@ -250,6 +268,7 @@ subtest 'update_field' => sub { > 952, ' ', ' ', > p => '3010023917', > y => 'BK', >+ 0 => '123456', > ), > ); > update_field( >@@ -283,6 +302,23 @@ subtest 'update_field' => sub { > [ '3010023917', '3010023918' ], > 'update all subfields 952$p with the different values' > ); >+ >+ update_field( >+ { >+ record => $record, >+ field => '952', >+ subfield => '0', >+ values => [ '654321' ] >+ } >+ ); >+ my @fields_9520 = >+ read_field( { record => $record, field => '952', subfield => '0' } ); >+ is_deeply( >+ \@fields_9520, >+ [ '654321', '654321' ], >+ 'update all subfields 952$0 with the same value' >+ ); >+ > }; > }; > >diff --git a/t/db_dependent/MarcModificationTemplates.t b/t/db_dependent/MarcModificationTemplates.t >index f9628d7f2b..2d646190f6 100644 >--- a/t/db_dependent/MarcModificationTemplates.t >+++ b/t/db_dependent/MarcModificationTemplates.t >@@ -1,6 +1,6 @@ > use Modern::Perl; > >-use Test::More tests => 115; >+use Test::More tests => 125; > > use Koha::Database; > use Koha::SimpleMARC; >@@ -55,7 +55,7 @@ is( AddModificationTemplateAction( > # Getter > > my @actions = GetModificationTemplateActions( $template_id ); >-is( @actions, 4, "4 actions are insered"); >+is( @actions, 4, "4 actions are inserted"); > > for my $action ( @actions ) { > isnt( GetModificationTemplateAction( $action->{mmta_id} ), undef, "action with id $action->{mmta_id} exists" ); >@@ -546,3 +546,134 @@ sub expected_record_2 { > $record->append_fields(@fields); > return $record; > } >+ >+# Tests related to use of subfield 0 ($0) >+ >+sub new_record_0 { >+ my $record = MARC::Record->new; >+ $record->leader('03174nam a2200445 a 4500'); >+ my @fields = ( >+ MARC::Field->new( >+ 100, '1', ' ', >+ 0 => '12345', >+ a => 'Knuth, Donald Ervin', >+ d => '1938', >+ ), >+ MARC::Field->new( >+ 245, '1', '4', >+ 0 => '12345', >+ a => 'The art of computer programming', >+ c => 'Donald E. Knuth.', >+ ), >+ MARC::Field->new( >+ 650, ' ', '0', >+ 0 => '42', >+ a => 'Computer programming.', >+ 9 => '462', >+ ), >+ ); >+ $record->append_fields(@fields); >+ return $record; >+} >+ >+sub expected_record_0 { >+ my $record = MARC::Record->new; >+ $record->leader('03174nam a2200445 a 4500'); >+ my @fields = ( >+ MARC::Field->new( >+ 245, '1', '4', >+ 0 => '12345', >+ a => 'The art of computer programming', >+ c => 'Donald E. Knuth.', >+ ), >+ MARC::Field->new( >+ 650, ' ', '0', >+ 0 => '42', >+ a => 'Computer programming.', >+ 9 => '462', >+ ), >+ MARC::Field->new( >+ 600, ' ', ' ', >+ 0 => 'TestUpdated', >+ ), >+ MARC::Field->new( >+ 100, ' ', ' ', >+ 0 => 'TestUpdated', >+ ), >+ MARC::Field->new( >+ 700, '1', '4', >+ 0 => '12345', >+ a => 'The art of computer programming', >+ c => 'Donald E. Knuth.', >+ ), >+ ); >+ $record->append_fields(@fields); >+ return $record; >+} >+ >+$record = new_record_0(); >+is( ModifyRecordWithTemplate( $template_id, $record ), undef, "The ModifyRecordWithTemplate returns undef" ); >+ >+$template_id = AddModificationTemplate("template_test_subfield_0"); >+like( $template_id, qr|^\d+$|, "new template returns an id" ); >+ >+# Delete subfield 100$0 >+is( AddModificationTemplateAction( >+ $template_id, 'delete_field', 0, >+ '100', '0', '', '', '', >+ '', '', '', >+ '', '', '', '', '', '', >+ 'Action 1: Delete subfield 100$0' >+), 1, 'Action 1: Delete subfield 100$0'); >+ >+# Add new subfield 100$0 with value "Test" >+is( AddModificationTemplateAction( >+ $template_id, 'add_field', 0, >+ '100', '0', 'Test', '', '', >+ '', '', '', >+ '', '', '', '', '', '', >+ 'Action 2: Add new subfield 100$0 with value "Test"' >+), 1, 'Action 2: Add new subfield 100$0'); >+ >+# Update existing or add new subfield 100$0 with value "TestUpdated" >+is( AddModificationTemplateAction( >+ $template_id, 'update_field', 0, >+ '100', '0', 'TestUpdated', '', '', >+ '', '', '', >+ '', '', '', '', '', '', >+ 'Action 3: Update existing or add new subfield 100$0 with value "TestUpdated"' >+), 1, 'Action 3: Update existing or add new subfield 100$0 with value "TestUpdated"'); >+ >+# Move subfield 100$0 to 600$0 >+is( AddModificationTemplateAction( >+ $template_id, 'move_field', 0, >+ '100', '0', '', '600', '0', >+ '', '', '', >+ '', '', '', '', '', '', >+ 'Action 4: Move subfield 100$0 to 600$0' >+), 1, 'Action 4: Move subfield 100$0 to 600$0'); >+ >+# Copy subfield 600$0 to 100$0 >+is( AddModificationTemplateAction( >+ $template_id, 'copy_field', 0, >+ '600', '0', '', '100', '0', >+ '', '', '', >+ '', '', '', '', '', '', >+ 'Action 5: Copy subfield 600$0 to 100$0' >+), 1, 'Action 5: Copy subfield 600$0 to 100$0'); >+ >+# Copy and replace subfield 245$0 to 700$0 >+is( AddModificationTemplateAction( >+ $template_id, 'copy_and_replace_field', 0, >+ '245', '0', '', '700', '0', >+ '', '', '', >+ '', '', '', '', '', '', >+ 'Action 6: Copy and replace subfield 245$0 to 700$0' >+), 1, 'Action 6: Copy and replace subfield 245$0 to 700$0'); >+ >+my @actions_0 = GetModificationTemplateActions( $template_id ); >+is( @actions_0, 6, "6 actions are inserted"); >+ >+ModifyRecordWithTemplate( $template_id, $record ); >+my $expected_record_0 = expected_record_0(); >+is_deeply( $record, $expected_record_0, '100$0 has been deleted, added back, updated, moved to 600$0, and copied back to 100$0; finally, 245$0 has been copied and replaced to 700$0' ); >-- >2.11.0
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 6473
:
4386
|
6837
|
6838
|
6839
|
6840
|
6841
|
6842
|
6843
|
7154
|
7155
|
7567
|
7994
|
7995
|
7996
|
7997
|
8018
|
9807
|
9808
|
9813
|
9831
|
9832
|
9836
|
9854
|
10842
|
10843
|
10844
|
10845
|
10846
|
10847
|
10848
|
10849
|
10850
|
10851
|
10852
|
10853
|
10854
|
10855
|
10856
|
10857
|
10858
|
11540
|
11543
|
11544
|
12502
|
12513
|
12514
|
12515
|
12516
|
12517
|
12518
|
12519
|
13473
|
13673
|
14955
|
14969
|
14970
|
14972
|
15201
|
18949
|
18950
|
18951
|
18952
|
18953
|
18954
|
18955
|
18956
|
18957
|
18958
|
18959
|
18960
|
18961
|
18962
|
18963
|
18971
|
18972
|
19518
|
19519
|
19591
|
19592
|
19871
|
19879
|
19880
|
19881
|
19882
|
20011
|
20012
|
20013
|
20014
|
22477
|
22481
|
22482
|
22496
|
22502
|
22503
|
31958
|
32444
|
32445
|
32446
|
32447
|
32448
|
32449
|
32450
|
32451
|
32452
|
34200
|
34201
|
34625
|
34999
|
35130
|
35269
|
35273
|
35274
|
35275
|
35276
|
35277
|
35279
|
35280
|
35303
|
40954
|
40957
|
45345
|
45349
|
45731
|
45732
|
45733
|
45734
|
47283
|
47284
|
47298
|
47299
|
47300
|
47334
|
47336
|
49083
|
56974
|
61059
|
61069
|
62038
|
65313
|
77301
|
78016
|
79959
|
80178
|
80179
|
80180
|
80181
|
80182
|
84400
|
86644
|
86645
|
87152
|
88128
|
95586
|
95716
|
97394
|
99026
|
99027
|
114217
|
114218
|
114219
|
114220
|
114221
|
114222
|
114223
|
114224
|
114225
|
114226
|
119255
|
121181
|
131891
|
131893
|
131894
|
134862
|
144109
|
144144
|
144671
|
144672
|
144673
|
147183
|
149030
|
149031
|
149032
|
149033
|
160566
|
160567
|
160568