Lines 10-16
my $dbh = C4::Context->dbh;
Link Here
|
10 |
$dbh->{AutoCommit} = 0; |
10 |
$dbh->{AutoCommit} = 0; |
11 |
$dbh->{RaiseError} = 1; |
11 |
$dbh->{RaiseError} = 1; |
12 |
|
12 |
|
13 |
$dbh->do(q|DELETE FROM marc_modification_template_actions|); |
|
|
14 |
$dbh->do(q|DELETE FROM marc_modification_templates|); |
13 |
$dbh->do(q|DELETE FROM marc_modification_templates|); |
15 |
|
14 |
|
16 |
# Creation |
15 |
# Creation |
Lines 19-33
like( $template_id, qr|^\d+$|, "new template returns an id" );
Link Here
|
19 |
|
18 |
|
20 |
is( AddModificationTemplateAction( |
19 |
is( AddModificationTemplateAction( |
21 |
$template_id, 'move_field', 1, |
20 |
$template_id, 'move_field', 1, |
22 |
'464', 'u', '', |
21 |
'464', 'u', '', '464', '3', |
23 |
'464', '3', '', |
22 |
'', '', '', |
24 |
'', '', '', '', '', '', '', |
23 |
'', '', '', '', '', '', |
25 |
'move first 464$u to 464$3' |
24 |
'move first 464$u to 464$3' |
26 |
), 1, "Add first action"); |
25 |
), 1, "Add first action"); |
27 |
|
26 |
|
28 |
is( AddModificationTemplateAction( |
27 |
is( AddModificationTemplateAction( |
29 |
$template_id, 'update_field', 0, |
28 |
$template_id, 'update_field', 0, |
30 |
'099', 't', 'LIV', |
29 |
'099', 't', 'LIV', '', '', |
31 |
'', '', '', |
30 |
'', '', '', |
32 |
'if', '200', 'b', 'equals', 'Text', '', |
31 |
'if', '200', 'b', 'equals', 'Text', '', |
33 |
'Update field 099$t with value LIV if 200$b matches "Text"' |
32 |
'Update field 099$t with value LIV if 200$b matches "Text"' |
Lines 35-42
is( AddModificationTemplateAction(
Link Here
|
35 |
|
34 |
|
36 |
is( AddModificationTemplateAction( |
35 |
is( AddModificationTemplateAction( |
37 |
$template_id, 'copy_field', 0, |
36 |
$template_id, 'copy_field', 0, |
38 |
'606', 'a', '', |
37 |
'606', 'a', '', '607', 'a', |
39 |
'607', 'a', '', |
38 |
'', '', '', |
40 |
'unless', '606', 'a', 'not_equals', '^AJAX', '1', |
39 |
'unless', '606', 'a', 'not_equals', '^AJAX', '1', |
41 |
'Copy field 606$a to 607$a unless 606$a matches RegEx m^AJAX' |
40 |
'Copy field 606$a to 607$a unless 606$a matches RegEx m^AJAX' |
42 |
), 1, "Add third action"); |
41 |
), 1, "Add third action"); |
Lines 87-93
is( $third_action->{conditional_value}, '^AJAX', "test conditional_value for thi
Link Here
|
87 |
# Modifications |
86 |
# Modifications |
88 |
is( ModModificationTemplateAction( |
87 |
is( ModModificationTemplateAction( |
89 |
$actions[1]->{mmta_id}, 'update_field', 0, |
88 |
$actions[1]->{mmta_id}, 'update_field', 0, |
90 |
'100', 'u', 'LIV', |
89 |
'100', 'u', 'LIV', '', '', |
91 |
'', '', '', |
90 |
'', '', '', |
92 |
'if', '200', 'c', 'equals', 'Text', '', |
91 |
'if', '200', 'c', 'equals', 'Text', '', |
93 |
'Update field 099$t with value LIV if 200$b matches "Text"' |
92 |
'Update field 099$t with value LIV if 200$b matches "Text"' |
Lines 126-132
is( GetModificationTemplateAction( $actions[2]->{mmta_id} )->{ordering}, '3', 'T
Link Here
|
126 |
is( DelModificationTemplateAction( $actions[0]->{mmta_id} ), 2, "Delete the first action, 2 others are reordered" ); |
125 |
is( DelModificationTemplateAction( $actions[0]->{mmta_id} ), 2, "Delete the first action, 2 others are reordered" ); |
127 |
is( GetModificationTemplateAction( $actions[0]->{mmta_id} ), undef, "first action does not exist anymore" ); |
126 |
is( GetModificationTemplateAction( $actions[0]->{mmta_id} ), undef, "first action does not exist anymore" ); |
128 |
|
127 |
|
129 |
is( DelModificationTemplate( $template_id ), 2, "2 actions are deleted" ); |
128 |
is( DelModificationTemplate( $template_id ), 1, "The template has been deleted" ); |
130 |
|
129 |
|
131 |
is( GetModificationTemplateAction( $actions[1]->{mmta_id} ), undef, "second action does not exist anymore" ); |
130 |
is( GetModificationTemplateAction( $actions[1]->{mmta_id} ), undef, "second action does not exist anymore" ); |
132 |
is( GetModificationTemplateAction( $actions[2]->{mmta_id} ), undef, "third action does not exist anymore" ); |
131 |
is( GetModificationTemplateAction( $actions[2]->{mmta_id} ), undef, "third action does not exist anymore" ); |
Lines 152-166
like( $template_id, qr|^\d+$|, "new template returns an id" );
Link Here
|
152 |
|
151 |
|
153 |
is( AddModificationTemplateAction( |
152 |
is( AddModificationTemplateAction( |
154 |
$template_id, 'copy_field', 0, |
153 |
$template_id, 'copy_field', 0, |
155 |
'245', 'a', '', |
154 |
'245', 'a', '', '246', 'a', |
156 |
'246', 'a', '', |
155 |
'', '', '', |
157 |
'', '', '', '', '', '', '', |
156 |
'', '', '', '', '', '', |
158 |
'copy field 245$a to 246$a' |
157 |
'copy field 245$a to 246$a' |
159 |
), 1, 'Add first action: copy 245$a to 246$a'); |
158 |
), 1, 'Add first action: copy 245$a to 246$a'); |
160 |
|
159 |
|
161 |
is( AddModificationTemplateAction( |
160 |
is( AddModificationTemplateAction( |
162 |
$template_id, 'delete_field', 0, |
161 |
$template_id, 'delete_field', 0, |
163 |
'650', 'a', '', |
162 |
'650', 'a', '', '', '', |
164 |
'', '', '', |
163 |
'', '', '', |
165 |
'if', '650', '9', 'equals', '462', '', |
164 |
'if', '650', '9', 'equals', '462', '', |
166 |
'Delete field 650$a if 650$9=462' |
165 |
'Delete field 650$a if 650$9=462' |
Lines 168-174
is( AddModificationTemplateAction(
Link Here
|
168 |
|
167 |
|
169 |
is( AddModificationTemplateAction( |
168 |
is( AddModificationTemplateAction( |
170 |
$template_id, 'update_field', 0, |
169 |
$template_id, 'update_field', 0, |
171 |
'952', 'p', '3010023917_updated', |
170 |
'952', 'p', '3010023917_updated', '', '', |
172 |
'', '', '', |
171 |
'', '', '', |
173 |
'unless', '650', '9', 'equals', '42', '', |
172 |
'unless', '650', '9', 'equals', '42', '', |
174 |
'Update field 952$p with "3010023917_updated" if 650$9 != 42' |
173 |
'Update field 952$p with "3010023917_updated" if 650$9 != 42' |
Lines 176-183
is( AddModificationTemplateAction(
Link Here
|
176 |
|
175 |
|
177 |
is( AddModificationTemplateAction( |
176 |
is( AddModificationTemplateAction( |
178 |
$template_id, 'move_field', 0, |
177 |
$template_id, 'move_field', 0, |
179 |
'952', 'd', '', |
178 |
'952', 'd', '', '952', 'e', '', |
180 |
'952', 'e', '', |
179 |
'', '', '', |
181 |
'if', '952', 'c', 'equals', '^GEN', '1', |
180 |
'if', '952', 'c', 'equals', '^GEN', '1', |
182 |
'Move field 952$d to 952$e if 952$c =~ /^GE/' |
181 |
'Move field 952$d to 952$e if 952$c =~ /^GE/' |
183 |
), 1, 'Add fourth action: move field 952$d to 952$e if 952$c =~ /^GE/'); |
182 |
), 1, 'Add fourth action: move field 952$d to 952$e if 952$c =~ /^GE/'); |