View | Details | Raw Unified | Return to bug 29341
Collapse All | Expand All

(-)a/C4/Stats.pm (+3 lines)
Lines 124-129 sub UpdateStats { Link Here
124
    my $location          = exists $params->{location}       ? $params->{location}       : undef;
124
    my $location          = exists $params->{location}       ? $params->{location}       : undef;
125
    my $ccode             = exists $params->{ccode}          ? $params->{ccode}          : '';
125
    my $ccode             = exists $params->{ccode}          ? $params->{ccode}          : '';
126
126
127
    # If $branch is set to an invalid branchcode, like 'OPACRenew'
128
    $branch = undef if $branch && ! Koha::Libraries->find($branch);
129
127
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
130
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
128
    my $statistic = Koha::Statistic->new(
131
    my $statistic = Koha::Statistic->new(
129
        {
132
        {
(-)a/t/db_dependent/Koha/Pseudonymization.t (-2 / +35 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 3;
22
use Test::More tests => 4;
23
use Try::Tiny;
23
use Try::Tiny;
24
24
25
use C4::Circulation qw( AddIssue AddReturn );
25
use C4::Circulation qw( AddIssue AddReturn );
Lines 29-34 use Koha::Database; Link Here
29
use Koha::DateUtils qw( dt_from_string );
29
use Koha::DateUtils qw( dt_from_string );
30
use Koha::Patrons;
30
use Koha::Patrons;
31
use Koha::PseudonymizedTransactions;
31
use Koha::PseudonymizedTransactions;
32
use Koha::Statistics;
32
33
33
use t::lib::TestBuilder;
34
use t::lib::TestBuilder;
34
use t::lib::Mocks;
35
use t::lib::Mocks;
Lines 209-211 subtest 'PseudonymizedBorrowerAttributes tests' => sub { Link Here
209
210
210
    $schema->storage->txn_rollback;
211
    $schema->storage->txn_rollback;
211
};
212
};
212
- 
213
214
subtest 'invalid branchcode' => sub {
215
    plan tests => 1;
216
217
    $schema->storage->txn_begin;
218
219
    t::lib::Mocks::mock_config( 'bcrypt_settings', '$2a$08$9lmorEKnwQloheaCLFIfje' );
220
221
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
222
223
    t::lib::Mocks::mock_preference( 'Pseudonymization', 1 );
224
    my $item = $builder->build_sample_item;
225
    my $library = $builder->build_object( { class => 'Koha::Libraries' } );
226
    my $branchcode = $library->branchcode;
227
    $library->delete;
228
229
    C4::Stats::UpdateStats(
230
        {
231
            type           => 'issue',
232
            branch         => $branchcode,
233
            itemnumber     => $item->itemnumber,
234
            borrowernumber => $patron->borrowernumber,
235
            itemtype       => $item->effective_itemtype,
236
            location       => $item->location,
237
            ccode          => $item->ccode,
238
        }
239
    );
240
241
    my $stat = Koha::Statistics->search({itemnumber => $item->itemnumber});
242
    is( $stat->next->branch, undef, 'UpdateStats does not explode if branchcode is invalid' );
243
244
    $schema->storage->txn_rollback;
245
};

Return to bug 29341