Lines 67-73
my @rules = (
Link Here
|
67 |
value => 'updated_value', |
67 |
value => 'updated_value', |
68 |
}, |
68 |
}, |
69 |
], |
69 |
], |
70 |
duration => '0', |
70 |
age => '0', |
71 |
}, |
71 |
}, |
72 |
); |
72 |
); |
73 |
|
73 |
|
Lines 93-99
is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNew
Link Here
|
93 |
value => 'new_updated_value', |
93 |
value => 'new_updated_value', |
94 |
}, |
94 |
}, |
95 |
], |
95 |
], |
96 |
duration => '0', |
96 |
age => '0', |
97 |
}, |
97 |
}, |
98 |
); |
98 |
); |
99 |
|
99 |
|
Lines 104-110
is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: The new value is
Link Here
|
104 |
$marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); |
104 |
$marc_item = C4::Items::GetMarcItem( $biblionumber, $itemnumber ); |
105 |
is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new value is not updated| ); |
105 |
is( $marc_item->subfield($tagfield, $new_tagfield), 'updated_value', q|ToggleNewStatus: The new value is not updated| ); |
106 |
|
106 |
|
107 |
# Play with duration |
107 |
# Play with age |
108 |
$item = C4::Items::GetItem( $itemnumber ); |
108 |
$item = C4::Items::GetItem( $itemnumber ); |
109 |
my $dt_today = dt_from_string; |
109 |
my $dt_today = dt_from_string; |
110 |
my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) ); |
110 |
my $days5ago = $dt_today->add_duration( DateTime::Duration->new( days => -5 ) ); |
Lines 126-155
$item = C4::Items::GetItem( $itemnumber );
Link Here
|
126 |
value => 'new_updated_value', |
126 |
value => 'new_updated_value', |
127 |
}, |
127 |
}, |
128 |
], |
128 |
], |
129 |
duration => '10', |
129 |
age => '10', |
130 |
}, |
130 |
}, |
131 |
); |
131 |
); |
132 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
132 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
133 |
$modified_item = C4::Items::GetItem( $itemnumber ); |
133 |
$modified_item = C4::Items::GetItem( $itemnumber ); |
134 |
is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: Duration = 10 : The new value is not updated|); |
134 |
is( $modified_item->{new}, 'updated_value', q|ToggleNewStatus: Age = 10 : The new value is not updated|); |
135 |
|
135 |
|
136 |
$rules[0]->{duration} = 5; |
136 |
$rules[0]->{age} = 5; |
137 |
$rules[0]->{substitutions}[0]{value} = 'new_updated_value5'; |
137 |
$rules[0]->{substitutions}[0]{value} = 'new_updated_value5'; |
138 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
138 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
139 |
$modified_item = C4::Items::GetItem( $itemnumber ); |
139 |
$modified_item = C4::Items::GetItem( $itemnumber ); |
140 |
is( $modified_item->{new}, 'new_updated_value5', q|ToggleNewStatus: Duration = 5 : The new value is updated|); |
140 |
is( $modified_item->{new}, 'new_updated_value5', q|ToggleNewStatus: Age = 5 : The new value is updated|); |
141 |
|
141 |
|
142 |
$rules[0]->{duration} = ''; |
142 |
$rules[0]->{age} = ''; |
143 |
$rules[0]->{substitutions}[0]{value} = 'new_updated_value_empty_string'; |
143 |
$rules[0]->{substitutions}[0]{value} = 'new_updated_value_empty_string'; |
144 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
144 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
145 |
$modified_item = C4::Items::GetItem( $itemnumber ); |
145 |
$modified_item = C4::Items::GetItem( $itemnumber ); |
146 |
is( $modified_item->{new}, 'new_updated_value_empty_string', q|ToggleNewStatus: Duration = '' : The new value is updated|); |
146 |
is( $modified_item->{new}, 'new_updated_value_empty_string', q|ToggleNewStatus: Age = '' : The new value is updated|); |
147 |
|
147 |
|
148 |
$rules[0]->{duration} = undef; |
148 |
$rules[0]->{age} = undef; |
149 |
$rules[0]->{substitutions}[0]{value} = 'new_updated_value_undef'; |
149 |
$rules[0]->{substitutions}[0]{value} = 'new_updated_value_undef'; |
150 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
150 |
C4::Items::ToggleNewStatus( { rules => \@rules } ); |
151 |
$modified_item = C4::Items::GetItem( $itemnumber ); |
151 |
$modified_item = C4::Items::GetItem( $itemnumber ); |
152 |
is( $modified_item->{new}, 'new_updated_value_undef', q|ToggleNewStatus: Duration = undef : The new value is updated|); |
152 |
is( $modified_item->{new}, 'new_updated_value_undef', q|ToggleNewStatus: Age = undef : The new value is updated|); |
153 |
|
153 |
|
154 |
# Field deletion |
154 |
# Field deletion |
155 |
@rules = ( |
155 |
@rules = ( |
Lines 166-172
is( $modified_item->{new}, 'new_updated_value_undef', q|ToggleNewStatus: Duratio
Link Here
|
166 |
value => '', |
166 |
value => '', |
167 |
}, |
167 |
}, |
168 |
], |
168 |
], |
169 |
duration => '0', |
169 |
age => '0', |
170 |
}, |
170 |
}, |
171 |
); |
171 |
); |
172 |
|
172 |
|
Lines 196-202
is( $marc_item->subfield($tagfield, $new_tagfield), undef, q|ToggleNewStatus: Th
Link Here
|
196 |
value => 'new_value', |
196 |
value => 'new_value', |
197 |
}, |
197 |
}, |
198 |
], |
198 |
], |
199 |
duration => '0', |
199 |
age => '0', |
200 |
}, |
200 |
}, |
201 |
); |
201 |
); |
202 |
|
202 |
|
Lines 223-229
is( $modified_item->{new}, 'new_value', q|ToggleNewStatus: conditions multiple:
Link Here
|
223 |
value => 'new_updated_value', |
223 |
value => 'new_updated_value', |
224 |
}, |
224 |
}, |
225 |
], |
225 |
], |
226 |
duration => '0', |
226 |
age => '0', |
227 |
}, |
227 |
}, |
228 |
); |
228 |
); |
229 |
|
229 |
|
Lines 250-256
is( $modified_item->{new}, 'new_value', q|ToggleNewStatus: conditions multiple:
Link Here
|
250 |
value => 'new_updated_value', |
250 |
value => 'new_updated_value', |
251 |
}, |
251 |
}, |
252 |
], |
252 |
], |
253 |
duration => '0', |
253 |
age => '0', |
254 |
}, |
254 |
}, |
255 |
); |
255 |
); |
256 |
|
256 |
|
Lines 273-279
is( $modified_item->{new}, 'new_updated_value', q|ToggleNewStatus: conditions mu
Link Here
|
273 |
value => 'another_new_updated_value', |
273 |
value => 'another_new_updated_value', |
274 |
}, |
274 |
}, |
275 |
], |
275 |
], |
276 |
duration => '0', |
276 |
age => '0', |
277 |
}, |
277 |
}, |
278 |
); |
278 |
); |
279 |
|
279 |
|