Lines 15-21
Link Here
|
15 |
# with Koha; if not, see <http://www.gnu.org/licenses>. |
15 |
# with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
|
16 |
|
17 |
use Modern::Perl; |
17 |
use Modern::Perl; |
18 |
use Test::More tests => 3; |
18 |
use Data::Dumper qw( Dumper ); |
|
|
19 |
use Test::More tests => 4; |
19 |
|
20 |
|
20 |
use C4::Context; |
21 |
use C4::Context; |
21 |
use C4::Log qw( logaction cronlogaction ); |
22 |
use C4::Log qw( logaction cronlogaction ); |
Lines 150-153
subtest 'GDPR logging' => sub {
Link Here
|
150 |
is( $logs->count, 1, 'We expect only one auth success line for this patron' ); |
151 |
is( $logs->count, 1, 'We expect only one auth success line for this patron' ); |
151 |
}; |
152 |
}; |
152 |
|
153 |
|
|
|
154 |
subtest 'Reduce log size by unblessing Koha objects' => sub { |
155 |
plan tests => 7; |
156 |
|
157 |
my $builder = t::lib::TestBuilder->new; |
158 |
my $item = $builder->build_sample_item; |
159 |
|
160 |
logaction( 'MY_MODULE', 'TEST01', $item->itemnumber, $item, 'opac' ); |
161 |
my $str = Dumper($item->unblessed); |
162 |
my $logs = Koha::ActionLogs->search({ module => 'MY_MODULE', action => 'TEST01', object => $item->itemnumber }); |
163 |
is( $logs->count, 1, 'Action found' ); |
164 |
is( length($logs->next->info), length($str), 'Length exactly identical' ); |
165 |
|
166 |
logaction( 'CATALOGUING', 'MODIFY', $item->itemnumber, $item, 'opac' ); |
167 |
$logs = Koha::ActionLogs->search({ module => 'CATALOGUING', action => 'MODIFY', object => $item->itemnumber }); |
168 |
is( substr($logs->next->info, 0, 5), 'item ', 'Prefix item' ); |
169 |
is( length($logs->reset->next->info), 5+length($str), 'Length + 5' ); |
170 |
|
171 |
my $hold = $builder->build_object({ class => 'Koha::Holds' }); |
172 |
logaction( 'MY_CIRC_MODULE', 'TEST', $item->itemnumber, $hold, 'opac' ); |
173 |
$logs = Koha::ActionLogs->search({ module => 'MY_CIRC_MODULE', action => 'TEST', object => $item->itemnumber }); |
174 |
is( length($logs->next->info), length( Dumper($hold->unblessed)), 'Length of dumped unblessed hold' ); |
175 |
|
176 |
logaction( 'MY_MODULE', 'TEST02', $item->itemnumber, [], 'opac' ); |
177 |
$logs = Koha::ActionLogs->search({ module => 'MY_MODULE', action => 'TEST02', object => $item->itemnumber }); |
178 |
like( $logs->next->info, qr/^ARRAY\(/, 'Dumped arrayref' ); |
179 |
|
180 |
logaction( 'MY_MODULE', 'TEST03', $item->itemnumber, $builder, 'opac' ); |
181 |
$logs = Koha::ActionLogs->search({ module => 'MY_MODULE', action => 'TEST03', object => $item->itemnumber }); |
182 |
like( $logs->next->info, qr/^t::lib::TestBuilder/, 'Dumped TestBuilder object' ); |
183 |
}; |
184 |
|
153 |
$schema->storage->txn_rollback; |
185 |
$schema->storage->txn_rollback; |
154 |
- |
|
|