Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use DateTime::Duration; |
20 |
use DateTime::Duration; |
21 |
use Test::More tests => 91; |
21 |
use Test::More tests => 92; |
22 |
use Test::Warn; |
22 |
use Test::Warn; |
23 |
|
23 |
|
24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
Lines 29-34
use C4::Letters qw( GetQueuedMessages GetMessage );
Link Here
|
29 |
use C4::Budgets qw( AddBudgetPeriod AddBudget GetBudget ); |
29 |
use C4::Budgets qw( AddBudgetPeriod AddBudget GetBudget ); |
30 |
use Koha::Database; |
30 |
use Koha::Database; |
31 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
31 |
use Koha::DateUtils qw( dt_from_string output_pref ); |
|
|
32 |
use Koha::Holds; |
32 |
use Koha::Libraries; |
33 |
use Koha::Libraries; |
33 |
use Koha::Patrons; |
34 |
use Koha::Patrons; |
34 |
use Koha::Suggestions; |
35 |
use Koha::Suggestions; |
Lines 594-599
subtest 'ModSuggestion should work on suggestions without a suggester' => sub {
Link Here
|
594 |
is( $suggestion->{note}, "Test note", "ModSuggestion works on suggestions without a suggester" ); |
595 |
is( $suggestion->{note}, "Test note", "ModSuggestion works on suggestions without a suggester" ); |
595 |
}; |
596 |
}; |
596 |
|
597 |
|
|
|
598 |
subtest 'place_hold tests' => sub { |
599 |
plan tests => 4; |
600 |
|
601 |
t::lib::Mocks::mock_preference( "PlaceHoldsOnOrdersFromSuggestions", "0" ); |
602 |
|
603 |
my $biblio = $builder->build_sample_biblio(); |
604 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
605 |
my $suggestion = $builder->build_object( |
606 |
{ |
607 |
class => 'Koha::Suggestions', |
608 |
value => { |
609 |
branchcode => $patron->branchcode, |
610 |
biblionumber => undef, |
611 |
suggestedby => $patron->id |
612 |
} |
613 |
} |
614 |
); |
615 |
|
616 |
my $hold_id = $suggestion->place_hold(); |
617 |
is( $hold_id, undef, "No suggestion placed when preference is disabled" ); |
618 |
|
619 |
t::lib::Mocks::mock_preference( "PlaceHoldsOnOrdersFromSuggestions", "1" ); |
620 |
|
621 |
$hold_id = $suggestion->place_hold(); |
622 |
is( |
623 |
$hold_id, undef, |
624 |
"No suggestion placed when preference is enabled and suggestion does not have a biblionumber" |
625 |
); |
626 |
|
627 |
$suggestion->biblionumber( $biblio->id )->store(); |
628 |
$suggestion->discard_changes(); |
629 |
|
630 |
$hold_id = $suggestion->place_hold(); |
631 |
ok( $hold_id, "Suggestion placed when preference is enabled and suggestion does have a biblionumber" ); |
632 |
|
633 |
my $hold = Koha::Holds->find($hold_id); |
634 |
$hold->delete(); |
635 |
|
636 |
t::lib::Mocks::mock_preference( "PlaceHoldsOnOrdersFromSuggestions", "0" ); |
637 |
|
638 |
$hold_id = $suggestion->place_hold(); |
639 |
is( $hold_id, undef, "Suggestion not placed when preference is disabled and suggestion does have a biblionumber" ); |
640 |
|
641 |
}; |
642 |
|
597 |
subtest 'Suggestion with ISBN' => sub { |
643 |
subtest 'Suggestion with ISBN' => sub { |
598 |
my $suggestion_with_isbn = { |
644 |
my $suggestion_with_isbn = { |
599 |
isbn => '1940997232', |
645 |
isbn => '1940997232', |
600 |
- |
|
|