|
Lines 16-22
Link Here
|
| 16 |
|
16 |
|
| 17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
| 18 |
use Data::Dumper qw( Dumper ); |
18 |
use Data::Dumper qw( Dumper ); |
| 19 |
use Test::More tests => 6; |
19 |
use Test::More tests => 7; |
| 20 |
|
20 |
|
| 21 |
use C4::Context; |
21 |
use C4::Context; |
| 22 |
use C4::Log qw( logaction cronlogaction ); |
22 |
use C4::Log qw( logaction cronlogaction ); |
|
Lines 177-183
subtest 'Reduce log size by unblessing Koha objects' => sub {
Link Here
|
| 177 |
is( $logs->count, 1, 'Action found' ); |
177 |
is( $logs->count, 1, 'Action found' ); |
| 178 |
is( length($logs->next->info), length($str), 'Length exactly identical' ); |
178 |
is( length($logs->next->info), length($str), 'Length exactly identical' ); |
| 179 |
|
179 |
|
| 180 |
logaction( 'CATALOGUING', 'MODIFY', $item->itemnumber, $item, 'opac' ); |
180 |
logaction( 'CATALOGUING', 'MODIFY', $item->itemnumber, $item, 'opac', $item ); |
| 181 |
$logs = Koha::ActionLogs->search({ module => 'CATALOGUING', action => 'MODIFY', object => $item->itemnumber }); |
181 |
$logs = Koha::ActionLogs->search({ module => 'CATALOGUING', action => 'MODIFY', object => $item->itemnumber }); |
| 182 |
is( substr($logs->next->info, 0, 5), 'item ', 'Prefix item' ); |
182 |
is( substr($logs->next->info, 0, 5), 'item ', 'Prefix item' ); |
| 183 |
is( length($logs->reset->next->info), 5+length($str), 'Length + 5' ); |
183 |
is( length($logs->reset->next->info), 5+length($str), 'Length + 5' ); |
|
Lines 218-221
subtest 'Test storing diff of objects' => sub {
Link Here
|
| 218 |
is( $diff->{D}->{barcode}->{N}, '_MY_TEST_BARCODE_', 'Diff of changes logged successfully' ); |
218 |
is( $diff->{D}->{barcode}->{N}, '_MY_TEST_BARCODE_', 'Diff of changes logged successfully' ); |
| 219 |
}; |
219 |
}; |
| 220 |
|
220 |
|
|
|
221 |
subtest 'Test storing original version of an item' => sub { |
| 222 |
plan tests => 1; |
| 223 |
|
| 224 |
$Data::Dumper::Sortkeys = 1; |
| 225 |
my $builder = t::lib::TestBuilder->new; |
| 226 |
my $item = $builder->build_sample_item; |
| 227 |
my $original = $item->get_from_storage; |
| 228 |
|
| 229 |
# make sure that $item->...->store logs the update |
| 230 |
t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); |
| 231 |
$item->barcode('_MY_OTHER_BARCODE_')->store(); |
| 232 |
|
| 233 |
# update was logged under CATALOGUING / MODIFY so we can retrieve the log now |
| 234 |
my $log = |
| 235 |
Koha::ActionLogs->search( { module => 'CATALOGUING', action => 'MODIFY', object => $item->itemnumber } )->next; |
| 236 |
my $info = $log->info; |
| 237 |
is( $info, "item " . Dumper( $original->unblessed ), 'Original version of item logged successfully' ); |
| 238 |
}; |
| 239 |
|
| 221 |
$schema->storage->txn_rollback; |
240 |
$schema->storage->txn_rollback; |
| 222 |
- |
|
|