Lines 33-39
use Koha::AuthorisedValues;
Link Here
|
33 |
use t::lib::Mocks; |
33 |
use t::lib::Mocks; |
34 |
use t::lib::TestBuilder; |
34 |
use t::lib::TestBuilder; |
35 |
|
35 |
|
36 |
use Test::More tests => 15; |
36 |
use Test::More tests => 16; |
37 |
|
37 |
|
38 |
use Test::Warn; |
38 |
use Test::Warn; |
39 |
|
39 |
|
Lines 117-145
subtest 'ModItem tests' => sub {
Link Here
|
117 |
$schema->storage->txn_begin; |
117 |
$schema->storage->txn_begin; |
118 |
|
118 |
|
119 |
my $builder = t::lib::TestBuilder->new; |
119 |
my $builder = t::lib::TestBuilder->new; |
120 |
my $item = $builder->build({ |
120 |
my $item = $builder->build_sample_item(); |
121 |
source => 'Item', |
|
|
122 |
value => { |
123 |
itemlost => 0, |
124 |
damaged => 0, |
125 |
withdrawn => 0, |
126 |
itemlost_on => undef, |
127 |
damaged_on => undef, |
128 |
withdrawn_on => undef, |
129 |
} |
130 |
}); |
131 |
|
121 |
|
132 |
my @fields = qw( itemlost withdrawn damaged ); |
122 |
my @fields = qw( itemlost withdrawn damaged ); |
133 |
for my $field (@fields) { |
123 |
for my $field (@fields) { |
134 |
$item->{$field} = 1; |
124 |
my $field_on = $field."_on"; |
135 |
ModItem( $item, $item->{biblionumber}, $item->{itemnumber} ); |
125 |
|
136 |
my $post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed; |
126 |
$item->$field(1); |
137 |
is( output_pref({ str => $post_mod_item->{$field."_on"}, dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "When updating $field, $field"."_on is updated" ); |
127 |
ModItem( $item->unblessed, $item->biblionumber, $item->itemnumber ); |
138 |
|
128 |
$item->discard_changes; |
139 |
$item->{$field} = 0; |
129 |
is( output_pref({ str => $item->$field_on, dateonly => 1 }), output_pref({ dt => dt_from_string(), dateonly => 1 }), "When updating $field, $field_on is updated" ); |
140 |
ModItem( $item, $item->{biblionumber}, $item->{itemnumber} ); |
130 |
|
141 |
$post_mod_item = Koha::Items->find({ itemnumber => $item->{itemnumber} })->unblessed; |
131 |
$item->$field(0); |
142 |
is( $post_mod_item->{$field."_on"}, undef, "When clearing $field, $field"."_on is cleared" ); |
132 |
ModItem( $item->unblessed, $item->biblionumber, $item->itemnumber ); |
|
|
133 |
$item->discard_changes; |
134 |
is( $item->$field_on, undef, "When clearing $field, $field_on is cleared" ); |
143 |
} |
135 |
} |
144 |
|
136 |
|
145 |
$schema->storage->txn_rollback; |
137 |
$schema->storage->txn_rollback; |
Lines 152-170
subtest 'ModItemTransfer tests' => sub {
Link Here
|
152 |
$schema->storage->txn_begin; |
144 |
$schema->storage->txn_begin; |
153 |
|
145 |
|
154 |
my $builder = t::lib::TestBuilder->new; |
146 |
my $builder = t::lib::TestBuilder->new; |
155 |
my $item = $builder->build_object( |
147 |
my $item = $builder->build_sample_item(); |
156 |
{ |
|
|
157 |
class => 'Koha::Items', |
158 |
value => { |
159 |
itemlost => 0, |
160 |
damaged => 0, |
161 |
withdrawn => 0, |
162 |
itemlost_on => undef, |
163 |
damaged_on => undef, |
164 |
withdrawn_on => undef, |
165 |
} |
166 |
} |
167 |
)->store; |
168 |
|
148 |
|
169 |
my $library1 = $builder->build( |
149 |
my $library1 = $builder->build( |
170 |
{ |
150 |
{ |
171 |
- |
|
|