Lines 17-27
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 10; |
20 |
use Test::More tests => 11; |
21 |
use Test::Exception; |
21 |
use Test::Exception; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
|
|
23 |
use DateTime; |
23 |
|
24 |
|
24 |
use C4::Context; |
25 |
use C4::Context; |
|
|
26 |
use C4::Biblio; # AddBiblio |
27 |
use C4::Circulation; # AddIssue |
28 |
use C4::Members;# AddMember |
25 |
use Koha::Database; |
29 |
use Koha::Database; |
26 |
use Koha::DateUtils qw( dt_from_string ); |
30 |
use Koha::DateUtils qw( dt_from_string ); |
27 |
use Koha::Libraries; |
31 |
use Koha::Libraries; |
Lines 309-311
subtest 'store() tests' => sub {
Link Here
|
309 |
|
313 |
|
310 |
$schema->storage->txn_rollback; |
314 |
$schema->storage->txn_rollback; |
311 |
}; |
315 |
}; |
312 |
- |
316 |
|
|
|
317 |
subtest 'unblessed_all_relateds' => sub { |
318 |
plan tests => 3; |
319 |
|
320 |
$schema->storage->txn_begin; |
321 |
|
322 |
# FIXME It's very painful to create an issue in tests! |
323 |
my $library = $builder->build_object( { class => 'Koha::Libraries' } ); |
324 |
C4::Context->_new_userenv('xxx'); |
325 |
C4::Context->set_userenv(0,0,0,'firstname','surname', $library->branchcode, 'Midway Public Library', '', '', ''); |
326 |
my $patron_category = $builder->build( |
327 |
{ |
328 |
source => 'Category', |
329 |
value => { |
330 |
category_type => 'P', |
331 |
enrolmentfee => 0, |
332 |
BlockExpiredPatronOpacActions => -1, # Pick the pref value |
333 |
} |
334 |
} |
335 |
); |
336 |
my $patron_data = { |
337 |
firstname => 'firstname', |
338 |
surname => 'surname', |
339 |
categorycode => $patron_category->{categorycode}, |
340 |
branchcode => $library->branchcode, |
341 |
}; |
342 |
my $borrowernumber = C4::Members::AddMember(%$patron_data); |
343 |
my $patron = Koha::Patrons->find( $borrowernumber ); |
344 |
my ($biblionumber) = AddBiblio( MARC::Record->new, '' ); |
345 |
my $biblio = Koha::Biblios->find( $biblionumber ); |
346 |
my $item = $builder->build_object( |
347 |
{ |
348 |
class => 'Koha::Items', |
349 |
value => { |
350 |
homebranch => $library->branchcode, |
351 |
holdingbranch => $library->branchcode, |
352 |
biblionumber => $biblio->biblionumber, |
353 |
itemlost => 0, |
354 |
withdrawn => 0, |
355 |
} |
356 |
} |
357 |
); |
358 |
|
359 |
my $issue = AddIssue( $patron->unblessed, $item->barcode, DateTime->now->subtract( days => 1 ) ); |
360 |
my $overdues = Koha::Patrons->find( $patron->id )->get_overdues; # Koha::Patron->get_overdue prefetches |
361 |
my $overdue = $overdues->next->unblessed_all_relateds; |
362 |
is( $overdue->{issue_id}, $issue->issue_id, 'unblessed_all_relateds has field from the original table (issues)' ); |
363 |
is( $overdue->{title}, $biblio->title, 'unblessed_all_relateds has field from other tables (biblio)' ); |
364 |
is( $overdue->{homebranch}, $item->homebranch, 'unblessed_all_relateds has field from other tables (items)' ); |
365 |
|
366 |
$schema->storage->txn_rollback; |
367 |
}; |