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 { # Test added for transaction_branchcode == 'OPACRenew' (BZ 29341) |
215 |
plan tests => 2; |
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, $branchcode, 'UpdateStats does not explode if branchcode is invalid, and stat logs the branchcode as is' ); |
243 |
|
244 |
my $p = Koha::PseudonymizedTransactions->search({itemnumber => $item->itemnumber}); |
245 |
is( $p->next->transaction_branchcode, undef, 'Pseudonymized transactions logged branchcode=NULL if invalid branchcode passed' ); |
246 |
|
247 |
$schema->storage->txn_rollback; |
248 |
}; |